Python vs JS vs PHP for embedded systems

UPDATE (07/18/17): The original article was written in 2011 and pretty much outdated, I've updated the numbers and conclusions.

I've got a question about which programming language is preferable for the website development for embedded systems (with limited resources). Here is my small investigation in a table form. Please note that the question was about only these 3 programming languages - there are better candidates for the embedded systems now (for example, Rust).

The Memory and Performance overhead numbers are based on the n-body benchmark and calculated as relatives to "C gcc #4" measurements.

Python 3Node.jsPHP
Type SystemStrong TypingWeak TypingWeak Typing
C BindingsExcellentAveragePoor
With PEP8 it can be almost perfectESLint enforces very good stylePEAR Coding Standards isn't consistent and not used so much

My totals: Python - a winner, Node.js - a very strong candidate (and wins if the app's performance is the most crucial factor), PHP - barely worth the efforts.

Additional notes (I didn't include them in the table due to its irrelevance in some cases):
  • Python is supported for many platforms, PHP - for slightly less, V8 - only on Linux/Windows/OSX.
  • Sometimes compiling V8 can be tricky depending on the target platform.
  • PHP is highly redundant and doesn't have thorough naming conventions for its functions (please take a look to its string functions).
  • People matter - for example, if you don't have PHP experts in your team, it can be risky to use it for the development process due to its pitfalls.


  1. And can use Python on Windows CE6/7 (embedded systems) too.

  2. Your comparison seems a little bit biased toward Python. Node.js is a really new project compared to Python and PHP.

    A fair comparison would be cross-compiling the three softwares and creating the same sample application for each one. Then you could measure development time and performance running on an embedded board.

  3. I agree, but frankly I'm really not so sure about running Google V8 on an embedded platform at all. I had some problems with its compilation even on standard PC, and I assume that it can be a nightmare to make it work on some limited platform.
    Anyway it can take a lot of time, and I can't do fair comparison now. For example, the embedded platform which available for me and can be used for that task is a certain kind of Linux and have only GCC compiler on it. To compile V8 I have to setup C++ toolchain, and even this task is pretty challenging.

  4. Don't underestimate that last option. Having people with experience in your chosen language is probably the most important factor.
    Surely Java, C and even Perl would also be options

  5. In the most cases I would agree with you, but embedded systems have its own peculiarities, which change the importance of the "experience" factor. In some cases it would be more profitable and efficient to train personnel to master in some other programming language.

    Let me provide the example. I'm developing for embedded systems in C now, and one of these have firmware size limitation. So we have to use stripped libraries because symbols take more than 10 Mb. Recently we've got a segfault, and it took several hours to find the reason (because core dump didn't contain even module name). I bet it could take just few minutes if website were developed using a high level programming language.

    Regarding "Java, C and even Perl" - yes, it would also be options, but my initial question was only about Python, PHP and JS. Of course, there are other good options including Lua, Erlang, Ruby etc, but it's a theme for another research.

  6. The target application, as much as the target platform need to drive these decisions.

    Before I get into it though, I wanted to point out that the vulnerability count you are using for nodeJS is based on all javascript engines, that the actual count for Chrome V8 and nodejs is in the twenties. Also, if you compare the performance of Chrome V8 with the other languages in your article, instead of Java which is the default on that page, that except for operations which require fast floating point operations, Chrome V8 (the engine in NodeJS) out-performs both Python and PHP in speed and memory utilization (which is very important in an embedded system).

    PHP is very mature, so has had a chance to be optimized to death. (I will keep my opinions about how that death has crept into other aspects of PHP to myself, or would if I could help it.) As a result of having been optimized heavily for speed over the years, it is VERY fast but also VERY large, an obvious handicap for embedded work. Otherwise a great tool for its original intended purpose. Dynamic generation of web pages on a full fledged server or cluster.

    I do not have a lot of experience with Python, so cannot comment fairly on it's merit relative to PHP or NodeJS, however I have some thoughts that are not TOO evangelical.

    While modules exist for python to enable its use as a webserver (tornado), they generally require getting additional software to compile on the embedded environment, further complicating the process. To Python's credit, its pretty fast and strong typing is valuable in many projects.

    My final thoughts (today). Both PHP and Python have their place, but what exactly are you trying to accomplish on that edge device? If you are building a computation engine in an embedded box, I have to ask WHY? If like most software on embedded systems your goal is to create a network service, you need to re-evaluate nodeJS. It has several HUGE advantages.

    NodeJS has simple to use libraries for acting as a web or socket server directly. Compared to tools like PHP and perhaps Python that would require a separate process for handling web/network requests, this is a huge advantage as it reduces kernel calls and complexity by at least one IPC (inter-process communication) channel.

    As with any project, choosing a tool must involve a realistic understanding of how it is to be used. Since my case is a network service, I have to go with the tool that makes best use of the VERY limited resources available in an embedded environment that also fits the type of application I am building, in this case NodeJS.

    Lastly, I have built NodeJS for an arm embedded using ELDK. There were several hurdles but nothing insurmountable.

  7. Chrome V8 is way much more advanced than Python and PHP. It is built on the concept of Asynchronous I/O. Moreover Google has already released a version of V8 that can be compiled on a bare metal platform (without OS) with only C++ libraries. Socket.IO using V8 and nodejs can be used develop real time web apps with always open socket connection between http client and server same as HTML5 websockets with advantage of older browser support. HTML5 websockets are supported by only some of latest browsers.

    1. Its not really more advanced at all, what makes you think you can't program asynchronously with python? V8 is way too heavy for embedded systems, and even on a powerful pc their electron system is a full os, sucking your resources dry.
      You say socket io, which is not at all the same as v8. It is a python framework made to use websockets, that is all. Embedded systems can do socket io, but most definitely not v8

  8. Now,there is the PH7 engine project which is an embedded PHP engine that allow C/C++ applications to compile and execute PHP programs in-process (very useful to build web administration interface for application).
    Here is the link:

  9. Late to the game here, but key point missed. Both PHP and Python are intended for server side web processing while JS runs on the client. Big difference. Also, since JS.node is written in C++, it's probably a good bit slower (C++ uses vtables and, depending on coding style, can grow the app large and slow, e.g., with several levels of inheritance.) I've been doing this a looooong time (40 yrs - yes four-zero) and web stuff does more, consumes much more memory, and is slower despite new tech and faster processors.

    1. Frankly, we had to fallback to C extensions for the most CPU-consuming tasks, neither of the server-side classic platforms are good fit for complicated embedded systems (however, I didn't test recent versions of Go and Rust).

  10. Disagree on Documentation (JS has tons of excellent documentation), Code readability (personally, the easiest to read language is Perl, but in your choices: JS is way easier to read, then Python) and Debugging (JS has several excellent debugging tools). <= on these 3, JS wins.

    1. you seem to forget that embedded systems are primarily backend/linux/system processes.. all of which javascript is the worst of the three at. It is "possible" to do a full stack in javascript using node js, but v8 is far too heavy for a typical embedded system. You need a much more minimal lightweight substitute to act as a backend, thus removing the js from the embedded system control. maybe others have found more efficient engines than node js im unaware of though

    2. Node.js in 2011 != Node.js in 2017, they improved documentation a lot and added new debugging capabilities. JS code readability depends on the developer, Python and PEP-8 enforce the specific style - for example, it won't be possible to have a lot of nested levels. At the same time, JS is infamous for its "callback hell" (however, the situation is much better now with async/awaits and promises). I've updated the article, and while I still see Node.js as the second option, it's a very strong candidate.

      As for embedding JS, it's not so bad - I've seen a lot of examples where it's used for IoT devices. However, I agree that it's not the best option - I guess it's very easy to find developers, but at the end they could be forced to write more and more code in C++ to avoid memory and performance issues. I think the most interesting candidate for embedding now is Rust programming language, but it requires additional research.


Post a Comment

Popular posts from this blog

Trac Ticket Workflow

Introduction to ReviewBoard