Monday, September 11, 2006

Embedded language

What's your embedded language? Which suits best for embedded use. Let's spend a few minutes thinking about it.

What are the options we have? Shortly there are four good candidates. First we have old and traditional C. There are lots of C applications available, it's well known, well supported, effective, Linux kernel is written with it, most system libraries are written with it, everything is good except one thing: it's not a modern laguage. It's missing object oriented features, it has memory leak problems among other problems. However they are all known but badly handled.

Let's make a step better language C++. It has object oriented features, but it's not a object oriented programming language. It's compatible with C, which has lots of benefits but inherits all misadvantages of C. It still leaks memory, no carbage collector, no proper class library, except STL which is a good try and for example Symbian does not have STL at all. And one little thing in Linux: every release of C++ libraries brakes binary compatibly. It's a really problem. Binary ABI for GNU libraries is very unstable. They may change it from a version to another. Have you ever tried to transfer an C++ application binary from machine to another and run it? Also compiling C++ applications takes a lot of more time than similair C application, more complex object oriented applications take even more time. You might say that nowadays computers are fast. They are, but wait until you compile your first big and complicated C++ application. It's not fast at all.

How about the newcomers, let's take Java first. Sun's "build once, run everywhere" ideology is nice! It really works. Java is really object oriented, carbage collector works nicely. Some problems however. Lets ingnore most of them, but take some in the spotlight. First Java versions. There three different versions: micro edition (J2ME) for embedded and resource limited devices, standard edition (J2SE) and enterprise edition (J2EE) for mainframe. Have you ever tried to port for example an application from J2SE to J2ME? It's impossible, or at least very difficult. Mobile phones has J2SE, however every manufacturer has their extensions to J2ME, it really breaks the "build once, run everywhere" ideology. This is however going to change in future versions of J2ME, but still waiting for the day. Should embedded Linux devices use J2SE or J2ME? For example Nokia solution on 770: surprise, no Java support at all! Second big thing is that Java is closed source. You have to have license and solve some issues to get Java for your device. Fortunately Sun has promised to release Java (only parts of J2SE in first phase) as open source. But what's the license, will the whole Java system become eventually free (as speech) and what are the terms and conditions. That will be seen.

Python. A programming language named after Monty Python can't be bad. And it's not. It has quite nice syntax, works well, is object oriented, etc. There's also Python available for example for Nokia 770 (Maemo) and Series 60. It's really suitable for anything, applications runs everywhere without recompiling, just like in Java. The biggest disadvantage: Python is interpreted language. Interpretion is slow, running is slow. Unofortunately I don't have speed measurements, but it's definetly slow on embedded devices. It suits for small applications which does not require a lot of resources or fast calculations. For slight use only as we could say.

So what's the best? I thing system should rely on C, while applications can be C or C++. And light applications can be implemented quickly and easily with Python. Java has problems, you have to choose your way and follow it blindly. It could be the killer, but it's not. Let's see what the future offers for us.

No comments: