Thursday, September 28, 2006

Serving your embedded

Usually people think embedded devices are clients for some services such as voice calls, video streaming, short messages and internet. But how about serving with your embedded device.

For example Nokia has a mobile web server for Symbian. It's modified Apache and is available as open source. They say that main target running a web server in your mobile phone is to make your personal mobile website. So what kind of are these personal mobile websites? Some information about you? It can't be anything that spends resources, it it just showing some simple pages. Isn't there any lighter way to show some information about you? I suppose nobody wants to surf to my mobile phone which might not be alwys available. I also thing that nobody wants to make this kind of page available as primary home pages since it's too easy and cheap to set up the pages to a real server.

But wait a minute, how about a whole, fully working web server serving some pages on the Internet. I found a Nokia 770 and Apache intresting combination. 770 has WLAN so it can be set up with wireless access point and get it visible to the Internet. Apache serving some personal web pages, portal or anything you like. How about setting up a server cluster? Multiple embedded devices serving on same address. Easy and cheap redunancy. Let's take a normal 770, it costs about 370 euros. Cheaper than a computer or a real web server.

How reasonable this is? Embedded devices are not any realiable, so anything can go wrong at any time. They does not automatically recover from error situations. You simply should not trust them. But at least serving web pages with your embedded device is really geeky and increases your masculine power. For power users only.

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.