Javascript on devices #2 – 21/01/14

On Tuesday, I went to my second JS on devices meetup. Like the first one, it was full of really useful information and cool tech. It also really showed off the ease of using javascript across a range of devices. Alex did a really great job organising this. It’s also nice to see companies (like Badoo in this case) hosting these kinds of events and enabling great discussions.

Enough of the fluff though. Now for the meat. There were three separate talks – about quite different devices.

Google glass

Radek started off the evening by talking about Google glass.

Interestingly, this was the least technical of the talks. A fair amount of it was focussed on introducing us – the audience – to the device and its capabilities. My guess is that this is because Google glass is in a sense the device most foreign to a tech audience. The user experience is clearly completely different to normal computers, mobile phones, other (sensor based) embedded devices. It also felt like the USB connection-based video feed to Google glass did not manage to fully convey the actual experience of using it. Radek had to work quite hard to bridge the gap to the actual experience!
I’d really love to take one of these for a spin, but at $1500 to join the developer community, it is quite steep and a big investment. Still, some of the things which he showed were extremely cool.

On the tech side, Radek briefly introduced two different ways of developing for Glass: A mirror rest API and the more traditional Glass SDK, GDK. The latter is a close sibling of the Android SDK, but still very much under active development with new releases happening every month.

Radek also had to spend some time justifying glass as a separate device (as opposed to, say, a mobile). His argument was that Google Glass solves the attention problem that many people struggle with. I.e. glasses notify you about important events without distracting you too much from your day to day activities. Working with Google Glass is not as disruptive as getting your phone out. Personally, I have to admit that I still have to be convinced, but – still – I would love to try one!

Run Javascript on Arduino – what, why and how

In the second talk, Alex spoke about how to run javascript on the Arduino. You can find his slides here. He first spent some time giving us some Arduino context which, as an Arduino noob, I found very helpful: He talked about things like the different types of Arduinos and the different extensions (“shields”) you can get for an Arduino. It made me very much want to get one – especially because I don’t know nearly enough about the hardware/circuit side of things and this would really force me to catch up with it.

In terms of running javascript on the Arduino (the title of the talk), the approach Alex presented was that of running a javascript wrapper library on a computer which allows you to abstract the actual hardware instructions. I believe the words “Johny five” and “Noduino” might be appropriate here!

The downside, of course, is that in this setup the Arduino needs to be connected to a computer. However, Alex pointed out that this means that you can leverage the computing power and other in-built facilities (e.g. wifi) from the machine.

Nodecopter

Finally, Andrew talked a little bit about Nodecopter. You can find his slides here. Nodecopter is a project which managed to run NodeJS on Parrot’s AR drone 2.0. This drone has got some pretty cool facilities: Front and bottom camera, 4 rotors, ultrasound sensors, 1ghz ARM cpu with 512mb of storage. It is also a flying router – it shows up as an unsecured hotspot.

Andrew showed some pretty awesome hacks for this drone:

  • Controlling the drone via a dance mat
  • Controlling the drone via a Kinect
  • Virus copter

He also talked a little about two different ways of operating the drone: one loading a node cross compiler on to the drone and then loading javascript files via ftp or USB stick so that these can be executed on the drone without needing to interact with the drone over its wifi network, the other of loading different javascript files on to the device and interacting with it that way.

Altogether a pretty awesome evening with exciting talks about three very different, but very cool devices!

Advertisements

Javascript on Devices #1 – 17/12/13

On Tuesday was the first meetup of a new meetup group: It’s all about running javascript on devices (e.g. the raspberry pi). In the past this would have been quite an usual meetup. Traditionally, embedded devices have always relied on native code to squeeze the most out of the computing power available on the device. However, javascript definitely seems to be the cool kid on the block and its community has leaps and bounds of energy for innovation.

For a native developer with (a little more than a) passing interest in web development this kind of meetup is a big culture shock. The technologies and tools bear a passing resemblance to what I’m used to in my traditional (mainly desktop-)client-server world, but everything feels a little foreign. Maybe because of that it also feels fresher and more exciting – like they are really pushing the envelope. Definitely lots of new stuff to research and think about (for me)!

For guys who do a lot of work with javascript or are familiar with embedded devices, these introductory talks may have been a little basic, but for me they were perfect. There were two talks:

  • A talk about the internet of things by Vlad
  • A talk about pushing javascript on to embedded devices with a simple git-push by Alex

The internet of things

Vlad’s presentation was split into two parts. He first talked about how with devices we currently have more of an intranet of things and the potential of moving towards the internet of things. He then spoke a little about the setup of his startup and how its work helps in moving towards the internet of things.

The intranet of things was Vlad’s metaphor for describing the current state of proprietary networks, protocol, standards and APIs that are prevalent in the embedded devices community. He argued that a move towards a REST & HTTP-based internet of things would bring big benefits to embedded devices:

  • ability to transfer experience of web development
  • proven scalability
  • reduction in development cost (ease of use, ability to reuse code for similar problems)

Another benefit is of course the ability to enable different devices to communicate and interoperate with each other. In my mind, this is the key benefit because pooling enables the kind of collaboration where the sum is greater than the parts: It is the kind of thing that turns a nicer development environment into a true platform on which higher level applications can be built:

For example, one of the things that Vlad mentioned is that we won’t need to physically search for our shoes in the morning and instead we will Google them. However, what if we could rely on a preference-based algorithm to physically select our entire wardrobe in the morning (entailing collaboration between lots of different individual units of clothing)?

He also talked a little about what may be necessary for this move towards HTTP (ADIs etc.)

The second part of his talk was more focussed on his startup‘s work towards this. This work has been to write REST APIs for particular projects as well as providing an infrastructure around these APIs. Interactions with the devices are supported at various levels of sophistication (QR code; RFID tag; sensors or raspberry-pi-like machines).

One of the interesting points was that his main customers are big companies who are looking to protect their (and their client’s data). Therefore, the normal deployment option is as a private cloud. Unfortunately, data security, identity and sharing are of course key concerns, when establishing a platform as described above. Private cloud-like deployment may limit potential.

In my mind, the main benefit is therefore the reduction of development cost and enabling a wider community to offer services for companies within their private cloud.

Deploying (javascript) more easily on to embedded devices

Alex’s talk had three parts to it:

  • Rise of javascript as a language and rise of devices

    This part talked about all the bits that you might expect from a young development community brimming with self-confidence: Describing milestones in the development of the language as Alex sees it (from original invention to use in gmail, to “javascript the good parts” to node.js to phonegap to nodecopter), showing us benchmarks in javascript execution times through time etc.

    Alex also described the evolution of devices, how devices are getting much more powerful and how we are reaching the point where squeezing performance for every clock cycle is no longer as important.

  • Using javascript for displays on bins

    The second part of the talk then described how Alex and his team first got involved in embedded javascript development. This was with a project for displaying ads on bins. The team here worked mainly on displaying ad content to end users. As part of this, they had to solve several interesting problems such securely interacting with the machines, finding a way of remotely updating content as well as underlying software, dealing with network reliability issues etc.

  • Use the experience gained for resin.io startup

    In the final part of his presentation, Alex described how this experience led them to develop an infrastructure that makes it easy to deploy javascript to devices. The service was compared in type to heroku (which I hadn’t heard of before) which offer a similar service for web applications. (I.e. they offer the ability to deploy to a hosted environment with a simple git push). Alex also described the technology stack they put together for interfacing with devices.Unfortunately, I can remember only some small parts of the infrastructure – in particular: docker and openVPN.

Altogether I found Alex’s talk very interesting and informative – with lots of pointers in new directions where I’d like to learn more!

Review: “The Node Beginner Book” by Manuel Kiessling

I have recently started dabbling with Node.js. A local meetup I stumbled across called stack kitchen is to blame for this dabbling:

Before the talk, I felt a little self-conscious about my node & javascript skills and went looking for somewhere to get the basic low down on node.

Being a lazy Google-user, I did not make it far down the list of results (or even try a very specific search) and used this tutorial.

About halfway through, I realised that the site was actually plugging a book – so I bought the book and worked through the rest of the book.

There are of course lots of other tutorials to choose from out there – probably because node is the flavour of the month (or given how hip I am the flavour of last month…).

Other tutorials and node resources are for example:

  • This focusses on node as a script host, not so much on the typical use case as a web server.

    I liked that it gets you started quite quickly and also mentions some important main features (interactive shell, packager manager, modules, callbacks). A good quick start guide if you want to start hacking things together.

  • This is more of a blog than a tutorial. It covers lots of different stuff. Probably not a place to come back to later, but not for finding your feet.

  • Felix (much like Tim who is man behind “How to Node”) is one of the early contributors to node. This website is really several guides in one: a tutorial to get you started, a guide on the community, a style guide and a guide on how to convince your boss (aka when to use node).

(This list was compiled on the couch on a lazy Saturday morning. So… let me know about other cool Node resources!)

How do you choose between those and this book?

If you’re like me, you’ll just take a chance on the first one you stumble across, but “The Node Beginner” book might be for if you…

  • …are interested in using node on the web server
    Almost all of the book (apart from the initial hello world example) is organised around a couple of (toy-like) web server use cases. There is e.g. no mention of using the node shell or script / parsing like examples.
  • …have some experience in programming, but not really in javascript

    This book assumes almost no familiarity with javascript. I reckon you could probably get away with knowledge of any OO language. Some server side exposure might help. (I have played around with javascript mainly for mobile and client side toys in conjunction with frameworks like knockout and even knowing only these toy use cases I found some of his explanations a little long winded.)

  • …are interested in different components of a web server and how they hang together

    The separation in to different modules such as the server, the router, the request handlers and view generation was one of the parts I enjoyed the most. While this is well covered, familiar ground (Skonnard e.g. covers similar handling and routing for WCF RESTful web services here), there was very much a beautiful simplicity to the toy implementation here.

  • …like a blog post writing style

    Writer’s style obviously comes down to personal preference, but I really like the style of the book. While sometimes a little long-winded, things are explained in a clear and logical way. Steps are laid like the thought process of somebody developing their first node application. For me this kind of approach fits very well.

Beyond this (and in the interest of adding yet more bullet points), there were some particularly interesting insights here for me:

  • …how strikingly easy it was to set up a simple server

    You literally need nothing more than node installed and the six line long javascript sample on the node.js website. Wowsers.

  • …how you then still need to hack your server components together
    There was a fair amount of reinventing the wheel in the book. However, to appreciate how much you need to really reinvent the wheel and how much was just a teaching device, I really need to dig a little deeper into existing node packages. Initial impressions are that there are loads and loads of packages.
  • … execution model

    This is one of the things I really still need to get my head around. I get the basic description in the tutorial of the importance of non-blocking operation and a single threaded event loop ….but… I really need to understand this a little better, e.g. how things are executed asynchronously. This seems like quite a good place to start – contrasting node with IIS&WCF.

  • …the ease of use of package managers

    I know this is the order of the day for almost any programming language out there now, but for C++ devs, this is still a big leap. I know Microsoft has expanded NuGet for native use, but because of C++’s reach across different compilers I’m a little sceptical of the widespread adoption of this.

For me, the next stop on the road of learning of node is “Hands on: Nodes.JS” by Pedro Teixeira.
This book comes bundled with the “Node Beginner Book”. Having read some of the first chapter (and glanced through the table of contents), this feels much more like a “grown-up” book. Lots of references to different patterns etc.

The plan is to also start building some breakable toys in Node. (Can you tell I’ve been reading a book about Apprenticeship patterns?). Those toys might make a good first use for my blog github repo.