6 Answers
6

The programming interface used by LEGO creates programs which make use of the standard firmware, that is, the one provided by LEGO.

If you look at alternatives (see also this answer for more information), you'll notice that quite a lot of them use the same firmware.

This means that the programs they produce use the same language which is interpreted by the standard firmware. One advantage is that you can have a mix of programs on the same NXT brick and it doesn't matter with what they've been originally written.

If you're interested to know more about the standard firmware and how to program it, you can download the Mindstorms Software Developer Kit. One of the interesting aspects of it is that you don't always need to create programs but you can send direct commands to the NXT as well - meaning you actual programming logic can sit on another connected device (PC, smartphone,...).

Others alternate languages use a different firwmare altogether, which means you can't mix languages at all. But if it uses a language you're more familiar with, it may be worth trying. (You can always revert to the standard firmware anyway.)

There are alternate text-based programming languages for the NXT. Three of the most popular ones are NXC/NBC, LeJOS NXJ, and RobotC. There are many more, all with their pros and cons, and are much more versatile than NXT-G, even on slow computers. I my personal favorite is NXC/NBC. But really it's up to you. The best way to see what suits your needs is to look at this table. It lists most of the pros and cons of the different programming languages. NOTE: it may be slightly out of date, but useful none the less.

The main microcontroller in the NXT is an Atmel AT91SAM7S256 (data sheet), which uses the ARM7TDMI core from ARM. This core is supported by gcc, so you can use GNU tools to program it in Assembly/C/C++.

You can build a firmware for the AT91SAM7S256 and load it via USB, after putting the controller in SAM-BA mode by a long press on the reset button.

There is also a smaller ATmega48 controller in the NXT, but it is not intended to be reprogrammed.

LEGO provides a Hardware Developer Kit among their support files. It contains schematics and descriptions of the sensors and motors, so that you know how the microcontroller is connected to the NXTs ports.

NXTGCC

MATLAB and Simulink

MATLAB

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 free and open source RWTH - Mindstorms NXT Toolbox.

Simulink

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.

Ada

A [http://libre.adacore.com/libre/tools/mindstorms/ port of GNAT] is available for the NXT. It relies on a dedicated run-time kernel based on the [[Ravenscar profile]], the same used on the [[Goce satellite]]: this permits to use high-level Ada features to develop concurrent and real-time systems on the MINDSTORMS NXT.

URBI

[[URBI]] is yet another language and is a parallel and event-driven language, with interfaces to C++/Java and Matlab. It also has a component architecture (UObject) for distribution. Urbi is compatible with many robots, including Nao (cf Robocup), Bioloid or Aibo.[http://www.gostai.com/nxt URBI NXT Page]

FLL NXT Navigation

[http://fllnxtnavigation.codeplex.com/ FLL Nxt Navigation] An open source program to help navigation on the FLL competition table. It uses NXT-G and .txt files to write programs.

I started coding using NXT software and later EV3 and lately I have switched to java using leJOS. EV3 software ( and NXT ) is great for quickly hacking your ideas but when things get ugly the graphical language doesn't help at all.

You can program the lego NXT in any language you wish! What is really the question is if you want the mindstorms brick to perform the decision making, or if you want some other device to do that for you. This works in two ways:

You download a program onto the NXT that it can run in its native format. Based on sensor input and the program which you've written, the NXT can operate by itself. This is how the mindstorms modules are primarely designed to operate out of the box - where you use their "visual" programming interface to create a program and then download it to the NXT.

As listed above, there are various other types of programming languages and interfaces you can use to write programs for the NXT. Eventually they require you to download them to the NXT - which will again be performing all the necessary calculations to run the program on-bard of the brick. These tend to offer you more control over your program however ultimately rely on the computing power available on the NXT.

The second scenario is to use the NXT as sort of a "slave" to another device with more computing power. This device - such as a PC or MAC, can be used to send down real-time direct commands to the NXT device to operate on. Based on feedback transfered back to the host computer, you can send down other commands. Using this method, you can use any programming language you are comfortable with - and simply use the NXT as a "dumb" device. This offers you the most verstility, and you can use virtually any programming language you are comfortable with.

What's nice about the NXT is that it allows you to use such a wide array of different techniques to control it - which makes it a great platform. One great walk-through of sending these direct commands over bluetooth to the NXT can be found here:
http://www.robotappstore.com/Knowledge-Base/Programming-LEGO-NXT-Mindstorms/92.html
I would recomend checking it out, since its a great introduction to getting started. If your computer supports bluetooth, you can easily download realterm (free) and get your robotic project working quickly!

I will admit that sending these direct commands to the NXT is a bit more advanced than say the type of visual programming used with the supplied Lego software, but it will allow you to use any language you wish, and with slight modification you can use your code for un-related projects too!