Suggestions for the most appropriate (best) language for programming an embedded system? [closed]

StackOverflow https://stackoverflow.com/questions/649197

  •  19-08-2019
  •  | 
  •  

Question

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 language for programming an embedded system? 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.

Was it helpful?

Solution

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.

OTHER TIPS

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.

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

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.

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.

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/

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).

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.

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.

C the best

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top