Thursday, June 09, 2005

Embedded Systems part 1

Why using C? Is there anyone still using C? Surprisingly or not, most embeded programming done these days is written in C rather than C++ or Java. Well, I program embedded systems and I use C!!! heheheheh ;-)

Java has a trouble: you need a device that supports J2ME machines.
Not a big deal, as it is not impossible to create these machines as you may have seen in cell phones or PDAs.

Also, schools are still teaching C as an introduction to programming. If you want to write numerical methods and don´t want to bother using a pre-historical language like Fortran use C instead.

Anyways, the ANSI C standard is mandatory for C. Basically, you are required to use prototypes to every function, your main function explicitly returns a int, your functions have parameters inside it´s call ( for ex, f( int * a)).

Why not C++ ? It can be very complex if you want to make it complex. Try to read code with templates,operator overloading, it´s a pain. Not that these features are useless, on contrary, they are mandatory for good OOP design, but we end up with code that´s not easily read.

A note: Java 1.5 supports generics which are the Sun way for templates, but you these are not hard to read as C++ ones. If you are on embeded, avoid generics. Most of time you will deal with bytes, which are basically unsigned char types, and mostly certainly people will use your code.

No comments: