top | item 6214553

JavaScript right on the hardware

346 points| chinchang | 12 years ago |technical.io | reply

313 comments

order
[+] eob|12 years ago|reply
First off, this is cool. It is tremendously exciting to see the bar for hardware hacking getting lower and lower. To the people complaining "Why JS? C is fine!", remember that once the complaint was "Why C? ASM is fine!".

At the same time, I can't help but grin that we on the CS side find a way to erase all the gains in performance and efficiency as soon as the EE guys make them.

There has to be come kind of universal constant: the limit, as technology proceeds into the future, of the execution time of "Hello World" is some fixed number. Because as soon as we get better hardware, we invent an even weightier runtime environment to slap on it. ;)

[+] btilly|12 years ago|reply
At the same time, I can't help but grin that we on the CS side find a way to erase all the gains in performance and efficiency as soon as the EE guys make them.

This is a long-noted phenomena. The old saying that summed it up was, "Andy giveth, Bill taketh away." (Referring to Andy Grove of Intel and Bill Gates of Microsoft.)

[+] 10098|12 years ago|reply
I don't have much problem with programming an embedded device in a high-level language, but why JS specifically? Why not Lua, which just as fast, and is better than javascript in many respects?
[+] coldtea|12 years ago|reply
>At the same time, I can't help but grin that we on the CS side find a way to erase all the gains in performance and efficiency as soon as the EE guys make them.

That's one way to see it.

Another is that we don't erase them: we put them to use so programming can be more widespread, easier and more ambitious in scope.

(E.g. you cannot practically write a 10.000.000 line program in ASM, whereas you can in C. Or you cannot have everyone be able to write a 200 line high level program that does something complex in C, but you can in Python).

[+] cpeterso|12 years ago|reply
The joke I've heard is that software is a gas and expands to fill the available space.
[+] aufreak3|12 years ago|reply

    At the same time, I can't help but grin that we on the 
    CS side find a way to erase all the gains in performance
    and efficiency as soon as the EE guys make them.
Here is one way I can think of - add a layer to run a subset of Scheme on this :)
[+] jkscm|12 years ago|reply
I don't think the language has been the problem. Just look at the Arduino.

For me, the main challenges always were getting the program onto a chip and wiring everthing so that is does not break or shortcut.

[+] farnsworth|12 years ago|reply
Forgive me for not being hip but why try so hard to put JS in new places? It seems to be just an unfortunate historical accident that JS is one of the most popular languages in the world - does anyone actually like it compared to other modern scripting languages? Could we invest in CoffeeScript instead, at the very least?
[+] nawitus|12 years ago|reply
From the title I expected the CPU to actually run JavaScript, like a certain decades old computer (of which name I can't recall).
[+] mbell|12 years ago|reply
ARM tried this with Java, it was called Jazelle and was (is?) a complete disaster.
[+] twog|12 years ago|reply
So much negativity in this thread & on HN in general. Not everyone has hardware experience, and this looks great for newcomers.
[+] chad_oliver|12 years ago|reply
This is very cool, but I don't see how it can compete with boards like the BeagleBone Black. The BleagleBone Black is $45 for a 1GHz CPU and 512 MB of memory, yet the access to low-level hardware is just as good.
[+] Florin_Andrei|12 years ago|reply
Very, very different things.

The BBB and the Raspberry Pi are designed to be relatively high-power (both computational, and power draw from DC) devices running a true multiuser OS.

This thing is more akin to an Arduino Micro or a Teensy - a low-power controller that could run a very long time on a tiny battery, no OS to speak of, just a single loop of essentially real-time code.

I just made a hardware clock for my PC (7-segment LED display mounted in a CD-ROM bay slot). I used an Arduino Micro to drive the display.

I may build a dedicated media server at home. A RasPi or BBB would be perfect.

I'm thinking to launch a stratospheric balloon. I need something to hold together and drive a GPS sensor, temperature sensor, VGA camera, SD card, and radio transmitter. Total weight and power consumption are severely limited. An Arduino or Teensy would be great.

Do a wall-mount big LCD screen at the office, showing the vital stats of our website in real time, for all to see? A RasPi or BBB.

Or you could go even more bare-metal and do everything with an AVR that costs $1 and a few components that you recover from the last floor sweep, like this:

http://florin.myip.org/blog/how-make-halloween-creepy-blinki...

See the differences? Horses for courses.

[+] brianpgordon|12 years ago|reply
Looks like the JavaScript bindings for Tessel are better. Comparing the demo for blinking an LED:

  var b = require('bonescript');
  var state = 0;

  b.pinMode("USR3", 'out');
  setInterval(function() {
    state = state ? 0 : 1;
    b.digitalWrite("USR3", state);
  }, 100);
vs

  var tessel = require('tessel')
  tessel.led(1).blink()
If they can give human-friendly names to stuff like "USR3" and "P9_40" and "P9_36" out of the box, then I'd say they've added some value.
[+] deepblueq|12 years ago|reply
You forgot the best part: not having to deal with javascript.
[+] wiredfool|12 years ago|reply
I don't see a price yet for this one. I like the pi (and the beaglebone) because they've already got the network hardware, but the gpio isn't as robust as on the arduino (3.3v vs 5v, very low current capacity on the pi, and no analog io).

I can't say I particularly want the javascript, but if they've got wifi and arduino compatible gpio for ~ $25, then I can find a use for it.

[+] taurath|12 years ago|reply
I'll take "most terrifying things you could tell an electrical engineer in 2005" for $2000, Alex.
[+] kyzyl|12 years ago|reply
I had this thought was well. As as physics major and an EE major, it's a (somewhat humorously) terrifying concept, at some level.

Now this has more or less been discussed to death in the threads above and below, but while I don't necessarily think running JS on a uC is a great idea, I don't see a problem with letting non-hardware-versed folk write low level code. People who know hardware will probably not use it for anything critical, and if it makes someone's life easier without endangering others or utterly diluting the community (knock on wood...) then so be it. There's no reason to be elitist about low level programming.

At this moment my workspace consists of a bit of code for an 8bit microcontroller, a FPGA layout + VHDL, and a mixed signal high speed PCB layout I've been laboring over for the better part of two weeks. Take that, "low level" C! Now I could go off about how superior and/or necessary my low level methods are, but my friend who's working on an ASIC design might say something similar to me. There's always a lower level. As always it's a little bit about preference, and a lot about using the appropriate tool for the job.

I might have a problem if web developers started cramming JS onto arduinos and calling themselves competent hardware engineers, but (and I think most people in the field would agree with me) I suspect the likelihood of that happening is negligible. It becomes apparent very, very quickly when someone is pretending to know how to hardware.

[+] malandrew|12 years ago|reply
So a lot of people have been complaining: "Why not language X, Y or Z instead of JavaScript?"

This to me makes me think that there is a space out there for a board that has some equivalent to vagrant/docker but for microcontrollers, where you can just flash the device with a image supporting a language of your choice.

Near as I can tell, there is nothing I read on the product launch page that says that JavaScript is supported at the physical hardware level.

[+] proee|12 years ago|reply
Javascript doesn't support integers, so it doesn't seem like a good language for programming low level hardware. What about bit manipulation (XOR, AND, Shifting, etc)? This is critical for a lot of serial data communications and I/O controls.
[+] teebrz|12 years ago|reply
JS supports integers; it just doesn't have an integer type so you can't always store, operate, etc on them efficiently (though a smart engine can do some of that for you). It has bitwise manipulation operations which treat the Number as a 32 bit int. There are also Typed Arrays which make it easier to work on raw binary data. Though yes, it can occasionally get a little finicky trying to interface a high level dynamic language with lower level stuff.

Anyway, for this I'm sure there will be a lot of libraries that handle that for you and expose a fairly high level api; like the blinking led in the example.

[+] tehwebguy|12 years ago|reply
This is cool!

If you are a veteran programmer it may seem dumb but there are plenty of people who only know JavaScript (& HTML). Some of those people will be utterly blown away that they can control actual, physical "stuff" with those skills.

[+] jevinskie|12 years ago|reply
Nifty! I presume this is running on a Linux kernel? How much memory does node use? I would think that kernel + JS VM would chew up quite a bit of your 32 MB of RAM.
[+] chinchang|12 years ago|reply
There have been many attempts with Node on embedded systems. Nodejs seems to work on as low as 10MiB.
[+] zokier|12 years ago|reply
> I presume this is running on a Linux kernel?

I doubt that. It has M-series ARM microcontroller, Linux is usually used with A-series ARM CPUs.

[+] hardwaresofton|12 years ago|reply
It is very rare that I actually put my email into one of those "sign up for updates" things, this is pretty awesome, can't wait to hear back from you guys
[+] peterwwillis|12 years ago|reply
This is the most elaborate troll i've ever seen. Kudos to the team for creating what is literally the physical embodiment of everything I hate about technology.
[+] delluminatus|12 years ago|reply
In contrast, this troll is quite transparent.
[+] knodi|12 years ago|reply
Please I don't need more JS in my life, i need less JS in my life.
[+] smilekzs|12 years ago|reply
Many others do seem to need more, though.
[+] tambourine_man|12 years ago|reply

  180mhz ARM Cortex-M3 LPC1830
  32mb SDRAM
I'm amazed that such wimpy hardware can run modern JS satisfactorily.
[+] test-it|12 years ago|reply
It won't run satisfactory.

Reminds me of that time Sun made the Java CPU and the JavaStation. A hardware implementation of the JVM. It ran 20 times slower than the Microsoft JVM on an average Windows PC.

[+] smilekzs|12 years ago|reply
I'm amazed too, considering how I often have to squeeze lots of performance out of my sub-100MHz Cortex-M3 micros, even when I'm using C++.
[+] ontouchstart|12 years ago|reply
JavaScript is the most deployed dynamic embedded programming language in the world (consider all the web browsers on desktop computers and mobile devices). If we expland this environment to customer hardware, we also expand our view of UI/UX to a different level. We should thank Moore's law.
[+] nfoz|12 years ago|reply
Are you implying that JS developers know more about UI/UX than others?

Most websites have horrible usability, ranging from "everything in CSS popups!" to "every site uses a different widget toolkit, deficient in new and exciting ways".....

I hope I just don't understand your comment.

[+] tn13|12 years ago|reply
This is precisely what I wanted to work with.
[+] dkuntz2|12 years ago|reply
Why? Because it uses JavaScript? I'd rather stick with my Arduino and use C. I don't get the whole "JavaScript Everywhere" meme, I'd rather use almost any other modern language (note the almost).
[+] aufreak3|12 years ago|reply
It was both a pleasure and a pain for me to read about this! Pleasure - because a language with closures is finally getting "closer to the metal" (even if it means an abstraction layer sitting in between). Pain - because that language is not a Scheme/LisP!

This would be so much cooler if I could tap into an REPL remotely and blink out a Morse code on the LEDs :)

PS: I have no idea what makes most of us go "cool!" whenever some form of remote control of a hardware device is presented :)

[+] zdw|12 years ago|reply
I'm curious about performance on this, compared to something like the Arduino YUN, which is basically a OpenWRT MIPS system (which uses a Lua UI by default) and an Arduino tacked on the side:

http://arduino.cc/en/Main/ArduinoYUN

The CPU in particular seems quite underpowered assuming that they're clockspeed comparable, but I'm not familiar enough with the M-series ARM cores to give a proper opinion.

[+] errordeveloper|12 years ago|reply
This is way better then Yun, IMO. Yun is an awkward design, I find very few reasons they had to put an 8-bit AVR and AR9 on one board. WTF. I really like this solution with a beefy LPC18xx and CC3000, it's totally cool by me.
[+] gfwilliams|12 years ago|reply
I've been working on another embedded JavaScript project - first posted on here almost a year ago, and soon to go on KickStarter: http://www.espruino.com

This is really interesting though. It looks like they've got linux and node.js into 32mb RAM, which is seriously impressive. It seemed as if people were trying and failing on Carambola (but that may have been because it didn't use an ARM CPU...)

[+] outside1234|12 years ago|reply
Did anyone find details (or have an idea) on power consumption?

<selfishPlug> I'm the maintainer of nitrogen (http://github.com/nitrogenjs/service), which is a node.js based project to provide web services and client libraries for devices like this. Check it out if you are interested in devices like this! </selfishPlug>