The significance of the 33$ Firefox OS smartphone

By creator1988 on Tuesday 26 August 2014 20:48 - Comments (7)
Category: Frontend, Views: 14.410

This article is a reworked abstract from my book Firefox OS in Action. The first few chapters are currently available under early access at http://manning.com/jongboom/. You'll get 50% off with code 'dotd082714au' if you buy it on August 27.

The launch of Firefox OS phones in India yesterday made a lot of buzz. Major reason: for the first time a smartphone was launched for a price under 2,000 rupees (25 or $33). This might seem insignificant in the 'first world', where every teenager runs around with a $700 iPhone in their pockets, but will make a huge impact in the third world. In this article I'd like to talk about the reasons why we have focused on breaking the price barrier, and about the choices in architecture that we made to facilitate this.

While internet is a commodity for most readers of this article, this is not the case for the majority of people on this planet. At the moment of writing an astonishing 4.2 billion people do not have access to the greatest source of information that humankind has ever created. There are more people that do not have access to the internet, than those who do. One of the main goals (for me *the* main goal) of Firefox OS is to change this.

Working as an evangelist for Telenor, a telco that has a number of subsidiaries in poor countries, this directly affects me. I have the opportunity to travel to a lot of these places, and the thing that strikes me the most every time I'm down in South-East Asia is the curiosity and willing to learn that people show. Every time we host a seminar, a training session or a Firefox OS app day there are 5 times more people that sign up than that we have room for. We have not even launched in Bangladesh and there are over a hundred apps in the Firefox OS marketplace already. It's astonishing.

For me this is the ultimate proof that the biggest difference between us, the Silicon Valley induced Hacker News crowd, and them is just plain simple opportunity. Internet is the way to level that playing field. With internet everyone has access to the best education programs; health care information; and communication channels. And on top of that it allows people to sell their product to the global market. Internet is going to have a direct impact on the lives of these 4.2 billion people.

The foundation

To accommodate these goals Firefox OS is built on two pillars. First: be able to run on the lowest hardware possible, because cost is a big factor. And second: put the open web first, as there is ten thousand times more information available on the web than in app stores.
Optimizing a phone to run the web as fast as possible on cheap hardware means that some interesting changes are made in the architecture of the OS. When you want to view a web page on Windows or on Android you'll do this through a browser like Mozilla Firefox or Google Chrome. The browser then runs on top of the operating system (Windows, Android, etc.), the operating system then runs on top of the hardware.

That means that running a web page will always be slower than running a native application on these operating systems, because it has one less layer of abstraction (App -> OS -> Hardware, versus Web Page -> Browser -> OS -> Hardware). But Firefox OS takes a new approach. Web pages should run as fast as possible, so the OS layer that sits between the browser and the hardware is just a factor that slows that down.

When you are designing an OS from the ground up you can change the way this works. Firefox OS takes a new approach, where there is no separate OS layer and the browser runs directly on top of the hardware. That way the heavy step in between is gone and we have a cheap and fast web browser on a mobile device.

This approach has one big drawback. The OS layer contains a lot of useful stuff that is not present in the browser. For example access to hardware sensors, the ability to place a phone call, and access to the SD card. Those features are not included in the browser. To make up for this, Mozilla added new JavaScript APIs to the browser that allow you to access all these things. This means that you can now write some JavaScript to place a phone call.

JavaScript:
1
2
3
4
var call = navigator.mozTelephony.dial('+1555332134'); // #a
call.addEventListener('connected', function() { // #b
  call.hangUp(); // #c
});

Here the API to make phone calls is located under navigator.mozTelephony. This API has a moz prefix because other browser vendors have not agreed upon the API yet. We can call the dial function to initiate a phone call (#a). The API returns a standard JavaScript object where we can attach event listeners. In this case we wait for the call to be connected (the other party picks up the phone #b), and instantly hang up (#c). This gives us the opportunity to interact with real life, straight from JavaScript!

The web is great

Now the ability to place a phone call from JavaScript might seem trivial but it's actually a big deal. Developers love building for the web. The web is open by nature; there is no gatekeeper or app store that puts restrictions on what you do. You are free to publish what you want, and when you want. And your applications are also available instantly, no need to install applications locally, and available on every device with a web browser.

But seen from the users perspective, mobile web applications often give a sub par experience, because the web is lacking some very important features. When people want mobile apps they don't want desktop apps scaled down to work on a smaller screen. They want apps that are a lengthening piece of their own lives.

Some examples, Shazam can detect which song you're listening to by using the microphone in your phone. Fitness trackers use the accelerometer to detect if you're walking or biking. News apps send push messages when breaking news happens. These are all apps that are impossible to build on the mobile web. Until now.

Because Firefox OS adds new APIs for all the features in your phone, you can create web applications that leverage all these new techniques. And for the first time you can write mobile web apps that have the same functionality as native apps. And it doesn't stop at sensors, there are facilities for dealing with the SD card, push notifications, offline, etc.

STANDARDIZATION

And because Firefox OS is in essence nothing more than a browser running on hardware, these new features are implemented in the Firefox browser. A lot of these new APIs will therefore also come to Firefox for Android. And that's just the start. The goal of Firefox OS is to make the web a better place, so other browser vendors are encouraged to also implement these new features.

Therefore, it proposed all new APIs to the W3C (World Wide Web Consortium), the main standards organization for the web. W3C members include browser vendors, big Internet companies, governments, and non-profits.

The benefit of going through W3C is that vendors have a say in the choices Mozilla made and in the APIs it had implemented. W3C acceptance is very important and indicates a strong chance other browser and OS vendors will implement the API as well. If that happens it will also be possible to use phone-specific features on those platforms using one standard API. This is the reason one web site will work on all web browsers.

Standardization of new APIs does not happen overnight though, as people will use them as soon as they're available. Because of that it is important to get consensus across all vendors, as it's almost impossible to change an API. But there already has been progress. For example, the W3C has accepted the API to vibrate the phone and the API to show notifications in the OS. And now they work in Chrome for Android as well. And that makes the web as a whole a stronger alternative to native.

More information

If you'd like to learn more about the architecture of Firefox OS, how we do process isolation, and how we route SMS from HTML all the way down to hardware, check out my talk at Simonyi Konferencia.

For information on how to create applications for Firefox OS you can get my book (remember 'dotd082714au'), or watch the free video series me, Sergi Mansilla and Christian Heilmann made called App Basics for Firefox OS.

Volgende: I wrote a book: Firefox OS in Action 29-07 I wrote a book: Firefox OS in Action

Comments


By Tweakers user MittaM, Wednesday 27 August 2014 10:31

Great article and Firefox OS sounds promising. However one question arrises how do you handle applications that have allot of data and need to work offline? I noticed articles online mentioning the HTML5 local storage. But what I always heard is that this storage is rather limited. Will you be able to store an a part of your application local on the phone? And run it from there using the webstandards?

Okay that where multiple questions but you get the point :)

By Tweakers user creator1988, Wednesday 27 August 2014 10:45

MittaM wrote on Wednesday 27 August 2014 @ 10:31:
Great article and Firefox OS sounds promising. However one question arrises how do you handle applications that have allot of data and need to work offline? I noticed articles online mentioning the HTML5 local storage. But what I always heard is that this storage is rather limited. Will you be able to store an a part of your application local on the phone? And run it from there using the webstandards?

Okay that where multiple questions but you get the point :)
You can use indexedDB and localStorage which can have elevated permissions through the Firefox OS manifest file to store more data than the default limit (50MB I guess?). Or you can use the currently non-standard Device Storage API to store data on the SD card.

By Tweakers user i-chat, Wednesday 27 August 2014 11:26

but if javascript is so common, and any webserver can become a host for a firefox aplication what wil protectie met from... banner linclusions that for example send text messages to verry verry expensive messaging services...

at its being hard enought on andriod and the likes to save yourself from sutch how would you do it if its all over the place...

how long will it take befor 'redtube' will host a fake dialer banner or two...

[Comment edited on Wednesday 27 August 2014 11:28]


By rsaxvc, Wednesday 27 August 2014 14:28

Firefox OS certainly seems to have an OS. Perhaps you mean it isn't running on top of android?

By Tweakers user Qwerty-273, Wednesday 27 August 2014 16:36

@rsaxvc, if you read your link correctly, Gonk is indeed the OS, while Gecko is the browser. However since both Gonk and Gecko are developed by the Firefox OS project, they integrate much tighter than lets say Gecko on Windows or Mac OS X. Hence also the term "Boot to Gecko", which means you boot into your "browser" instead of "OS" as you do on Android.
"For example, Gecko has direct access to the full telephony stack and display frame buffer on Gonk, but doesn't have this access on any other operating system."

By Tweakers user Punkie, Monday 01 September 2014 13:14

I am totally missing why a 25 euro phone would have such an impact on the connectivity. Sure, noone can argue that lower price means more ppl can get their hands on it. But when they *have* it, then what? The montly subscription bill of mobile internet access is, at my place, is also 25 euro and you need both to actually do something. Even if you manage to get online for 10 euro a month, it means that over the phones probable lifetime of 2 years, the cost of the phone is only 10% of the total cost. Slashing the phone's price in half would only yield 5% less cost.

I suppose this excerpt is missing a load of necessary information if you actually want to inform people.

By Tweakers user creator1988, Monday 01 September 2014 17:03

Punkie wrote on Monday 01 September 2014 @ 13:14:
I am totally missing why a 25 euro phone would have such an impact on the connectivity. Sure, noone can argue that lower price means more ppl can get their hands on it. But when they *have* it, then what? The montly subscription bill of mobile internet access is, at my place, is also 25 euro and you need both to actually do something. Even if you manage to get online for 10 euro a month, it means that over the phones probable lifetime of 2 years, the cost of the phone is only 10% of the total cost. Slashing the phone's price in half would only yield 5% less cost.

I suppose this excerpt is missing a load of necessary information if you actually want to inform people.
I picked up a prepaid SIM card on the streets of Dhaka with 1GB of data for 1 euro (incl. SIM). Recharging is even cheaper.

Comment form
(required)
(required, but will not be displayed)
(optional)

Please enter the code from the image below: