Ok, super technical link here…. You have been warned….
http://blog.technical.io/post/102381339917/a-new-engine-for-your-tessel
When designing Tessel, we grappled with some very unique constraints for a developer platform. Most microcontrollers weigh in at perhaps a few dozen kilobytes of RAM, and a small factor more Flash. The average amount of JavaScript in a single webpage exceeds the amount of space in most microcontrollers, including the Tessel’s Cortex-M3, which has only 200kb(!) of memory on-chip.
The problem with running JavaScript on a target like Tessel is that every commonly used JavaScript engine has been refined and tuned for Desktop PCs, with gigabytes of RAM and fast network connections.
LuaJIT is a combination of a few components: a parser/compiler converting Lua source into (LuaJIT’s own) bytecode, an interpreter for running this bytecode, and then a JIT (just-in-time compiler) for optimizing this bytecode into machine code at the lowest level. If you’re not familiar with a JIT, imagine a compiler that runs alongside your code, observing your code as it’s running. If it sees any loops that look intensive, are called often, and use similar types of variables on each iteration, it can bundle these assumptions up as compiler “guards” and generate low-level machine code that acts much more like C than a high level language. If, while your code is running, one of those guards fails (the variable i is no longer a number, because we suddenly assigned it to be an array!) we jump backward into interpreting your code one line at a time. This is one of many optimizations that happen while your code is running inside a VM with just-in-time compilation.
What these guys are talking about is really interesting.
You need a small OS footprint for these small IoT devices. What language has such a small footprint?
I will see if I can dig it up, but I talked about JS being the OS of IoT in a Tweet…..
Anyway, point is, the speed IoT is moving, you need an existing language so you can focus on getting stuff done, not learning the tool.
You also need cheap, small and fast enough. You can’t pick just two, you need all three.
Its looking more and more like JavaScript will do the job.
I’m not sure how it will become a standard, but with guys like this working on getting it into such small low power devices, its got a solid foothold in the IoT language of choice door.
EDIT: As if to prove my point, a few hours after I wrote this blog entry, another JavaScript engine popped up on my radar.
Duktape is an embeddable Javascript engine, with a focus on portability and compact footprint.
Duktape is easy to integrate into a C/C++ project: add duktape.c and duktape.h to your build, and use the Duktape API to call Ecmascript functions from C code and vice versa.
Main features:
Embeddable, portable, compact;
about 210kB code, 80kB memory, 40kLoC source (excluding comments etc)
Duktape. Equally small and interesting as Tessels efforts.
Small, fast, powerful. The IoT is pushing us to have all three.