tags:

views:

1050

answers:

11

I'm looking at doing embedded coding for a device that's approximately 20MHz, has 6mb ram, with an ARM32 processor. Can anyone suggest the best / most appropriate embedded language? I'm considering:

  • Lua
  • TinyPy
  • C
  • Java ME
  • C#
  • someone has suggested JavaScript

Any suggestions? Thanks

Edit - looks like C and Lua are the winners. Cheers all!

Edit - Real Time is not an issue, its more the limited ram/cpu dictating things.

+4  A: 

I'd be tempted to go with straight C, but then I've been writing C for nearly 30 years. Lua and TinyPy seem too new, experimental, to me; embedded devices need to be very robust.

Java ME has good points. I don't know about C# in an embedded world.

Charlie Martin
Yet a scripting language might result in more robust code for the same reasons it does in server-land: pointer arithmetic and memory management removed from the programmer's list of responsibilities.
slim
No, it just means the responsibility has been passed along to the scripting language coders, while adding the problem of dynamic typing mistakes. IF the Lua or TinyPy implementation were bug-free, you'd be right, on balance, but they're awfully new for me to trust.
Charlie Martin
Lua has been around since '93 (released in '94), and the engine is open source. I'd argue that's as trustworthy as many compilers for C and C++.
patros
+4  A: 

C is probably your best bet for such limited cpu resources.

patros
Don't forget that people used to write perfectly viable applications in BASIC on 2MHz 8 bit 6502 processors with 16K of RAM. If you need to squeeze out every last bit of performance, use C - but the hardware described does not rule out interpreters.
slim
I agree, just went with the safest answer since the OP didn't give any indication of what they actually wanted to do with the device.
patros
For an embedded processor, having 6 Mb is far from limited. For example, the smallest PIC10F has 16 bytes of RAM, and 384 bytes of flash. For that, you program in assembler. :-)
Steve Melnikoff
A: 

Edit: hmm. I just noticed that the 'embedded' you seem to be describing is not about adding an automation language to an application, but squeezing an application into an embedded platform. As others suggest, unless you really need it, skip embeddable languages and program your application in C. There is nearly no runtime overhead for that, except for what you actually use.

In no particular order, Lua, JavaScript and TCL are all quite well suited to embedding. Lua has been the easiest for me to embed. Javascript might be the fastest. All three have good handling for untrusted code, but TCL's is most robust, for example, untrusted code can run untrusted code (if it's trusted to do that much).

TokenMacGuy
Javascript - that's an interesting idea! What would that be like?
Chris
well, i haven't tried anything newer than spidermonkey from a few years ago, but it is quite simple, so long as you don't need to override the global object. That confused me considerably.
TokenMacGuy
+7  A: 

If you're bringing the device up from scratch or interfacing directly with non-standard peripherals, C is really the only way to go.

If you've already got an embedded OS or can port one without difficulty, you might have more flexibility in adding one of the more script-y languages. C# is out of the question unless you're on WinCE, and then you'll be restricted to .NET Micro.

Beyond that, "best" has little meaning without describing what your device is going to be used for. Some languages have better support for certain tasks than others.

HUAGHAGUAH
Disagree. http://en.wikipedia.org/wiki/.NET_Micro_Framework
Tim Matthews
ARM isn't exactly exotic... it is widely used in embedded systems, especially as the CPU core of a system on a chip.
RBerteig
+2  A: 

I've used Lua on an ARM OMAP processor. Lua's tight integration with C allows going to the metal whenever you need, and its small size makes it suitable for a wide range of platforms. I developed the UI for my firmware in Lua on my mac and then brought it over to the embedded platform with no changes.

While the OMAP processor was beefy enough to run other languages like Java or Python, I didn't know what hardware I was targeting when I started the code. Lua was a safe bet.

Paul
+3  A: 

It's important to specify what you expect this device to do. Is it some sort of control application? Does it have to implement algorithms? What about floating-point support? GUIs? Is performance critical? Are you planning on using an OS?

Answering these questions is a crucial prerequisite to picking a programming language.

That said, embedded systems have to be reliable, so I'd go for some tested solution. C is probably the most solid and best-supported option for ARM chips, but YMMV depending on your specific needs.

Eli Bendersky
A: 

Unless you have an RTOS available that supports a variety of alternate languages, C or C++ (depending on your compiler chain) is the way to go.

Nate
A: 

Your decision is most likely to be determined by the tools avaiable for this processor.

C is by far the most supported language for embedded processors, so you can't go far wrong with that, and it will be good experience if you have to write software for other chips in the future.

C++ is becoming more popular for embedded systems. Beyond that, it depends on your priorities (time to market, resource usage, speed), and the quality of the tools you use.

Steve Melnikoff
A: 

C the best

Enjoy coding
+1  A: 

C is certainly the most used language in embedded systems. It also seems to be the most talked about language in general http://www.langpop.com/

robert.berger
A: 

i'm doing final year B.Tech information technolody. i would like to do embedded course. which having more value and which will help my job opportunities.

siva