
Low.js – Node.js for embedded devices - payne
http://www.lowjs.org
======
CharlesW
> _It currently uses under 2 MB of disk space and requires a minimum of around
> 1.5 MB of RAM_

Wow, that's an absolute unit of a JavaScript runtime compared to Moddable's
XS7, which can run real apps on _devices_ with as little as 32KB of RAM.

[http://blog.moddable.com/blog/moddable-tech-presentation-
to-...](http://blog.moddable.com/blog/moddable-tech-presentation-to-tc-39/)

~~~
village-idiot
That’s also absolutely massive for an embedded device. And that’s not even
including code, runtime use, etc.

~~~
CharlesW
Note that I said _devices_ with 32 KB of RAM. The XS7 "hello world" sample
(with debugger attached) needs a total of 6 KB of RAM on ESP8266s.

~~~
village-idiot
I was referincing the 2mb of ram requirement for low.js

~~~
CharlesW
Ah, indeed. :)

------
supahfly_remix
Is Javascript an appropriate language for embedded applications? Given all of
the security issues with IOT, I would think a 'stricter' language (e.g., Rust
or even Java) is better suited to this application.

~~~
janoc
The problem is not so much the security of Javascript itself but the
craptacular state of the Javascript/Node ecosystem where pulling in random
unchecked dependencies is the norm, for example. So lowering the barrier of
entry to already bad IoT to Javascript programmers that have no clue
whatsoever about embedded work is likely going to be a mess.

Also the fact that you need a pretty beefy MCU (=costly and not just the price
of the chip itself but also the stuff required to integrate it on the board -
e.g. all the RF stuff) just to be able to run Javascript on it - and cripple
it in the process, because then the majority of the processing capabilities of
the chip are going to be wasted on interpreting Javascript code instead of
doing something useful.

I wish these guys luck if they think they can sell this software to embedded
developers. There are some very good reasons why most embedded work is still
done in C (not even C++!) and languages like Javascript on microcontrollers
just aren't a thing - and not because they don't exist (e.g. Micropython,
Forth, even Lisp ...)

~~~
pjmlp
True, but there are also religious reasons against anything else that isn't
Assembly or C89, when reading about experience reports about trying to move
devs forward to C++ or even more up to date C versions.

~~~
village-idiot
It’s very hard to throw away decades of knowledge, libraries, and tooling.

~~~
monocasa
And a lot of the time you don't have a choice. For example the Xtensa core in
ESP32s doesn't have an upstream quality GCC or LLVM backend last time I
checked.

~~~
jononor
GCC toolchain for Xtensa has been available since day one. ESP8266 is
upstream, pretty sure ESP32 is also.

------
JohnDotAwesome
Super cool. I had never heard of Duktape before. Seems like there should be
some work making Electron compatible with Duktape to reduce the memory
overhead of some of our favorite Electron apps _cough_ VScode _cough_ Slack.

(This is probably a naive comment. I have no idea if this would work the way I
assume it would).

~~~
aikah
Well first Duktape is only a Javascript engine. it is not a browser engine so
there is no DOM, furthermore Duktape is not ES2015 compliant so you'd need to
transpile your code to ES5. It's also debatable whether Duktape is more
performant than v8 or not.

> to reduce the memory overhead of some of our favorite Electron apps cough
> VScode cough Slack.

are not going to take less memory with Duktape at all if the problem is sloppy
programming or DOM related.

------
Apaec
I like js, but I won't sacrifice all the performance aspects in the sole name
of productivity.

Node(nor any GC lang) is simply not designed for embedded dev. I'll gladly
switch to C or Rust that are designed for this kind of work.

~~~
zokier
It is debatable if any (mainstream) language is _designed_ for embedded use. C
was designed for "minicomputers" (aka small mainframes), not for embedded
devices.

~~~
e12e
"minicomputers" with 256kb ram and a cpu running at ~10mhz?

How would you differentiate them from today's embedded devices? ;)

~~~
zokier
> How would you differentiate them from today's embedded devices? ;)

Intent and usage type. Minicomputers were still "general-purpose" computers,
expected to run varying user code while embedded devices are more or less
fixed-function.

From a more technical perspective, one difference is the expectation of (hard)
real time control. While I have no doubt that some genius has put PDP-11 into
industrial process control loop or something, generally UNIX (and C by
extension) was not designed for real-time applications

~~~
monocasa
Throwing out there that PDP-11/20s were borderline running the entire
manufacturing sector for a decade or so there. Parts are still super expensive
because some ancient steel mill or something will buy them up as soon as
they're on ebay or what have you.

But yeah, those weren't running UNIX for the most part, but probably RT-11 if
their developers were sane.

------
mosselman
Strange that the page talks about it being for $3 esp32 devices, but the only
esp32 devices it can run on are the preflashed ones which are $12. What?

~~~
jerrysievert
I wasn't able to find them for $3, but I did find quite a few boards ready to
use on AliExpress for $4-5, as long as you're willing to take the 30 day hit
on delivery.

if you're ordering domestically, you'll find them more the price that you're
quoting, with much quicker shipping times.

~~~
opencl
The ESP32 version isn't open source though. It's one of those "open core"
commercial projects with the commercial part being selling the dev
boards/preflashed modules.

~~~
rzr
JerryScript+IoT.js could be an opensource stack to consider then

~~~
mosselman
Thanks. Ill check that out

------
pi-maker
It seems to me that my definition of an embedded device is different than the
developer of this framework. Just because it is headless, doesn't necessarily
mean it is embedded. A Linux server can be considered embedded, if that was
the case.

The ESP32 is an awesome chip, but it is a beast. Dual-core, with Bluetooth,
wifi, and everything else you could think of. I wouldn't call that your
typical embedded device.

But, as things get cheaper and more power efficient, my definition will be
antiquated and wrong, if it isn't already.

------
savrajsingh
What are the advantages of this over just writing C/C++? Is there a key
application/ what problem does it solve? I read the “what for” section and
wasn’t convinced. :)

~~~
PedroBatista
The same advantages of you writing this post in English and not having to
write it in Portuguese.

~~~
mlevental
that's pretty fatuous. English is not easier to read/write than Portuguese
when controlling for experience. js is easier to read/write even when
controlling for experience.

~~~
PedroBatista
Is it? have you read the average nodeJS application?

------
_fizz_buzz_
Hacker news folks seem to be pretty negative about this. I'd definitely like
to try it out. Maybe it's time to have some more options besides C on embedded
devices.

~~~
AlotOfReading
There already _are_ more options than C on embedded devices. You can run C++,
Lua, Python, Ada, Lisp, Java, Forth, Rust, and dozens of others. The reason C
dominates is that it's by far the most flexible, portable, and economical of
these, despite its safety issues.

~~~
01100011
I think C dominates because it's a language many embedded guys, who often are
EE's not CS graduates, can get their head around. Also C compilers were some
of the most common for embedded platforms going back a few decades. Up until
IoT became a buzzword, the embedded world was sort of insular and you had a
lot of guys who got their start in the 80s or before. Sure, there's Forth, but
that pretty much died out decades ago.

C is also deterministic, unlike, say, Python, where you don't have a compiler
to catch type errors and things can blow up unexpectedly at run time.

~~~
Sytten
Totally agree and thats what they still teach us at school in EE and CE
(believe it or not). I worked a bit on embedded devices during internships and
the only thing I saw is C sometimes with an API to abstract the registers (I
was in the world of PIC).

I talked with guys that still only coded in assembly and C was a "new" thing
for them. People just don't realize that if you can save a KB of RAM and
cycles of processor, you save on cost of pieces (you can use cheaper ones) and
if you are to produce million of pieces thats a lot of money...

~~~
berti
I never understood the attraction of PIC in the face of ARM. The ecosystem
seemed so much weaker in terms of compilers, libraries, and sheer variety of
parts available.

~~~
01100011
IIRC, PIC appealed to those embedded/EE guys because it was simple. It was
also really cheap. You could add a tiny bit of smarts to your design for a
little bit of money and effort. Those guys became well-versed in the PIC
weirdness and stuck with it even though other, more traditional(i.e. 8051
based) micros came out with good features at nice price points. I don't
remember a lot of cheap, easy to use options based on ARM around the time that
the first PICs came out.

Honestly I'm not sure though. I skipped the PIC entirely. I dealt with Z8's
and 68HC12s at the time(and TMS320s, but that's another story).

------
tomglynch
Was reading the comments and realised it wasn't what I thought it was talking
about. Very different besides name and node/js, check out this tiny local JSON
database, LowDB:
[https://github.com/typicode/lowdb](https://github.com/typicode/lowdb)

------
martin-adams
I'd be curious to know if something like this has any performance gains over
running full Node.js in a microservice architecture under high load.

Feels like if you've got a Node service running in Docker, whether using
low.js can reduce the footprint.

------
catchmeifyoucan
This is cool, but I don't get how to use it? I'm sold because it works on
ESP8322, but I'm confused now because I have to buy the board again?

------
truth_seeker
There is also JerryScript runtime by Samsung. It supports ES5.

[http://jerryscript.net](http://jerryscript.net)

------
village-idiot
Meh. Jamming JS into more places it has no right to be. I’m sure this’ll go
well.

~~~
dang
"Please don't post shallow dismissals, especially of other people's work. A
good critical comment teaches us something."

[https://news.ycombinator.com/newsguidelines.html](https://news.ycombinator.com/newsguidelines.html)

~~~
village-idiot
Honestly at this point, why does “please stop shoving JS into everything,
you’re fucking it all up” need to be even said? That this is even mildly
controversial (or in your case, flaggable) is a sign of how far we’ve sunk.

~~~
dang
It doesn't need to be said. That's the point. Could you please stop saying it
now?

