I'm a long time Java developer who is starting to learn on the Lego Mindstorms NXT 2.0. Are there any limitations to using the Java API? Which language is the most robust on the platform?

I found a post, Which programming language should I use with the NXT? which mentions many of the alternatives. The answer is helpful, but doesn't mention the different languages' limitations.

  • $\begingroup$ What research have you done? [link]lejos.sourceforge.net/nxt/nxj/api/index.html $\endgroup$
    – Spiked3
    Dec 11, 2012 at 16:01
  • $\begingroup$ This question is too broad. Maybe you could ask about specifically what it is you want to do? $\endgroup$ Dec 12, 2012 at 19:55
  • $\begingroup$ So think the intent of the question can be boiled down to is lejos a full featured language for nxt or are their operations that can only be performed by the native language? $\endgroup$
    – Bob Paulin
    Dec 12, 2012 at 23:12
  • $\begingroup$ "or are their operations that can only be performed by the native language" - you still lose me on that - no idea what it is asking. LeJOS is an implementation of a JVM. Parts of Java that are inappropriate (ie TCP) are not implemented. What else is there to know? Asking which language is most robust is too ambiguous - Ford or Chevy? teamhassenplug.org/NXT/NXTSoftware.html has a comparison chart $\endgroup$
    – Spiked3
    Dec 13, 2012 at 6:17
  • $\begingroup$ @Spiked3: Thank you for the comparison chart. One might also like to know (1) which (if any) of these alternatives supports hard real-time systems (a), (2) how much memory on the NXT is left over for my "user-level" programs and data after the language-support infrastructure libraries are loaded, (3) do any of these alternatives support interrupt handlers, etc. $\endgroup$
    – David Cary
    Dec 15, 2012 at 17:29

1 Answer 1


A lot of the different options with regards to language are listed on the NXT wiki page http://en.wikipedia.org/wiki/Lego_Mindstorms_NXT_2.0.

  • NXT-G NXT-G is the programming software included in the standard base kit. It is based on LabVIEW graphical programming. It features an interactive drag-and-drop environment. LabVIEW Toolkit[edit] NXT-G is powered by LabVIEW, an industry standard in programming. Created by National Instruments, LabVIEW uses data flow programming to create a virtual instrument. To allow for more advanced programming, in the graphical sense, National Instruments released a Toolkit for the NXT. Version 1.0 came out in December 2006 Since its release, several bugs have been found and new sensors have been created. While the toolkit does allow for the creation of new sensors, National Instruments has yet to formally release an update
  • Lego::NXT Lego::NXT provides an API between Perl and NXT.
  • Ada A port of GNAT is available for the NXT. It requires nxtOSEK to run. The port includes Ada bindings to the NXT hardware and nxtOSEK.
  • Next Byte Codes & Not eXactly C Next Byte Codes (NBC) is a simple open-source language with an assembly language syntax that can be used to program the NXT brick. Not eXactly C (NXC) is a high level open-source language, similar to C, built on top of the NBC compiler. It can also be used to program the NXT brick. NXC is basically NQC for the NXT. It is the most widely used third-party programming language.
  • ROBOTC ROBOTC is an Integrated development environment targeted towards students that is used to program and control LEGO NXT, VEX, RCX, and Arduino robots using a programming language based on the C programming language.
  • RoboMind RoboMind is an educational programming environment that offers a concise scripting language for programming a simulated robot. These internationalized scripts can, however, also directly be exported to Lego Mindstorms robots. It does not require custom firmware in order to run.
  • NXTGCC NXTGCC is a GCC toolchain for programming the NXT firmware in C. URBI[edit] URBI is a parallel and event-driven language, with interfaces to C++/Java and Matlab. It also has a component architecture (UObject) for distributed computation. Urbi is compatible with many robots, including Nao (cf Robocup), Bioloid or Aibo.
  • leJOS NXT leJOS NXT is a high level open source language based on Java that uses custom firmware developed by the leJOS team.
  • nxtOSEK To be able to write in C (programming language)/C++, nxtOSEK can be used, but that requires custom firmware too.
  • MATLAB and Simulink MATLAB is a high-level programming language for numerical computing, data acquisition and analysis. It can be used to control LEGO NXT robots over a Bluetooth serial port (serial port communication is part of the base functionality of MATLAB) or via a USB connection; for example using the RWTH - Mindstorms NXT Toolbox (free & open-source). Simulink is a MATLAB-based environment for modeling and simulating dynamic systems. Using Simulink, a user can design control algorithms, automatically generate C code for those algorithms, and download the compiled code onto the LEGO NXT. MATLAB and Simulink code for NXT programming is freely available.
  • Lua pbLua is an implementation of the Lua programming language, a general purpose scripting language, for Lego Mindstorms. FLL
  • NXT Navigation FLL Nxt Navigation An open source program to help navigation on the FLL competition table. Uses NXT-G and .txt files to write programs.
  • ruby-nxt ruby-nxt is a library to program the NXT for the Ruby programming language. Unlike the other languages for the NXT the code isn't compiled to a binary file. Instead the code is directly transmitted to the NXT via a bluetooth connection. This method of execution is significantly slower than executing compiled code directly. Robotics.
  • NXT Robotics.NXT is a Haskell interface to NXT over Bluetooth. It supports direct commands, messages and many sensors (also unofficial). It has also support for a simple message-based control of a NXT brick via remotely executed program (basic NXC code included).

As previously mentioned the chart in http://teamhassenplug.org/NXT/NXTSoftware.html is a good comparison.

Which language is the most robust on the platform?

Although I agree that the question is far too ambiguous, after using NXT-G, Matlab, Labview and a number of the other interfaces, I have found that the BricxCC IDE and the NXC is very easy to use with great contextual help and a lot of examples. It allows a lot more programming freedom that the visual based solutions do not offer. I have not attempted to use the higher level programming languages such as Java and C++ because most of the applications that I have been using would not have benefited from the advanced functions. If you are wanting these advanced functions is NXT the right hardware?

One might also like to know (1) which (if any) of these alternatives supports hard real-time systems

This post for the LeJOS discuses this with regards to Java: http://www.lejos.org/forum/viewtopic.php?f=18&t=4619 :- "The NXT firmware switches thread contexts every 1ms. Also, the scheduler of the NXT firmware is much more predictable. For example, a thread with high priority would be preferred by the scheduler over any thread with lower priority. So high priority threads could be pretty sure to be scheduled as soon as possible. The motor regulation was typically running as a high priority thread. But as you already guessed, the NXT firmware was no realtime system either. Threads with the same priority are served round-robin. Oh and once in a while, the garbage collector will halt the whole JVM. This is always true for the NXT. But the Oracle JVM used on the EV3 uses concurrent garbage collectors. However, in the worst case, even those fall back to halting the whole JVM. The trick to avoid that is to reuse object, arrays, and such stuff as far as possible in performance critical code paths."

how much memory on the NXT is left over for my "user-level" programs and data after the language-support infrastructure libraries are loaded

This post for the LeJOS discuses this with regards to Java: http://www.lejos.org/nxt/nxj/tutorial/AdvancedTopics/UnderstandingFilesLCPMemTools.htm

"The NXT has 256kb of flash memory. A fixed section at the start of the flash memory is allocated to the system. It is used to hold the firmware, followed by the startup menu. The rest of this system area is unused. The size of the system area varies between releases.

The firmware is written in C, with some ARM assembly language. The startup menu is written in Java (in the startup project in SVN).

Flash memory is read and written in 256-byte pages. The first page after the system area is used for persistent system settings administered by the startup menu.

The rest of the flash memory is used for the user file system. The first two pages hold the file table (directory), and the rest of the pages hold user files. Files are held as a contiguous set of bytes – i.e they use a single range of page numbers with no gaps. This allows a file to be addressed as a region of memory."

do any of these alternatives support interrupt handlers

One way of programming interrupt handlers on the NXT is to program at a lower level: http://www.tau.ac.il/~stoledo/lego/nxt-native/

"It's pretty easy to get started. You need two tools: the GNU development tools for ARM processors, and some way to download the resulting programs to the NXT. I use nexttool to download programs to the NXT, but I suppose that you could use NXT-G as well. There are several distributions of the GNU tools for ARM around. I usually use a distribution called WinARM, which is for windows; GNUARM and YAGARTO are two other options (I have used GNUARM on Linux)."

  • $\begingroup$ While the links are appreciated, sooner or later they are bound to rot. To be future-proof, it would be a good idea to quote the most relevant parts of the text you linked to right in this answer. $\endgroup$
    – Shahbaz
    Nov 12, 2013 at 14:36
  • $\begingroup$ Shahbaz I have edited the post to prevent the link rot. $\endgroup$
    – Tom Bamber
    Nov 13, 2013 at 13:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.