Why are C, C++, and LISP so prevalent in embedded

2019-03-09 02:46发布

It seems that the software language skills most sought for embedded devices and robots are C, C++, and LISP. Why haven't more recent languages made inroads into these applications?

For example, Erlang would seem particularly well-suited to robotic applications, since it makes concurrent programming easier and allows hot swapping of code. Python would seem to be useful, if for no other reason than its support of multiple programming paradigms. I'm even surprised that Java hasn't made a foray into general robotic programming.

I'm sure one argument would be, "Some newer languages are interpreted, not compiled" - implying that compiled languages are quicker and use fewer computational resources. Is this still the case, in a time when we can put a Java Virtual Machine on a cell phone or a SunSpot? (and isn't LISP interpreted anyway?)

16条回答
可以哭但决不认输i
2楼-- · 2019-03-09 03:17

Because embedded devices mostly have limited resources where it is not welcome to have luxury such as automatic garbage collector. C/C++ allows you to work on quite low levels and program close to machine so that you get effective code as very much needed on those devices.

One more area where high-level languages like Java and .NET don't play well is real-time operation. You can't afford to get suddenly stalled because the garbage collector just kicked in at the worst possible moment.

查看更多
Rolldiameter
3楼-- · 2019-03-09 03:17

C and C++ are languages with very effective compilers (what leads to efficiency very important in Embedded systems with low resources).

Regarding Lisp, some misunderstanding has been spawned. Common Lisp (something what is mostly used right now - descendent of LISP 1.5) is compiled (not interpreted) and very efficient with a wide range of implementations and FFI (i.e your Common Lisp application may interoperate with C libraries) and some very nice high-level constructs. Live coding via REPL makes it even more convenient for checking out things on working robot.

Moreover there is Embeddable Common-Lisp, which allows embedding Common Lisp application in C binary – it is implementation compiled to shared library.

查看更多
我命由我不由天
4楼-- · 2019-03-09 03:18

In 20 years in embedded systems (including 8 years on a commercial robotics project), I have never seen Lisp used anywhere and would not regard it as 'prevalent'. I seen far more Ada for example. I would say that it is a niche, but if you happen to be working in that niche, it might look prevalent to you.

C and C++ are used because they are systems level capable languages that require minimal run-time support. For example they can run without an OS - and indeed commonly used to implement Operating Systems.

When a new processor architecture or device is developed, C and C++ are typically the first 'high-level' language tools available for the platform (and often remain the only ones available) - usually from day one, and increasingly often GNU GCC based. Availability of other languages is patchy or non-existant. C and C++ skills are the ones pretty much guaranteed to be reusable across projects and architectures.

查看更多
男人必须洒脱
5楼-- · 2019-03-09 03:18

Most commercial and industrial robots are programmed in C or C++. There maybe another language that the user interacts with. For example The industrial robot company I work for uses C running in a VxWork OS, but the applications programmers like me work with a proprietary language for commanding the robot. Both C and C++ give you a great deal of access and control over the hardware. You don't find too many commercial drivers for high power servo control motors. While complex these robots just follow basic routines.

LISP is mainly used in research robots like those that competed in the DARPA challenge. These types of robots need more "intelligence" then industrial or commercial robots.

查看更多
在下西门庆
6楼-- · 2019-03-09 03:21

You can do robotics with Java on the Mindstorm robots and MS has a push for doing robotics, but to a large extent C/C++ is used due to limited resources, and LISP is used for AI because for a long time this was an area of research and researchers were the main users of LISP, so they used the language they knew.

This is the same reason why FORTRAN is so prevalent in physics, for example, people use the language they know and when the project becomes commercial, unless you want to rewrite it from scratch, you keep the original code.

查看更多
Evening l夕情丶
7楼-- · 2019-03-09 03:23
  • As others have pointed out already, C and C++ are used because they are low-level. Another reason for C's popularity is that just about every architecture gets a C compiler targeted for it. This is good enough for a lot of people, so extra effort isn't often put into other languages. This is sort of like saying C is popular because C is popular, but hey, that's how things work.

  • LISP variants are popular in robotics in part because LISP variants have historically been popular in AI research. AI is a major focus in robotics, so a lot of stuff gets carried over from that field.

  • LISP has been around for a long time -- 1958 according to Wikipedia. It has more history than most other high-level languages, and this has two significant implications: 1) LISP is more firmly established (in the areas it is commonly used) than other high-level languages and 2) LISP interpreters have already been made to run on all manner of resource-limited hardware (see the next bullet point).

  • Interpreters are easier to implement for LISP variants than for many other high-level languages, and they can be made reasonably efficient. Scheme, for example, is a really easy language to parse, both conceptually and in CPU exertion.

To see why other languages do not have a strong foothold in embedded programming, just take the converse of the reasons that C, C++, and LISP do have a strong foothold.

  • They are not already popular in this field, so effort is not put into supporting them.

  • They were not used by previous generations, so newbies are not taught to use them.

  • They don't have much history (in this field). They represent the unknown. The unknown is scary (and hard).

  • They are taxing on limited hardware.

NOTE: When I talk about limited hardware, this is what I mean: a lot of embedded work still involves systems with between 256 bytes and 32 kiB of RAM. A smart phone that has 128 MiB of RAM is not a limited system.

查看更多
登录 后发表回答