Hey guys,

Most embedded devices suc as the Amtel boards seen to require C / C++ programming, why don't they support Java? Is it question of performance? Or am I overlooking something?

Probably because java is a memory hog, it runs slower because its an interpreted language, and C/C++ languages let you get much closer to the hardware than java does.

In addition to what Ancient Dragon said, YES java can be used to program some low level devices. As far I know it is quite used in the mobile programming and in Bluetooth and many others. Well what you need to understand here is the fact that they are all running on a specific platform. You write a program using java for a mobile device and the program get compile to generate a bytecode which is then interpreted by the Java Virtual Machine (JVM). You can clearly see that the target device should be installed with the JVM, which it does on most devices.

Now, let’s think it practically with the ATMEL AVR board. These boards come with the AVR microcontroller which has a very small amount of memory. We are speaking in KB’s. We use several techniques to improve the efficiency of the code to make use of the memory effectively. When it comes to ATMEL we are speaking of three types of memory flash, SRAM, eeprom.

The ATML AVR board doesn’t come with any RTX or RTOS with it. The only software which gets shipped is the boot loader. It doesn’t come with JVM. The JVM its self needs a specific platform to run which the AVR doesn’t support (I might be wrong).

And more over java doesn’t support pointers, and for programming an embedded system you need pointer. Since I don’t program java I am not pretty sure about it. I think its some like C++ isn’t?? But you can still program an embedded system using C++.

Hope you get an ides on why java isn’t the right language to program any level devices. Here is a small brief:

1. Java compiles the code to bytecode, not binary
2. It requires a JVM
3. It’s slow
4. Lack of pointers.
5. Needs huge amount of memory.

And remember ATMEL AVR are RISC based processor. Does JVM support RISC architecture??? From my research it seems that ARM can execute some Java bytecode!!! But I havn't persoanlly tried.

As you could see there are of lots things which you need to be considered. :)

ssharish

Comments
Very nice explaination :)

...

1. Java compiles the code to bytecode, not binary
2. It requires a JVM
3. It’s slow
4. Lack of pointers.
5. Needs huge amount of memory.

And remember ATMEL AVR are RISC based processor. Does JVM support RISC architecture??? From my research it seems that ARM can execute some Java bytecode!!! But I havn't persoanlly tried.
...

ssharish

A Question about bytecode vs binary - does this mean that instead of converting the data directly into binary that instead the data is separated by chunks of bytes?

Excuse my ignorance if this is wrong.

A bytecode is set of instruction which is generated the by a java compiler. This bytecode can then be ported to any machine regards of the on what platform and processor architecture of the target machine is! The bytecode will then be interpreted by the Java Virtual machine (JVM) which then internally creates a binary which can then be executed by the local machine or whatever the processor architecture which the local machine has been implemented. The JVM holds the complete system spec. So that when it interprets the byte code it knows on what platform its working and what sort of binary it has to produce.

But when we speak about binary, it is something which the compiler generates it for us. When you compile a C code by a C compiler, example GCC, it created .exe file or a binary file which can then be executed. The GCC doesn’t create byte code instead it creates a binary. But what you should remember is that, when you compile your code for your embedded system, you should compile your code to get the binary which can then be executed by the processor which is there on the embedded board but not our host machine.

Because those both are completely different in terms of processor architecture. But thanks for the GCC. It can create binary for a wide range of processor. And hence it’s called native compile. The compile which can generate binary for specific processor architecture is called Cross compile or a native compiler.

So you could see the potential of what the bytecode and the binary is. While programming embedded programming you should thinking about more than a programmer since you will have to consider more than one thing. But the thing which I like about it is that, the program you write will be executed on just one board. So, no need to consider any multiple architectures or the portability issues. You are free to use anything. But it’s a good practice to follow standards still :)
Hope that answers your question.

ssharish

Comments
Thanks for the clarification!
This article has been dead for over six months. Start a new discussion instead.