4
$\begingroup$

Low-level languages have for a long time dominated the field of embedded systems due to their rapidity and flexibility. As high level languages are becoming faster and faster, might the situation get reversed soon? Can high-level languages become frequent in embedded systems in a near (or not so near) future? What would it take for a high-level language to be suitable for embedded systems?

$\endgroup$
  • $\begingroup$ I'm not sure how reading the glass ball makes for a good SE question. Community votes, please: subjective? $\endgroup$ – Raphael Oct 19 '16 at 16:12
  • $\begingroup$ To the point of your question, I guess there will always be use cases for low-level languages, those that ride the border of "impossible" and "we can just so do it". Once you have more resources (and tools), you can use higher-level languages. I expect that there is a dependable flow of "impossible" -> "do it with bit-tinkering" -> "many platforms, many languages" -> "Python runs on there" -> "there's an app for that". $\endgroup$ – Raphael Oct 19 '16 at 16:15
  • $\begingroup$ @Raphael That's what I thought first. But who knows SE might be an exception to the rule (like operating systems). I wanted to have a more experienced and more refined opinions on the matter hence my question. $\endgroup$ – Nassim HADDAM Oct 19 '16 at 16:49
  • $\begingroup$ I can at least tell you anecdotally that the languages for PLCs have been gaining more and more high-level functionality over the years. Programming started as a rough analogy of relay logic systems (so engineers used to designing relay logic could 'easily' program the controller) and have since taken on some aspects of object-oriented programming (in the form of instantiable 'function blocks'.) Also, previously you had to explicitly specify the memory location for all your 'variables' and now it's usually automatically assigned. $\endgroup$ – Dan Bryant Oct 19 '16 at 18:17
  • 2
    $\begingroup$ I took the liberty of editing your question, which was not answerable since you were asking us to predict the future, to a question that, while still opinion-based, calls for answers that back these opinions with facts and experience and calls on computer science expertise. $\endgroup$ – Gilles 'SO- stop being evil' Oct 20 '16 at 0:37
4
$\begingroup$

What is a high level language? What is an embedded system? Once upon a time C was a high level language and a Raspberry Pi would have changed the outcome of major wars, now almost every microcontroller can be programmed with C and we use Pis that run a full-blown desktop OS to turn servo motors. Let's say a high level language is a language that has strong abstraction mechanisms and an embedded system is a system with very limited memory and a processor with few features.

That alone is not enough to say whether this language is suitable for embedded programming or not. The important part is how the programs in the language can be compiled. Many languages (have to) add something called a runtime to the programs. For Haskell for example the runtime added by GHC is about 50k LOC and includes a garbage collector, a scheduler and a bunch of other stuff. That is quite a lot of code for a small chip to handle and might require processor features that aren't present.

Rust is another language that I'd call high-level, but it is possible (in theory at least) to run Rust on many embedded systems. This is because Rust has the possibility to use a much smaller runtime that can be handled by simpler processors and doesn't add as much overhead.

So in summary, the important part is not the features of the language, but how much of those features need support at runtime as opposed to a clever compiler. Garbage collection is typically too difficult for embedded systems, but a surprising amount of abstraction power can be provided without any extra costs at runtime.

Note that in practice you're still limited to C or Assembler in many cases, because you need a compiler that supports your target architecture. Unfortunately it is often the case that the architecture is proprietary and you're limited to using the compiler provided by the manufacturer. That is typically a compiler that supports some flavor of C.

$\endgroup$
  • $\begingroup$ An important characteristic of C is that number of reserved keywords is small, something like 32 for a simple K&R type of compiler, and functionality such as I/O is through a library rather than built into the language itself. And the technology is well known. A C runtime can be pretty simple and primitive and C cross compilers are pretty common so you can compile your C code on a PC to generate an image and then download the image into the target device. $\endgroup$ – Richard Chambers Dec 15 '17 at 2:07
0
$\begingroup$

There is metaprogramming exists many years ago, so you can do hardware/software codesign in any programming language including Python, Prolog, Lisp or anything you want to use.

Take code generation as a base principle, wrap C code writing to files, or wrap LLVM which can cross-compile directly to your system object code. Implement some class tree represents both source code elements (modules, functions, control structures), and your target model components (finite automata, DSP processing elements,..).

You can construct the target software you want to build by interconnecting these like objects and transform model object to source code objects by your metaprograms. And finally, call code generation method in a recursion starting from the top-level object, which will generate files with C source code, or directly call LLVM.

Of cause, it is not an easy or well-described method, but it works at least at the level of parametric code snippets composition. As an example, look on CodeMX init code generator suite provided by STMicro. It is a closed-source vendor-provided system, but you can brew your own analog maybe not GUI but script-driven.

Also look on knowledge representation and reasoning, it will give you an idea of how it can be implemented.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.