Author Topic: Comparing "Modern" embedded chip programming languages?  (Read 42403 times)

0 Members and 4 Guests are viewing this topic.

Offline westfwTopic starter

  • Super Contributor
  • ***
  • Posts: 4676
  • Country: us
Comparing "Modern" embedded chip programming languages?
« on: July 08, 2016, 12:13:11 am »
I think I mostly understand the differences between "modern" programming languages like Python, and old languages like C.
But I'm finding myself clueless when it comes to differentiating the "modern" languages.  Would anyone like to compare:

  • lua
  • micro-python
  • Java Embedded
  • C#
  • Other?
These are all things that I've seen aimed at relatively small embedded systems (Ie ARM, ESP2866, etc.)

 

Offline Mechatrommer

  • Super Contributor
  • ***
  • Posts: 11727
  • Country: my
  • reassessing directives...
Re: Comparing "Modern" embedded chip programming languages?
« Reply #1 on: July 08, 2016, 12:34:31 am »
looking at the reason of why a language is created may give some light. but in general modern language = managed language.

Offline Signal32

  • Frequent Contributor
  • **
  • Posts: 251
  • Country: us
Re: Comparing "Modern" embedded chip programming languages?
« Reply #2 on: July 08, 2016, 12:45:25 am »
What differences are you looking for ?

The biggest difference is that lua & micro-python(which is python minus some libs) are scripting languages, whereas C# and java are compiled to binary bytecode that then executes on a VM. And recently MicroSoft has made it possible to compile c# programs to fully native, so you get a full native image ( like C generates ).

Here is how compiling source code generally happens:
1.Source code(text form, this can have syntax errors, etc)  --->
2.Intermediate binary format(some optimizations are done,there are no syntax errors here, needs to be interpreted in order to run) --->
3.Native code(can be run directly by the processor, fully optimized).


Yes, almost always C also goes through an intermediate step in order to simplify code generation on multiple platforms, but of course it's not going to be the same intermediate format as C# and Java.
So basically lua and micro-python programs are at step 1 above, c# and java at step 2 and C at step 3.
Between them are trade-offs of portability / speed / memory usage / ease of development and other things such as automatic garbage collection, better security, lower level access etc
« Last Edit: July 08, 2016, 12:48:57 am by Signal32 »
 

Offline ataradov

  • Super Contributor
  • ***
  • Posts: 12516
  • Country: us
    • Personal site
Re: Comparing "Modern" embedded chip programming languages?
« Reply #3 on: July 08, 2016, 01:23:00 am »
Would anyone like to compare:
All are pretty pointless toys, unless you actually need user scripting in your product. Using them as a primary development tool is like using Arduino for real products. It may work in some cases, but not in general.

You'll basically need more flash and RAM, so your cost will go up. You may save on development time, but it is highly unlikely since you will still need to bridge all the capabilities of your MCU into the virtual machine.

EDIT: And finding people fluent in "embedded" LUA or Python is not and easy task. And you can't really explain to a typical Python developer why allocating a 1 MB temporary array is not going to work here :)

And if you actually need scripting, LUA is more suited for that application, if your platform has hardware floating point (double precision) support. Otherwise LUA will be super slow, since there are no integers, only floats.
« Last Edit: July 08, 2016, 01:28:04 am by ataradov »
Alex
 

Offline Rasz

  • Super Contributor
  • ***
  • Posts: 2625
  • Country: 00
    • My random blog.
Re: Comparing "Modern" embedded chip programming languages?
« Reply #4 on: July 08, 2016, 01:35:00 am »
those were adopted for embedded for people with no understanding of underlying architecture of a platform they are working on (and often _any_ hardware platform whatsoever), basically web developers
Who logs in to gdm? Not I, said the duck.
My fireplace is on fire, but in all the wrong places.
 
The following users thanked this post: Mechatrommer, Kilrah

Offline Sal Ammoniac

  • Super Contributor
  • ***
  • Posts: 1816
  • Country: us
Re: Comparing "Modern" embedded chip programming languages?
« Reply #5 on: July 08, 2016, 02:25:10 am »
Is there such a thing as embedded Javascript yet? If not, then someone will invent it soon.
"That's not even wrong" -- Wolfgang Pauli
 

Offline asgard20032

  • Regular Contributor
  • *
  • Posts: 184
Re: Comparing "Modern" embedded chip programming languages?
« Reply #6 on: July 08, 2016, 03:11:18 am »
I think there is a need for a new more modern language for microcontroller and for low level programming like kernel.

This "new language" would of course be type safe, have smart pointer, not interpreted..... (add lot of other nice feature here).

And I already see at least one candidate for such language : Rust. If only it could go more mainstream and be adopted. It is basically a language build for the same purpose that C currently fulfill.

Other language mentionned, like python and lua and etc... could still be useful on a microcontroller, only if that microcontroller is one of those cortex 4 or cortex 7 (or insert other behemoth microcontroller here), and its running an RTOS, and that said language is only used in some thread that only manage logic, and not input/output. Of course, that said task (thread) should not use heap allocation, and should only allocate memory on its stack.
« Last Edit: July 08, 2016, 03:14:39 am by asgard20032 »
 

Offline ataradov

  • Super Contributor
  • ***
  • Posts: 12516
  • Country: us
    • Personal site
Re: Comparing "Modern" embedded chip programming languages?
« Reply #7 on: July 08, 2016, 03:13:04 am »
I think there is a need for a new more modern language for microcontroller and for low level programming like kernel.
Yes, there is.

have smart pointer
Disagree :)

And I already see at least one candidate for such language : Rust.
Rust has a ton of overhead in a standard library and some language features.
Alex
 

Offline asgard20032

  • Regular Contributor
  • *
  • Posts: 184
Re: Comparing "Modern" embedded chip programming languages?
« Reply #8 on: July 08, 2016, 03:16:58 am »
Well, i was not saying to use rust as it, but use it as a base/concept to get to what we need. My main point was that it is possible to get a modern low level language, and rust is one of the few that took that step. There is many thing in Rust that could be the foundation of other modern language.
 

Offline ataradov

  • Super Contributor
  • ***
  • Posts: 12516
  • Country: us
    • Personal site
Re: Comparing "Modern" embedded chip programming languages?
« Reply #9 on: July 08, 2016, 03:20:22 am »
Well, i was not saying to use rust as it, but use it as a base/concept to get to what we need.
I absolutely agree. There is a number of features that are used daily in the embedded development, but are not standard.

I'd really like to see language-level packed structures for interfacing external devices. Bit-fields with predictable/controllable behavior would be nice as well. Eliminating C headers nightmare would not hurt either :)

But creating a new language and pushing it into industry is really hard and I doubt it will actually happen. Banking industry still uses COBOL.
Alex
 

Offline zapta

  • Super Contributor
  • ***
  • Posts: 6620
  • Country: 00
Re: Comparing "Modern" embedded chip programming languages?
« Reply #10 on: July 08, 2016, 04:36:41 am »
I'd really like to see language-level packed structures for interfacing external devices. Bit-fields with predictable/controllable behavior would be nice as well.

IIRC this is available in ADA. See the other thread regarding ADA in embedded environments.

 
 

Offline ataradov

  • Super Contributor
  • ***
  • Posts: 12516
  • Country: us
    • Personal site
Re: Comparing "Modern" embedded chip programming languages?
« Reply #11 on: July 08, 2016, 04:41:04 am »
See the other thread regarding ADA in embedded environments.
Nope, I'm not going to a marginal language for 1 or 2 features it may have implemented better than C. Especially given that all compiler let you do this with compiler extensions.

The problem here is that none of the MCU peripheral will be described in ADA. It should be possible to generate those descriptions based on SVD files, but no such generator exist at the moment.
Alex
 

Offline sleemanj

  • Super Contributor
  • ***
  • Posts: 3178
  • Country: nz
  • Professional tightwad.
    • The electronics hobby components I sell.
Re: Comparing "Modern" embedded chip programming languages?
« Reply #12 on: July 08, 2016, 04:55:48 am »
The biggest difference is that lua & micro-python(which is python minus some libs) are scripting languages, whereas C# and java are compiled to binary bytecode that then executes on a VM

Err, I dunno about micro python, but python itself is compiled to bytecode - admittedly on the fly, but it is, that's what the .pyc/o files are, compiled bytecode versions of the .py source.

I have no real love for python, the tab/space centric syntax sucks ass, but anyway.

( I think Lua is also compiled to bytecode and executed by a VM, but don't quote me on that, I'm only very loosly aware of lua's existence and that's about the extent of it, it kinda seemed like a language implemented because somebody wanted to make their own language to me, solving a solved problem )
« Last Edit: July 08, 2016, 05:00:21 am by sleemanj »
~~~
EEVBlog Members - get yourself 10% discount off all my electronic components for sale just use the Buy Direct links and use Coupon Code "eevblog" during checkout.  Shipping from New Zealand, international orders welcome :-)
 

Offline rstofer

  • Super Contributor
  • ***
  • Posts: 10095
  • Country: us
Re: Comparing "Modern" embedded chip programming languages?
« Reply #13 on: July 08, 2016, 05:36:04 am »
Look at Ada if you want a type-safe language suitable for embedded programming.  http://libre.adacore.com/

Oberon is derived from Modula 2 which is derived from Pascal.  It is available for ARM.

Pascal is available for 8051 and variants.

I'll stick to C but I am looking at Ada as a language for my grandson should he want to work in an environment where it is used.

In my view, none of the listed languages are anywhere near suitable for embedded programming.
 

Offline Rasz

  • Super Contributor
  • ***
  • Posts: 2625
  • Country: 00
    • My random blog.
Re: Comparing "Modern" embedded chip programming languages?
« Reply #14 on: July 08, 2016, 07:24:38 am »
Is there such a thing as embedded Javascript yet? If not, then someone will invent it soon.

sure, there are masters of IoT building stuff with nodejs on rasPee
over one minute to boot your 'app' is just a start of a long feature list
Who logs in to gdm? Not I, said the duck.
My fireplace is on fire, but in all the wrong places.
 

Offline Mechatrommer

  • Super Contributor
  • ***
  • Posts: 11727
  • Country: my
  • reassessing directives...
Re: Comparing "Modern" embedded chip programming languages?
« Reply #15 on: July 08, 2016, 08:12:34 am »
Oberon is derived from Modula 2 which is derived from Pascal.  It is available for ARM.
which is pascal is suck. its syntax is a hybrid between <insert any modern language> and C with a pointless ";" havent seen oberon or modula but general rule is anything derived from imperfect will always be imperfect.

Offline donotdespisethesnake

  • Super Contributor
  • ***
  • Posts: 1093
  • Country: gb
  • Embedded stuff
Re: Comparing "Modern" embedded chip programming languages?
« Reply #16 on: July 08, 2016, 09:12:19 am »
Oberon is derived from Modula 2 which is derived from Pascal.  It is available for ARM.
which is pascal is suck. its syntax is a hybrid between <insert any modern language> and C with a pointless ";" havent seen oberon or modula but general rule is anything derived from imperfect will always be imperfect.

That would explain why C++ is a massive pile of shit then :)
Bob
"All you said is just a bunch of opinions."
 
The following users thanked this post: neil555

Offline Mechatrommer

  • Super Contributor
  • ***
  • Posts: 11727
  • Country: my
  • reassessing directives...
Re: Comparing "Modern" embedded chip programming languages?
« Reply #17 on: July 08, 2016, 09:30:00 am »
Oberon is derived from Modula 2 which is derived from Pascal.  It is available for ARM.
which is pascal is suck. its syntax is a hybrid between <insert any modern language> and C with a pointless ";" havent seen oberon or modula but general rule is anything derived from imperfect will always be imperfect.
That would explain why C++ is a massive pile of shit then :)
no because ";" in C has a specific purpose, pascal tried to implement it in sporadic way. pascal is not derived from C but a random mix of a recipe from various languages. and C++ is not derivative of C, but an extension to it, imho.

Offline ddm

  • Newbie
  • Posts: 1
  • Country: be
Re: Comparing "Modern" embedded chip programming languages?
« Reply #18 on: July 08, 2016, 09:52:31 am »
Is there such a thing as embedded Javascript yet? If not, then someone will invent it soon.

There are several embedded JavaScript implementations available:

I have had success running V7 on ESP8266 using mongoose-iot (aka. Smart.js) and Espruino on STM32. I find them nice for fast prototyping.
To my knowledge, none of them work on 8bit MCUs.
Espruino is being ported to nRF52 (Cortex M4F) in the context of the Puck.js kickstarter.
« Last Edit: July 20, 2016, 09:39:34 am by ddm »
 

Offline sleemanj

  • Super Contributor
  • ***
  • Posts: 3178
  • Country: nz
  • Professional tightwad.
    • The electronics hobby components I sell.
Re: Comparing "Modern" embedded chip programming languages?
« Reply #19 on: July 08, 2016, 10:58:52 am »
pascal is not derived from C but a random mix of a recipe from various languages


At best you can say that PASCAL derives from ALGOL, in so far as all the Wirth languages do. 

From memory, PASCAL requires a semicolon as a statement terminator except for the last statement in a block, where it's not necessary since the block end forms the termination.  But you can add one if you want.

It's been a long time since I've written anything in a Wirth language though.

NB: PASCAL and C were both initially developed around the same time, late 60s early 70s.

« Last Edit: July 08, 2016, 11:01:00 am by sleemanj »
~~~
EEVBlog Members - get yourself 10% discount off all my electronic components for sale just use the Buy Direct links and use Coupon Code "eevblog" during checkout.  Shipping from New Zealand, international orders welcome :-)
 

Online nctnico

  • Super Contributor
  • ***
  • Posts: 30440
  • Country: nl
    • NCT Developments
Re: Comparing "Modern" embedded chip programming languages?
« Reply #20 on: July 08, 2016, 11:19:58 am »
Would anyone like to compare:
All are pretty pointless toys, unless you actually need user scripting in your product. Using them as a primary development tool is like using Arduino for real products. It may work in some cases, but not in general.

You'll basically need more flash and RAM, so your cost will go up. You may save on development time, but it is highly unlikely since you will still need to bridge all the capabilities of your MCU into the virtual machine.

EDIT: And finding people fluent in "embedded" LUA or Python is not and easy task. And you can't really explain to a typical Python developer why allocating a 1 MB temporary array is not going to work here :)
Actually LUA is compiled into bytecode as well. Also LUA is widely used in games to let users extend functionality of elements of the games. All in all there are millions of kids out there who started programing in LUA at the age of 10 to 12. Don't underestimate that!

Trying to do some with eLua has been on my list for a couple of years now because it takes a lot of problems away. Also increased hardware costs are not a big issue unless you run really big volumes (>10k units). People still focus too much on the cost of hardware and too little on the development costs because the costs of the latter are way more difficult to understand or predict.
There are small lies, big lies and then there is what is on the screen of your oscilloscope.
 
The following users thanked this post: diyaudio

Offline timb

  • Super Contributor
  • ***
  • Posts: 2536
  • Country: us
  • Pretentiously Posting Polysyllabic Prose
    • timb.us
Re: Comparing &quot;Modern&quot; embedded chip programming languages?
« Reply #21 on: July 08, 2016, 12:02:18 pm »
Would anyone like to compare:
All are pretty pointless toys, unless you actually need user scripting in your product. Using them as a primary development tool is like using Arduino for real products. It may work in some cases, but not in general.

You'll basically need more flash and RAM, so your cost will go up. You may save on development time, but it is highly unlikely since you will still need to bridge all the capabilities of your MCU into the virtual machine.

EDIT: And finding people fluent in "embedded" LUA or Python is not and easy task. And you can't really explain to a typical Python developer why allocating a 1 MB temporary array is not going to work here :)
Actually LUA is compiled into bytecode as well. Also LUA is widely used in games to let users extend functionality of elements of the games. All in all there are millions of kids out there who started programing in LUA at the age of 10 to 12. Don't underestimate that!

Trying to do some with eLua has been on my list for a couple of years now because it takes a lot of problems away. Also increased hardware costs are not a big issue unless you run really big volumes (>10k units). People still focus too much on the cost of hardware and too little on the development costs because the costs of the latter are way more difficult to understand or predict.

Exactly. People think "scripting language" and they immediately think slow and bloated. But that's really not the case with Lua. In fact, in some cases it can be nearly as fast as C! Then, there's alternate VMs like LuaJIT, which is normally *at least* twice as fast as the stock Lua 5.1 VM; sometimes over 64x as fast!

eLua is actually really fast based on some tests I've done. Keep in mind, it's running bare metal, so aside from the small overhead of the VM, execution would be comparable to compiled C in a lot of cases. And for the cases it's not? Well, Lua allows you to use C as well (you write your code in C and compile it as a Lua module, basically) so I don't really see a downside so long as you've got enough Flash space to deal with the overhead of the VM (or an MCU that supports an EMIF and code execution from external flash/ram).
Any sufficiently advanced technology is indistinguishable from magic; e.g., Cheez Whiz, Hot Dogs and RF.
 

Offline Kalvin

  • Super Contributor
  • ***
  • Posts: 2178
  • Country: fi
  • Embedded SW/HW.
Re: Comparing "Modern" embedded chip programming languages?
« Reply #22 on: July 08, 2016, 12:07:59 pm »
You can make the Forth as modern as you want.
 
The following users thanked this post: newbrain

Offline rstofer

  • Super Contributor
  • ***
  • Posts: 10095
  • Country: us
Re: Comparing "Modern" embedded chip programming languages?
« Reply #23 on: July 08, 2016, 02:31:14 pm »
See the other thread regarding ADA in embedded environments.
Nope, I'm not going to a marginal language for 1 or 2 features it may have implemented better than C. Especially given that all compiler let you do this with compiler extensions.

The problem here is that none of the MCU peripheral will be described in ADA. It should be possible to generate those descriptions based on SVD files, but no such generator exist at the moment.

I have spent the last day or so dealing with Ada and how it is used to describe hardware.  It's pretty verbose but packed, named bits seems pretty useful.  In the GNAT package, there are several board support packages from which is should be possible to create a description for just about any hardware.  It's just records and fields...

I haven't gotten interrupts figured out as yet but I see where they initialize the vectors in assembly code.  But that's pretty typical for ARM code anyway.  The vectors and some small fragment of the interrupt handler is written in assembly and the bulk of the driver is written in C.

I don't know how far I will take this adventure with Ada because I am quite comfortable using C.  I would like to get "Hello World" working but, at the moment, it seems that I have some confusion in which library to use and where the USART registers are located.
 

Offline ataradov

  • Super Contributor
  • ***
  • Posts: 12516
  • Country: us
    • Personal site
Re: Comparing "Modern" embedded chip programming languages?
« Reply #24 on: July 08, 2016, 04:40:41 pm »
I have spent the last day or so dealing with Ada and how it is used to describe hardware.  It's pretty verbose but packed, named bits seems pretty useful.  In the GNAT package, there are several board support packages from which is should be possible to create a description for just about any hardware.  It's just records and fields...
So if I want to switch to a new MCU, I need to spend days describing bit fields? No, thanks.

But that's pretty typical for ARM code anyway.
No its is not. With ARM Cortex devices one of the design goals was to not have any assembly at all. All my interrupts are described in pure C and it is such a pleasure that I'm not going back to writing them in assembly no matter what other benefits are.

it seems that I have some confusion in which library to use and where the USART registers are located.
Exactly. And try to work with something more complicated, like USB.
Alex
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf

 

- - -
-->