151 points · by talles · 11y ago · 70 comments
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 but not all tests are running https://github.com/Samsung/jerryscript/issues/158
Ok, it doesn't yet JSON.stringify https://github.com/Samsung/jerryscript/issues/432 so not sure if ready yet.
- 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://github.com/PaulBernier/castl
- https://github.com/tessel/colony-luaOpinion: Lua is a better choice for IoT but alas the programming "market" has (again) chosen the worse alternative.
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.
Why is being 0-based more important on embedded compared to other contexts?
You have slipped up.
Sure there's Lua et al but JS is just a more relevant language nowadays.
JavaScript is not that high-level anyway, and there are many high-level languages that are much more embedded- and realtime-friendly. Why choosing JavaScript over the much more suitable ones?
...though I'm not sure what languages you think are more high-level that are not thereby made somewhat more difficult to use by beginners and/or on small projects, which would rather defeat the purpose, since the actual code running on these cheap microcontrollers is usually relatively small.
The point, I would suspect, is lots of people already know JavaScript, so it 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.)
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.
Indisputably. Lowering a barrier to entry isn't the same thing as guaranteeing success for every entrant.
As a field ages and accumulates best practices and social patterns, domain knowledge becomes relatively more important and technology choices become relatively less important.
Many of the biggest profit opportunities in a field come from owning the platform it's built upon, which is why it's logical to try and attract developers early with technologies they're familiar with. Eventually domain knowledge will matter more - but that depends upon the platform becoming big enough that it's a domain.
Unfamiliar programming language is an impediment, for many, to that learning process. If the tradeoff for that is a much clearer mapping to the domain than a more familiar alternative, the unfamiliar language may be, pedagogically, a net win, but -- especially for self-study -- people are more likely to learn enough to look deeply into the domain (including through unfamiliar languages) if the initial entry path is easy from where they currently are.
Here, just say "resource-constrained devices" or something with ANY amount of meaning.
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.
Ardunino Uno (ATmega CPU): 2KB RAM, 32KB ROM - Too small.
Arduino DUE (ARM CPU): 96KB RAM, 512KB ROM - Yes.
Raspberry Pi (ARM CPU): 256MB RAM, 1GB+ ROM - Yes, but why?
On the Raspberry Pi, of course, you can run Go programs. Or anything else that runs on Linux. It won't fit on the smaller machines. There's no need to run a Javascript this tiny on the Pi.So the target for JerryScript is machines in the Due range. Rust has been crammed into the Arduino Due, which may become a good approach for embedded work. Go probably won't fit; too much runtime.
They're all in the $25-$45 price range. The Due, surprisingly, is the most expensive.
To be fair, that system really doesn't run anything dynamic well.
However, your point stands. Requiring 64K of RAM puts this above most ARM Cortex M0 chips.
Picobit (https://github.com/stamourv/picobit) sits comfortably in 16K ROM/4K RAM. There's no good reason why Javascript vouldn't do the same.
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
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.
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.
[1] http://english.stackexchange.com/questions/132868/jury-rigge...
But I just hate this "Internet of Things" name... There must be a better suited name for it.