Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I do normal Java programming for embedded devices?

Tags:

java

embedded

I am looking at some Java code of a program running on JBed, a real time Java derivate. I'm not too familiar with JBed yet.

The device has only 16 MB of RAM and the code looks more like C++. It seldom passes objects as return value and makes use of global variables, so the code is hard to understand.

Is that a required optimization due to the little amount or RAM available or with the given amout of RAM, could it have been implemented in a "normal" fashion?

I understand that at a certain point, objects would probably cause too much overhead, so Java wouldn't be suitable any more. If we go further down, even C++ causes too much overhead and only C is an option (e.g. on a Texas Instruments MSP430 with 8 kB).

However, my assumption would be that, if I use Java, I use it correctly and not e.g. return half of the return value (e.g. two ints in a return statement and the other half by setting a member. Instead I would use some sort of Pair class as the return value.

I don't care whether it is much OO programming, it could also be FP style, but at least use atomic items as return types and not spread it all over in global variables.

So, can I do "normal" Java programming for embedded devices? If the question is too broad, then consider a JBed scenario and a 16 MB device. If it matters whether Java is used in OO-style or FP-style, please point out which style could be appropriate.

like image 402
Thomas Weller Avatar asked Oct 20 '22 21:10

Thomas Weller


1 Answers

Can I do "normal" Java programming for embedded devices?

yes, on some small devices (embedded or mobile) you can do almost normal Java programming. What exactly you can/can't do is determined by the list of JSRs (Java Specification Requests) which the particular Java Micro Edition Platform supports.

Before Android came to life in 2008 and brought in new APIs, it was quite normal that you could do Java programming on phones with very constrained CPU/memory. See e.g. "java.mob.org: Free mobile games. Download java games for mobile phones" for evidence.

Can I do...Java programming for embedded...JBed scenario and a 16 MB device?

Corresponding Google search words for this platform would probably be "Esmertec JBed Micro Edition profile".

According to my web search, the original Esmertec JBed was re-branded after a merger under the name Myriad Group. I did not succeed in quick-finding relevant developer infos and the official public page http://www.myriadgroup.com/products/device-solutions/mobile-software/jbed-advanced is very business-oriented.

But this is now the company to ask about the JSRs and developer resources (SDK, platform constraints, optimized libraries...)

I am looking at some Java code...seldom passes objects as return value and makes use of global variables...hard to understand...OO-style or FP-style?

You're probably looking at an old "bad" code written by some self-taught beginner. That's normal and probably has not much to do with the platform.

However, optimizing for speed, writing compact code (which generates compact minified bytecode) is certainly recommended. Together with writing a garbage-collector-friendly code. OO-style vs FP-style does not make much difference, although too many small objects may mean too much work for the garbage collector.

The tool to find the equilibrium is usually a profiler + the platform-specific best practices (e.g. Roy Ben Hayun's book "Java ME on Symbian OS: Inside the Smartphone Model" contains some tips for old Nokia mobile devices)

like image 69
xmojmr Avatar answered Oct 22 '22 09:10

xmojmr