Programming languages

This is where you talk about the NXJ software itself, installation issues, and programming talk.

Moderators: roger, 99jonathan, imaqine

Programming languages

Postby Aqualuna » Wed Oct 31, 2012 1:46 am

Hello,

I'm bought an NXT just a few days ago, and after a few attempts to use NXT-G I realized I wanted something that felt more like real programming. I was initially looking for an ansi C++ or C, since i have more experience with those languages, but I couldn't find one that didn't look as a dead project. So far the only language I've tried is java with lejos, and so far I've liked it. I'm wondering what other real alternatives are there to program the NXT, I havent been able to find any recent comparison between the big languages.

I would like to compare them in terms of speed, maturity, features, community size, library, and 3rd party hardware support, if someone could point me the major differences that would be great...

thanks in advance
Aqualuna
New User
 
Posts: 13
Joined: Mon Oct 29, 2012 9:52 pm

Re: Programming languages

Postby gloomyandy » Wed Oct 31, 2012 9:26 am

Hi,
I don't think you will find an up to date comparison of languages. In my opinion, there are really only four options for you to consider assuming your main aim is on brick programming, rather than some form of remote control (most of the others are in effect either no longer supported, or only have a minimal set of devices supported). These are:
* leJOS - Open source prject that supprorts the use of Java
*NXG - The Lego Mindstorms official programming environment
* RobotC A commercial product that provides a "C like" language for the NXT
* NXC An open source "C like" language environment

All of the above are pretty well supported and have a strong community behind them. They are all very different though, both in terms of things like language compliance and the programming environment they use. So for instance leJOS supports pretty much all of the standard Java language features and a large sub-set of the standard class library. It uses an industry standard IDE (Eclipse).

Probably best for you to take your own look at the above ... I may be a little biased!

Andy
User avatar
gloomyandy
leJOS Team Member
 
Posts: 3004
Joined: Fri Sep 28, 2007 2:06 pm
Location: UK

Re: Programming languages

Postby skoehler » Wed Oct 31, 2012 12:46 pm

It is worth mentioning, that all of the above transform the code into some form of byte-code, which is then interpreted. None of the above generate native arm code.
Also, NXC generated bytecode for the standard Lego firmware. RobotC has its own firmware (and byte-code interpreter).
leJOS also has its own firmware, and interprets standard Java byte code.

Also, leJOS has unique features like threading- something that other languages (like RobotC) really suck at.
(For example, there or no mutexes or conditions variables in RobotC)

gloomyandy wrote:I may be a little biased!


No no ...
skoehler
leJOS Team Member
 
Posts: 1114
Joined: Thu Oct 30, 2008 4:54 pm

Re: Programming languages

Postby Aqualuna » Wed Oct 31, 2012 4:47 pm

Thanks for the replay, how is nxtOSEK?, I assume all the C-like are not OOP. So I guess Java is the best alternative to me, my only concerns in Java are speed and code size, but at this point I'm doing just fine. In the situation that I need more computational power and memory I could use a computer I suppose, the question is, is the bluetooth or usb latency short enough to respond in realtime? Would it be a good idea to stream input data from the bot to the PC the whole time to reduce the latency?

I'm at this moment writing a GUI class to set some values in my NXT program, unless I completly missed it, it seems there aren't any gui classes. I could write a few and maybe help the project if that's even possible, stuff I would like to have at this moment is, a way to enter values and text, some ploting functionality and smaller text size.

Since you said there were not many supported alternatives and up to date comparisons, do you think its a sign of the community dying?

What are the most active forums for NXT users besides the language-specific ones? are there any chats as well?

cheers
Aqualuna
New User
 
Posts: 13
Joined: Mon Oct 29, 2012 9:52 pm

Re: Programming languages

Postby skoehler » Wed Oct 31, 2012 5:12 pm

Aqualuna wrote:Thanks for the replay, how is nxtOSEK?


I'm sorry, but I don't know much about that project.

Aqualuna wrote:I assume all the C-like are not OOP.


The C-like ones we mentioned do not provide OOP, AFAIK.

Aqualuna wrote:So I guess Java is the best alternative to me, my only concerns in Java are speed and code size, but at this point I'm doing just fine.


I am not sure, that code-size is an issue. Java byte-code can be quite compact. Also, we've added support for NXJ files larger than 64KB recently. You can now use the whole free space that is available after installing the leJOS firmware for your own programs.

Aqualuna wrote: In the situation that I need more computational power and memory I could use a computer I suppose, the question is, is the bluetooth or usb latency short enough to respond in realtime? Would it be a good idea to stream input data from the bot to the PC the whole time to reduce the latency?


You might run out of memory (only 64KB) and also out of CPU power. In both cases, you can use the PC.
The latency over USB is much lower than over bluetooth. Whether the latency is unbearably large depends on what you do.
If the NXT needs to react to sensor input very fast, you should probably implement that on the NXT-side of your program.

Aqualuna wrote: I'm at this moment writing a GUI class to set some values in my NXT program, unless I completly missed it, it seems there aren't any gui classes. I could write a few and maybe help the project if that's even possible, stuff I would like to have at this moment is, a way to enter values and text, some ploting functionality and smaller text size.


Google for "Java Swing" and "JFreeChart". The former is included in your JDK. The latter is a nice library for drawing diagrams.

Aqualuna wrote:Since you said there were not many supported alternatives and up to date comparisons, do you think its a sign of the community dying?


You mean the Lego NXT community, right?
I'm not sure whether it is dying. There are certainly cheaper and but also more powerful devices available (Arduino Due, Rasberry Pi).

Aqualuna wrote:What are the most active forums for NXT users besides the language-specific ones? are there any chats as well?


Like http://mindboards.sourceforge.net/ ?
skoehler
leJOS Team Member
 
Posts: 1114
Joined: Thu Oct 30, 2008 4:54 pm

Re: Programming languages

Postby Aqualuna » Wed Oct 31, 2012 7:47 pm

But Swing and JFreeChart don't run in the NXT do they?
Aqualuna
New User
 
Posts: 13
Joined: Mon Oct 29, 2012 9:52 pm

Re: Programming languages

Postby genom2 » Wed Oct 31, 2012 7:51 pm

I wonder! In which programing language is the leJOS VM itself implemented? Is it one of:
* NXG - The Lego Mindstorms official programming environment
* RobotC A commercial product that provides a "C like" language for the NXT
* NXC An open source "C like" language environment
???
I think there must be some C++ or C compiler for 32-bit ARM7 micro controller behind the scenes!
Why not recommend that C++ or C compiler to Aqualuna?
genom2
New User
 
Posts: 6
Joined: Tue Nov 08, 2011 11:01 pm

Re: Programming languages

Postby skoehler » Wed Oct 31, 2012 8:06 pm

Aqualuna wrote:But Swing and JFreeChart don't run in the NXT do they?

Sorry, I was under the impression you mean the NXT. No, Swing and JFreeChart won't run on the NXT.
skoehler
leJOS Team Member
 
Posts: 1114
Joined: Thu Oct 30, 2008 4:54 pm

Re: Programming languages

Postby skoehler » Wed Oct 31, 2012 8:07 pm

genom2 wrote:I wonder! In which programing language is the leJOS VM itself implemented?

A bit of ARM assembler and a lot of C.
genom2 wrote:Why not recommend that C++ or C compiler to Aqualuna?

I think he's looking for something less challenging.
skoehler
leJOS Team Member
 
Posts: 1114
Joined: Thu Oct 30, 2008 4:54 pm

Re: Programming languages

Postby Aqualuna » Wed Oct 31, 2012 11:36 pm

With challenges I suppose you mean low level io stuff, yeah I would rather like to work on a higher level... I hate to work on boilerplate code. I noticed there is a javax.microedition.lcdui that implements many ui elements, ill give that a shot.
Aqualuna
New User
 
Posts: 13
Joined: Mon Oct 29, 2012 9:52 pm

Re: Programming languages

Postby gloomyandy » Wed Oct 31, 2012 11:52 pm

There is also a couple of sample programs that show off the GUI and graphics capabilities. Take a look in the samples directory for lcdui and graphicssample...
User avatar
gloomyandy
leJOS Team Member
 
Posts: 3004
Joined: Fri Sep 28, 2007 2:06 pm
Location: UK

Re: Programming languages

Postby Aqualuna » Fri Nov 02, 2012 5:18 pm

Yeah i Just checked samples, pretty amazing the things you can do with lcdui, I still ended coding my own form class because I needed a "fast key repeat" feature.
Aqualuna
New User
 
Posts: 13
Joined: Mon Oct 29, 2012 9:52 pm


Return to NXJ Software

Who is online

Users browsing this forum: No registered users and 1 guest

more stuff