Programming Languages

I'm just learning about the Arduino framework and it seems like the perfect platform to start teaching my 10 yr old son about robotics. (He's been begging me to start)

I don't have much experience myself, so it'll be a learning process for both of us. My question is with regards to the programming language for Arduino projects.

Can it be programmed in any Language, or does it have to be in the C/C++ that I am reading so much about as I learn about Arduino? I am well versed in C# and the other .NET languages as well as Java. But not as much in C/C++.

Thanks for your advice.

C/C++ is the only official language supported by the IDE.

But most programs are so simple, that your knowledge of C# should be sufficient.

Read a few examples and you should get the hang of it.

Apart from agreeing with @KeithRB, once you install the IDE there are a lot of examples under the file->examples to look at.

C# is as I understand it a Microsoft derivative of C++, as such the syntax should seem reasonably familiar.

C# is as I understand it a Microsoft derivative of C++, as such the syntax should seem reasonably familiar.

There are a lot of similarities between C++ and C#, at least as far as the basic syntax goes. But they are completely different languages, and the way of thinking involved with the two languages are very different.

C# is a very strongly typed managed language and will do a lot of things for you: memory management, garbage collection, and many other helpful abstractions (like no pointers and managing object lifespan for you.) There is a rich system library of classes and functions that make many complex tasks easier.

In comparison, C++ is a much lower level language with much looser type checking. You need to be aware of pointers, and much more aware of array management and memory management. Complex operations that are handled by system classes with a minimum of code can be more difficult in C++.

I’m not knocking C++, in fact I prefer it to C# in many ways. But someone who is familiar with C# (and the huge amount of memory that is typically available) is likely to feel very constrained by C++.

The Arduino is a great learning/teaching tool, and C++ should be easy for a C# programmer to learn, but it is a learning experience and there are significant differences.

If you really like C#, and don’t want to learn something new, have you considered the NetDuino family?

C# is as I understand it a Microsoft derivative of C++,

I tend to think of C# as being Microsoft's attempts to circumvent Java.

I tend to think of C# as being Microsoft's attempts to circumvent Java.

Well, yes, Microsoft have a habit of doing things like that, but they are slightly more friendly than Apple and a tad less patronising.

That said, as long as the OP bears in mind he is playing on a much smaller machine (and I expect he does) then there should not be too much to over come, certainly in the early stages.

Hmmm, it just so happens that I posted a related post in my new blog a week ago... :wink:

ChilliTronix is definitely right - the extent of C/C++ one actually needs for the average Arduino sketch is relatively small, and while there are differences is the general approach due to the very limited resources of the platform, the syntax will be easy for anyone with a background in a C-like language.

You may possibly find the Standard Template Library useful (STL).

See here for my post about a port of it for the Arduino.

It may well be an overkill for simple projects, but with it you can have lists, vectors, arrays and maps of any (reasonable) type of data, and let the library handle the memory management.

Just remember, in whatever method you use, on an Arduino Uno you only have 2 kB of RAM and 32 kB of program memory, so keep your project scale in mind when designing stuff.

Thank you all for your thoughtful posts. I learned C++ in college (was my first programming class) and that was the extent of it, but from what you all are saying I think I should be ok.

2 KB of RAM and 32 KB of program memory is a tiny amount, I'll have to keep that in mind, but probably won't be an issue for beginner projects.

Thank you very much.

The biggest difference is probably String support. Doing "trivial" String operations on Arduino can quickly use up a lot of memory, and the library has bugs (or at any rate has a reputation for bugs.) You tend to want to use C-style character arrays instead, and ... they're sorta like programming in the 60s.

they're sorta like programming in the 60s.

i.e. yesterday