Saturday, May 23, 2015

DevTools, Firefox OS and wearable devices

Recently, I had the opportunity to give talks at two amazing events. I will try to summarize the experience, as well as share the same content here.


The first event was Mobile:Next, where I had a bunch of fun. For some reason, my laptop wouldn't work with the projector there, so I had to use some other laptop. It was both good and bad. For one, I was able to setup everything I needed to give a technical demo, in just 10 minutes. That really shows you the ease with which you can get into developing for Firefox OS.
The atmosphere was really really nice. People were quite friendly, and I feel I managed to get my point across to all people.

The most recent event was at BucharestJS. Given that these people were either JS developers, or people interested in JS, it felt like preaching to the choir. These people did JS better than I ever could, and still I was able to show them a bunch of new things about DevTools and even JavaScript ( most of them didn't know about ASM.js ) Here too I had a bit of a hiccup with the demo, where the Firefox OS Simulator failed to load. (My fault. Apparently I can't use it on release Firefox, after using it on Nightly).

So, let's get into the content:


First off, I talked about Firefox OS, and the way it works. I didn't get too much into it. The real stars of Firefox OS are the WebAPIs. These are the things developers care about. How do I do things?

The demo is a really great way of showing people how it works. Moreover, a bunch of people have no idea of the power that lies in the DevTools. On of the great features is Valence which allows you to debug other browsers, such as Chrome on Desktop, or Safari on iOS. (this is something most developers didn't know)

After the demo I went into how the apps work. As opposed to iOS and Android, apps for Firefox OS are web apps, so the really powerful feature is that you don't have to download an app from an app store, to be able to use it. Web pages and Apps would work largely the same way.
Of course, those don't always work when we don't have an internet connection. For that we need packaged apps. These are basically packaged web pages, that are downloaded so you can use offline, whether it's games, dictionaries, camera apps, etc.
One special group of these is privileged apps, which are packaged apps with certain permissions, so they can use various more powerful APIs.
The last group is certified apps, which are apps developed by Mozilla or partners. Certified APIs can only be used by developer apps through WebActivities

The best thing about Firefox OS apps is that it doesn't pin you to a certain app ecosystem. You don't have to distribute your app through the Marketplace. You can just host it on your own web server, and even sell your app, without any involvement from Mozilla, without the user having to take any risk or check a "allow apps from untrusted sources" box.

However, one of the incentives to distribute your app through the Marketplace is that you can use Firefox as a runtime for your apps. If you go to the marketplace on Android, or desktop, the app will be downloaded and packaged as a native app (Android, Windows, whatever), and then you can use it just as you would a native app. It will still be using Firefox as an engine, but it will lack Firefox's UI, and you will be able to uninstall it just as you would a normal application.

The next part of my presentation was largely based on Jan Jongboom's project, JanOS. It's a great project, as it solves one of the major hurdles to starting your own wearable device project - Cost! If you just do the obvious thing, and go for RaspberryPi, but if you need a screen, a battery, wires and a couple of sensors, it can easily cost you upwards of 100$.
Meanwhile, the cheapest FirefoxOS phone packs all those components, and more, and costs only 25$.
Moreover, if you strip it down to the essentials, its a bit smaller than a credit card, making it great for a wearable device prototype.

The really cool thing about this is JanOS, which is a stripped down version of FirefoxOS, without all of the apps, and UI, just a simple web page and all the JavaScript bindings and premissions you might need.

There are several simple things you can do with it right after you flash it, such as the doorbell demo. It involves the phone's proximity sensor, and a Bluetooth speaker. I didn't have a speaker, to I set it to vibrate when you triggered the proximity sensor, then I disconnected it from the computer, and passed it into the audience to play with it.
Of course, there's a bunch of cooler stuff you can do with it. You could use it as a security camera, or as an answering machine, or as an alarm, or as a webcam.
There are a lot of possibilities!

And JanOS comes with a bit of goodies on the side - 2 APIs that allow you to run native commands on the phone, and to directly access the filesystem.

Recently a bunch of companies have emerged that build their devices on Firefox OS. Such as Matchstick, Panasonic's UHD TVs running Firefox OS, or even something like the Monohm Runcible. The reason to use it is that it's a great platform, which requires very few resources, and which you can easily adapt to your own needs.

This was basically my talk. I also had a few slides prepared to address questions from the audience. One of these was for the performance question - Asm.JS addresses performance very well. The way this works, is the emscripten compiler transforms your C/C++ code, into a very optimized subset of JavaScript. This allows the JavaScript engine to run it really really fast, while browsers that don't support ASM.js will still be able to run it, albeit at a slower speed. This page lists a bunch of great demos - Dead trigger proved to be a hit with the audience.

I also included a few tips for the audience interested in porting existing apps to Firefox OS. Mainly, if you already have a web application, or an app built with Apache Cordova/Phone Gap, your job should be super easy. If your app is very Android/iOS specific, you might a difficult road ahead of you.

These were a couple of great events. I hope I managed to reach the audience, and clarify all that they needed to start developing for the web.

-- 

If you read this blog post and have any questions about Mozilla, Firefox OS, the web or anything... comment, or send me a tweet or email. I'll do my best to anwer.