The JavaScript Of Things


There are a ton of people out there that can program in JavaScript, but give them an embedded device, and they’re up the creek without a paddle. Not anymore, that is, thanks to [Gordon]’s wonderful Espruino, a JavaScript interpreter for ARM microcontrollers. Oh, it’s also a very capable dev board that has more than enough power to turn just about any project you can imagine into reality.

On board the Espruino is an ARM Cortex M3 in the form of an STM32 chip, 256kB Flash, 48kB of RAM, and a ton of PWM and ADC pins to go along with 2 SPI ports, 2 I2C ports, and 2 DACs. It’s a very capable piece of hardware, and if you’re looking to build anything, it would be hard to pick a better general purpose dev board.

[Gordon] has put his board up on Kickstarter, and since it’s already been successfully funded, he’ll be releasing the hardware and software sources under an Open Source license. If you’ve ever wanted to run JavaScript on an ARM board, it looks like Espruino is just the ticket.

57 thoughts on “The JavaScript Of Things

      1. That’s if you define “scripting” as completely different from “programming”.
        Personally, I view it as a subset of programming, where you happen to be using a scripting language.
        Assembly? Machine? Java? Javascript? C? All programming to me, but at different levels of abstraction, and with different toolsets and libraries.

        1. Well a programming language is defined as a script that compiles to a machine code (C, C++) or a Pseudo machine code (java, C#, Python). Since a scripting language is read by an interpreter, and not compiled to machine code it is a scripting language. it is a mater of semantics, nothing more.

          1. I consider scripting being programming without having to manage memory, mind buffers or pointers and all that jazz. In scripting those things are being taken care off for you.

          2. @voxnulla
            That would make C#, D, and Java scripting languages.

            The point of that “sooo 2001” comment is that the range of technologies available has broadened such that scripting/programming distinctions don’t actually make a whole lot of sense except in particular contexts.

          3. I think of scripting in a shell-script kind of way. Tying together fully implemented programs that actually do most of the work. The scripting just does a bit of basic guiding and routing between them.

            Programming is creating a program from scratch. No library by itself does anything useful.

        2. “That would make C#, D, and Java scripting languages.”
          The way these are used, I would indeed agree that these languages are more often than not scripting languages.
          It makes no sense determining what is or isn’t programming on whether you first have to produce a machine understandable binary, or that this is done JIT/at runtime.
          Perhaps a better way of looking at is is this : To program you have to understand the hardware, to script the hardware is arbitrary.

      2. I’d’ve said “horrible stapled-together misbegotten abortion”. Out of all the languages to take over the world… I’m really starting to believe that there are gods and that they really enjoy fucking with us.

        FWIW BBC BASIC had a lot of expansion potential, why not that? Or INTERCAL?

    1. I do agree, When I started programming I picked up Basic and what then was the first iterations of JavaScript. and I though I was a good programmer. until I got to college. It was then that I leaned how to program, and not just duct tape code together.

    2. Oooh, I remember a beautiful early book on Javascript. It was specifically about doing graphics programming with it. The whole book relied on the scheme of doing a, say, 200×200 grid of individual 1-pixel sized GIFs. Replacing each GIF by index with one of whichever colour was the basic pixel-plot. From there it went on to implement the standard methods of drawing lines and circles and things. Like a book on graphics from the 1970s, bizarrely hammered into a web browser!

      It was a heavy book! And somebody published it! Which means that somebody might accidentally have ended up buying it! This was back around 10 years ago, when the CPU and RAM of most computers would’ve meant watching the “pixels” change before your eyes. Assuming it didn’t crash the Javascript interpreter in versions of Netscape at the time, which it certainly must have.

    1. The author says it will become open once they complete the kickstarter campaign. I can understand it, but now that the money goal has been met let’s see if he keeps his word.

      In the meantime I would give a look at Elua ( which seems much more powerful, is already open source and comes from a very powerful, compact language aimed from scratch at programming and not web page automation.

    2. There is that virtue known as patience ;) Clearly stated from the beginning it will be released as open source after the kickstarter is fully funded, kickstarter has stated that will take place later this month. In the event the creator decides that the pledge amount is sufficient for release, release should be impending.

    3. The $4.95 is because I haven’t updated the images since before the KickStarter. If you go to register it does remind you that it’ll be completely free in 3 weeks :) When the campaign completes, I guarantee I’ll release the source code though.

      I’m not releasing right this second because I want a bit of time to tidy it up – I think that’s probably reasonable :)

      1. @Gordon – nice work. Something I’ve wished I had time for and probably still don’t, but it is very edifying to see someone skilled bring this sort of thing to the geek public. A big thank you for your time well spent on something I hope many will enjoy. Hopefully, I will find time to join them!

    1. Do you mean how JavaScript works or how JavaScript is often implemented? Implementations often suck in one way or another, but the specification for JS is pretty impressive for a lot of reasons. Memory management is up to the implementor and some, like IE, really do a bad job at it. I suspect Gordon, having an embedded system as his target has made a tight implementation, though I won’t know till I can see what he’s done in more detail. Just a hunch though.

  1. What am I missing? JavaScript runs in a browser to add another layer of processing to the data that gets returned by a Web server, just before showing it to a human. Or to respond to user input within the page that got returned by a Web server.

    I can understand JS on a Raspberry Pi – you can hook up a monitor to it – but an MCU? Who or what is the recipient of the data processed by that JS?

    1. @Robot I don’t currently use a watchdog timer, but when you use ‘setWatch’ on a pin, changes on it trigger an interrupt which timestamps the event and sticks it in a queue. JavaScript always runs in the main loop, but because those events are timestamped you can do really accurate timing very easily (eg. for Ultrasonic Distance sensors).

      Espruino won’t be suitable for some things – but for 95% of what people do with Arduinos it’s significantly easier to use…

      1. I’m sorry, but if the plethora of libraries with accompanied examples from which you can snag code without writing but a single line yourself is so hard that you need something easier, perhaps you should not even be dealing with electronics do to the 100% chance you’ll set the house on fire.
        Apart from that, how can the implementation of a language that has been designed to be as remote and detached from the real iron form a solution for this non existent problem?

      2. @Gordon, thanks for the reply. Interesting. . . with a 72 MHz clock your setWatch as being sufficient for most applications. I could see this as a gratifying entry into the world of hardware for the object oriented types. . . certainly less painful than the experience of cutting my teeth writing HDL for a CPLD and ASM for the 68HC11. I think hardware engineer types like myself can’t help but be defensive of the hard won experience of working at the bit level.

        As an aside some years ago I asked a friend “what exactly makes a language object oriented?” He was baffled and struggled to explain something he felt to be so fundamental. Honestly, I still don’t know the answer to that question :P

        I’m still waiting for someone to show me what that looks like in machine code.


        1. @Robot: Thanks for the positivity! People seem to think I’m trying to replace C with it – I’m not. It’s probably best to think of it as a scripting language for hardware.

          However I still believe that most of what people do with Arduino is actually quite simple, and is well-suited to JavaScript. Of course for the bigger projects you’ll probably still want to use C – and you’ll need real knowledge of the underlying hardware.

      3. I am not understanding this well lol. To me the greatest advantage of using JavaScript for hardware is that you can attach event handlers to pin interrupts. ie not in the main loop.

  2. This is very interesting but I don’t know it will appeal to.

    JavaScript would be a good hardware language because of it Property/Method/Event structure. The dot, curly bracket, semicolon syntax would be comfortable for a wide range of programmers.

    The problem is that most JavaScript programmers who have had any experience with web implementations of JavaScript hate it with a vengeance.

    Just watch as the sweat form over a web developers brow when you ask if his code is cross browser compatible. For this reason most web developers go one level of abstraction further and use a framework like Prototype or jQuery so they can program in a ‘JavaScript like’ way while not having to worry about cross browser comparability issues.

    I often use JavaScript for quick data crunching where the presentation of the results are visually complex. I just make a .htm file on my desktop and instantly I have a useful and simple programming environment that is very good at rendering. BUT if someone asks me to do any JavaScript for a web site then I just say I don’t know anything about JavaScript at all.

    I hope an prey though that this implementation has removed case sensitivity! That’s my pet peeve with JavaScript.

  3. A hardware solution to a software problem, just to sell some things.

    The smart thing for this would have been to make some sort of Java to C translator that can work with any development board.

    But honestly, if you are a web developer skilled in Java, learning to program in C is not the difficult part. You will still be faced with all the hardware things you will have to know about the embedded platform, you know: pins, timers, PWM, ADC, UART etc. These will still take a lot more time than learning a bit of C(++)

Leave a Reply

Please be kind and respectful to help make the comments section excellent. (Comment Policy)

This site uses Akismet to reduce spam. Learn how your comment data is processed.