28 comments

[ 3.3 ms ] story [ 64.7 ms ] thread
I hear they use embedded systems on airplanes, rockets and space vehicles. Javascript on embedded systems makes it so that your average front end developer can now make the software that controls auto pilot or Nuclear Power Plants!

Javascript is taking over!

> Javascript on embedded systems makes it so that your average front end developer can now make the software that controls auto pilot or Nuclear Power Plants!

You must be kidding, or you want to see everyone dies, right? JS does meet realtime constraints. Maybe someday when nodejs has event priorities, it would be much more interesting to use in that field.

I mean software development skill is only a small part of embedded system development used in autopilot and power plants. You need related engineering expertise (e.g Math) much more than writing C or JS.

Some embedded systems are maintained or coded with GUI's like RSLinx (it's all visual), so using JS instead might be a step up in some scenarios.
I think GUIs and touch screens are the future of all embedded systems. No more buttons. Imagine the cockpit of a boeing 747 with all levers buttons and knobs removed. Just a giant LCD touch screen GUI coded by a bootcamp graduate in React + redux.

The plane would be more useable by the pilot as touchscreens are more versatile than old fashioned buttons. Also you would be more safe because if a lever or button fails on a flight you are pretty much screwed but if a touchscreen fails you can just reboot the touchscreen and you're good.

Why use one of the trashiest languages, when we have so many good and effective languages outside of web browsers?
One man’s trash is another man’s treasure.
Come on, I also use JS for web, it doesn't mean I have to love it. Even it's creator admits low quality of his creation - it was made in a hurry. Try to be objective - if not monopoly in web browsers, JS would never exist or gain popularity.
modern js and ts are very usable plus you get access to a huge ecosystem.
Modern TS is usable, agree. But I'm talking about non-browsers world, where we have not just "usable" languages, but languages with much better characteristics, much better suited for the Embedded Systems. And they have even bigger ecosystems.
Who said _you_ have to love it? Some people do love JS. Those people will appreciate using it in embedded systems.
> Why use one of the trashiest languages

This isn't about C++.

ECMAScript has garbage collection.

Funny joke, but I have doubts about garbage collector in the world of Embedded Software.
Embedded spans a lot of different usecases and requirements. For lots of things a garbage collector is a non-issue. Not everything has hard realtime requirements.
Flawed one, it failed to collect itself.
The most significant form of garbage collection in the ECMAScript community is called npm.
What's the worse case latency of said garbage collection and how many embedded use cases does that preclude?
Well, the worst case of not having garbage collection is crashing due to memory leaks.

So tell me... is predictable latency worse than a hard crash?

Then why Java programms still have memory leaks?
Hard real time stuff generally doesn't leak because they statically allocate the at rest data and stack allocate the intermediate data.

Hard real time stuff also is, by definition, broken code if you can't reason about worse case latency.

"Saying that JavaScript is good because it works on all platforms is like saying anal sex is good because it works on all genders."

It's great for use on the web, just please keep it there!

Neat stuff. What's all the hate is about. Not every embedded system is running real-time sensitive industrial machinery or medical equipment.

Many things like general consumer electronics can run fine with Node. The runtime is incredibly well-tested at this point, JS is easily learned and scriptable for extensibility, the single-threaded nature is easy to work with and fast enough, and managed memory makes it easy to crash and recover from failures.

(comment deleted)
The choice of node.js means putting developer convenience in front of everything else.

The end user does not care about developer convenience, cares about a working product that is reliable.

Is it though? I'd prefer many other languages that are more convenient to code in that dealing with the quirks of JS, but I don't see why Node must be unreliable either. I think for simple devices this works just fine.
Most of the 'hate' has to do with the fact that the language isn't suited to platforms with memory constraints. Specifically there's semantics around closure capture that make it pretty easy to leak variables.

I've worked on platforms where we wrote the same logical code in JS and Lua, closures and all. The JS version leaked like a sieve while the Lua version was memory steady.

You can totally use gc'd, interpreted languages in the embedded space. I've used Lua on a product with 8mb of system ram in a 400kb block and it worked like a charm.

I think it is somewhat related to the hate around Electron. You can develop great Eletron apps like VSCode but people hate most of Eletectron apps taking much memory and CPU load. This is mainly because of the developers who don't care about rhe differences between the desktop environment and the broswer environment e.g. users can click the refresh button in the browser when it's slow while it's not the case in the desktop environment.

I think the hate is not about JS language itself but about some offensive people who believe JS enough to develop everything and who are not willing to learn appropriate knowledges/languages in the field.

A friend of mine did some sort of medical device for diabetes or transfusion (or something like that) using node.js a few years back.