
JerryScript – A JavaScript Engine for Internet of Things - talles
http://samsung.github.io/jerryscript/
======
inglor
Wait, so Samsung wrote their own new JavaScript engine for embedded devices?
This is actually very cool.

It looks very constrained in what it supports so far though.

Update: They're at ECMAScript 5.1
[https://github.com/Samsung/jerryscript/issues/205](https://github.com/Samsung/jerryscript/issues/205)
but not all tests are running
[https://github.com/Samsung/jerryscript/issues/158](https://github.com/Samsung/jerryscript/issues/158)

Ok, it doesn't yet JSON.stringify
[https://github.com/Samsung/jerryscript/issues/432](https://github.com/Samsung/jerryscript/issues/432)
so not sure if ready yet.

------
daurnimator
Similar projects:

    
    
      - http://duktape.org/
      - http://mujs.com/
      - https://github.com/gfwilliams/tiny-js
      - http://pdqi.com/cgi-bin/cgiwrap/pdqi/jsi.cgi/doc/tip/jsi/www/index.wiki
    

Fun alternative: Compile JS to Lua and run that instead (e.g. as done by
[https://tessel.io/](https://tessel.io/))

    
    
      - https://github.com/PaulBernier/castl
      - https://github.com/tessel/colony-lua

~~~
rawdisk
One more:
[https://cesanta.com/smartjs.shtml](https://cesanta.com/smartjs.shtml)

Opinion: Lua is a better choice for IoT but alas the programming "market" has
(again) chosen the worse alternative.

~~~
bsder
Lua has a significant strike against it in being _1-based_ when everything
embedded you'd want to put Lua on is _0-based_.

In addition, the point of having Javascript is so that I can get my junior
software folks (proxy for any inexperienced programmer) to write things for my
embedded hardware instead of having to haul out my senior staff engineers who
have 20 years of experience writing C for embedded devices.

Look at Arduino vs. Raspberry Pi/BeagleBone. Arduino has _way_ more developers
because it was orders of magnitude easier to program. Ecosystem is important.

~~~
acoard
>Lua has a significant strike against it in being 1-based when everything
embedded you'd want to put Lua on is 0-based.

Why is being 0-based more important on embedded compared to other contexts?

------
robmccoll
How does this compare to duktape ([http://duktape.org](http://duktape.org))? I
really like duktape's API and documentation (stack-based interface similar to
Lua and the doc perfectly describes how each function call affects the stack
state).

~~~
mwcampbell
The API isn't stack-based. It's more like the Python C API, complete with
reference counting (but note that actual memory reclamation is done through
mark-and-sweep GC), except that instead of _everything_ being a pointer to an
object, numbers and booleans are represented directly, so a union is used to
represent values.

------
tomphoolery
Coming soon: GeorgeScript, a little language that compiles into JerryScript.

~~~
the-dude
Everybody knows: you have got to keep your worlds apart!

You have slipped up.

------
sklogic
I'm struggling to understand - what's the point of using JavaScript for
anything embedded?

~~~
dragonwriter
> I'm struggling to understand - what's the point of using JavaScript for
> anything embedded?

The point, I would suspect, is lots of people already know JavaScript, so it
lowers the barrier to entry to embedded programming.

~~~
userbinator
_lowers the barrier to entry to embedded programming._

Embedded systems often have very different characteristics than e.g. a web
app, and just because someone has been doing JS web apps does not mean they'll
be any good at using JS with an embedded system (and vice-versa, but maybe
less so.) IMHO lowering the barrier to entry is just going to result in many
more buggy/insecure IoT devices... (JS does eliminate certain classes of bugs
associated with traditional embedded languages like C, but there are plenty
other bugs you can find in web apps that are not buffer overflows.)

~~~
dottrap
Be careful not to conflate web programming with plain-old JavaScript the
language. A lot of the horrible bugs in web programming come from the massive
complexity and size related to web browsers, the DOM, and over-engineered
frameworks.

If we're talking about streamlined, embeddable JavaScript, we're not bringing
the web and all those bloated frameworks.

You are right that those writing web apps won't necessarily be good at
embedded systems, especially since (for now), they will have to also separate
web APIs from JS-the-language and will not have the APIs they are used to.

But those who survive the transition process will likely pick up better
habits. I suspect the APIs and usage will end up looking a lot like the Lua
sphere, though perhaps more fragmented since none of JavaScript engines have
anything remotely resembling compatible C API interfaces.

------
kzhahou
Internet Of Things is a rather meaningless term. It was fuzzy at first, and
remains so a few years on.

Here, just say "resource-constrained devices" or something with ANY amount of
meaning.

~~~
tomphoolery
The authors of this engine are Samsung, who are currently leading the world in
promoting the "Internet of Things" buzzword.

------
orf
AKA how to not to make a landing page. "For more info check the Github" ->
"View the wiki for more info" -> repeat.

------
Animats
Nice. JavaScript allocates a lot of memory dynamically, and sometimes
implicitly, though. In very tiny RAM environments, that's going to be a
problem.

~~~
weland
It would probably be OK if all programs have a simple, predictable sequence of
malloc and free that they call in a loop, with similar-ish sizes each time.

It's extremely unpleasant to program something with just a few KB of RAM and
not know exactly what memory goes where. However, a lot of IoT-related gadgets
just gather a buffer of data from an ADC or something, average it and send it
over some wireless protocol every 1 minute. The allocation pattern is
predictable enough that you don't run into strange cornercases.

I see no reason why anyone would want to use this commercially, but for the
enthusiast market (and maybe even for some rapid prototyping) this looks
interesting enough.

~~~
mwcampbell
It seems to me that consistent allocation patterns would help more if
JerryScript used reference counting for memory management, perhaps with mark-
and-sweep GC as a backup to handle cycles. As it stands now, each object has a
reference count to keep it alive while it's being used by C code via the API,
but actual deallocation is done via mark-and-sweep GC.

------
cfstras
Isn't this basically the same as the Espruino [1]? Has anyone compared the two
in terms of performance and handling?

[1]:
[https://github.com/espruino/Espruino](https://github.com/espruino/Espruino)

------
bitmapbrother
JerryScript - A scripting language about nothing.

------
tmrmn
a few days ago Cesanta brought their v7 JS engine to the esp8266 and now
samsung is showing JerryScript. Pretty interesting times for embedded JS

------
hmottestad
For anyone interested in IoT, look at the esp8266.

It is a tiny chip with included wifi. It was 2 digital IO ports, and also a
serial connection if you want to connect it to an arduino.

And at the moment it costs 2.6 USD on ebay!!!

And someone made a plugin so you can program it from the Arduino IDE:
[https://github.com/esp8266/Arduino](https://github.com/esp8266/Arduino)

------
vegancap
This is something Tessel does well, I believe they do all kinds of
transpilation to Lua. This could be really useful for them.

~~~
tracker1
IIRC, I believe the Tessel guys are abandoning the transpiler approach in
favor of slightly more powerful hardware for the next generation that can just
run node directly... We're really at a point where for the types of projects
people want to run for under $100 of hardware, it's fast enough to do a lot
more.

Power is a bit of a concern, and it all depends on the environment... being
able to get every web monkey coding in more environments is a big win for
enthusiasts and commercial applications for limited scope projects... Hell,
without a screen or antenna powered on all the time, you can get a lot of
processing done on even a smart phone from two generations ago.

------
BFatts
[http://www.espruino.com/](http://www.espruino.com/)

This has been around for a lot longer than Samsung's (as far as I know) and
has a lot of great support. If you're looking for a small, embedded JS
processor built specifically for this kind of thing, I'd recommend Espruino.

------
volaski
Am i the only one who doesn't get the reference? Where does the name Jerry
come from?

~~~
jbottigliero
My first thought was "jerry-rigged". Rather than starting the almost
inevitable conversation here ("jerry" vs. "jury"), I'll point out the
following SE answer[1]...

[1] [http://english.stackexchange.com/questions/132868/jury-
rigge...](http://english.stackexchange.com/questions/132868/jury-rigged-or-
jerry-rigged)

------
cfontes
Very interresting.

But I just hate this "Internet of Things" name... There must be a better
suited name for it.

------
personjerry
I like the name :)

------
Raed667
If it doesn't work with an Ardunino Uno, then it is not relevant.

~~~
Raed667
Ok maybe an STM32F1 as well

