Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why aren't object oriented languages popular in the embedded world? [closed]

Tags:

oop

embedded

I'm a firmware developper and I usually develop firmware in C or Assembly. However, I came across a project completely implemented in C++ in our embedded library. Now I know object oriented languages can be used on a hardware level, but I would like to know why they aren't that popular when developing embedded systems.

like image 226
H_squared Avatar asked Dec 28 '25 16:12

H_squared


2 Answers

The real reason: because of conceptual complexity. C and assembly provide an a simple mental model to track what is going on in the system. Object oriented programs require a more complex model that makes it harder to reason about what is going on.

Embedded systems tend to be environments that call for very tight control about what is going on in the system versus the more open ended server and PC environment. This requires both simple and transparent programming constructs. Both C and assembly provide a high level of visibility on what is really going on in the system at the lowest hardware level.

Object oriented languages in general and C++ in particular, abstract away many of the details of what is going on in the system when code is executed, thus making it much harder to reason about the inner working of the system.

Here is an example to explain what I mean. Consider the following code snippet:

i++;

Seeing this in a C program gives us a mostly accurate idea about what this does and an order of magnitude about how many CPU cycles are used, how many registers are involved and so on.

Now what does the same line will do in a C++ program? well, it depends. Depends on what type i is and how has the ++ operator been overloaded. See what I mean?

None of these comes to say that C++ or object oriented is bad. It is not. It does require a much more complex mental model if one is interested about the minute details about what is really going in the system, as many embedded developers feel they need.

like image 55
gby Avatar answered Jan 01 '26 17:01

gby


From technical point of view, embedded systems have limited resources. Object oriented languages tend to create much bigger binaries than pure procedural ones, thus many would choose something that's as light as possible. For instance, I work for a smartcard company and my team is the one handling extremely low cost cards, with RAM ranging only from 1.5 - 1.75 KB and EEPROM from 96 - 136 KB. For this kind of embedded environment, most object oriented languages (especially the heavy ones such as Java) won't fit. We don't even use ANY standard C library, everything is written from scratch for size. C++ might fit, with proper coding technique and use of compiler options that doesn't generate rtti, minimize vmt, use only stack based objects, etc. but it's just my guess.

like image 29
LeleDumbo Avatar answered Jan 01 '26 19:01

LeleDumbo



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!