News for hackers. Stuff that matters.
Re:Firefox OS devices officially released by mwcampbell on Tuesday July 09, 2013 @09:27AM (#6012522)
I love what Mozilla is trying to accomplish with Firefox OS. I hope it succeeds, and I don't want to be negative. But I'm not convinced about this part:

> Firefox OS offers the best cost-benefit ratio once you think about how much performance you have against your hardware specs. If you pick the same low-end hardware with Android or Firefox OS, Android will have a worse experience, not because Android is broken in any way, Android is great but because there are more things going on on Android than on Firefox OS. Firefox OS is just a tiny hal, gecko and gaia, while Android has a VM and lots of other things going on.

Let's look at some of the components that a modern mobile OS needs:

* Kernel

* Hardware abstraction layer

* OpenGL ES implementation and compositor

* 2D vector graphics API

* UI toolkit

Android and Firefox OS both also have a VM to run managed code, along with a JIT compiler. Android's VM, Dalvik, was specifically designed to be memory efficient in the case where several apps are running as separate Unix processes. Is the same true of SpiderMonkey?

So Android and Firefox OS share many of the same types of fundamental components, and in some cases, the same components (the kernel, some aspects of the HAL). But on top of this, Firefox OS and its apps add:

* Markup language processor and layout engine designed for hypertext documents, not UIs

* Parser for a poorly designed programming language (JS), and advanced JIT optimizations that in effect extract the latent static types from a dynamically typed language. By contrast, Dalvik accepts bytecode as input, and the program is already statically typed, so the JIT compiler can be much simpler

* Hacks on top to turn this combination of hypertext markup language and poorly designed programming language into a tolerable UI toolkit and application platform

So how can you say that Firefox OS is more resource-efficient than Android? Perhaps the Android platform developers have gotten sloppy lately, since they're primarily concerned about high-end phones. But that can be remedied. What matters is that, as far as I can tell, the Android platform was designed for efficiency, while the Web platform was not.

I hesitate to bash the Web platform, because for better or worse, it seems to be the best way of achieving Mozilla's mission, and I believe social ends outweigh technical means. But I believe I have accurately described the current reality.

Re:Firefox OS devices officially released by Yoric on Tuesday July 09, 2013 @10:10AM (#6012713)
> Android and Firefox OS both also have a VM to run managed code, along with a JIT compiler. Android's VM, Dalvik, was specifically designed to be memory efficient in the case where several apps are running as separate Unix processes. Is the same true of SpiderMonkey?

Short answer: yes, SpiderMonkey has been designed to be quite memory efficient.

> But on top of this, Firefox OS and its apps add:

Actually, let me clarify something, if not for you, then for our readers: "on top of this" means essentially "on top of the kernel and HAL," rather than "on top of Android."

> [valid points] So how can you say that Firefox OS is more resource-efficient than Android? Perhaps the Android platform developers have gotten sloppy lately, since they're primarily concerned about high-end phones. But that can be remedied.

All your technical points are valid. However, you have not taken into account the fact that Android is much larger than that not to mention, conceptually, very old. Just the Core Libraries, for instance, offer at least three or four ways of reading/writing files. Most of these APIs should be removed for the sake of performance, as they were based on Java 1.0 designs from the 1990s, a time at which industry believed that disk speed would keep improving as fast as CPU speed and that concurrency was too expensive to be used. But these APIs cannot be removed, simply because too much code depends upon them, both in Android itself and in applications that Google would not want to lose. Sadly, this means that all such code is a performance hog, especially on mobile devices, since mobile storage is horribly slow in comparison to PC storage.

Now, while I am less familiar with the rest of the architecture of Android, I seem to remember this is true of many features and that many features are accidentally implemented several times in the kernel, Dalvik, the libraries and/or the frameworks, in the interest of (partial) compatibility with Posix, Linux, J2SE, etc – and tutorials.

While it would theoretically be possible to get rid of all these inter-layer duplications, and to only keep the good APIs, this effectively means breaking too much of both Android itself and of many applications. Google cannot afford to do that, as they would risk driving away all developers and users. Moreover, Google does not need to do that, as Android has always been targeted towards high-end phones. A new operating system, by opposition, with everything to win and nothing to lose, can start from a blank state. Moreover, since Firefox OS offers only high-level APIs and no NDK-style access, it is easier and will remain easier for a number of years, to perform whichever low-level refactorings are necessary to improve performance and/or memory efficiency without breaking applications.

Note that this is almost the reverse of Chrome vs. Firefox. Firefox is burdened by the number of add-ons that need to be supported, and the low-level APIs provided to these add-ons, while Chrome, starting with a blank slate and restricted public APIs, managed to rise the stakes of performance quite harshly.

Re:Firefox OS devices officially released by mwcampbell on Tuesday July 09, 2013 @11:28AM (#6013142)
Your argument is quite plausible. Android has indeed accumulated several APIs: ANSI C, POSIX, various Khronos APIs (OpenGL ES, OpenMAX), a subset of J2SE, and Android APIs (both Java and native, with some overlap between the two). I can accept that offering only web APIs leaves much more room for streamlining the lower layers of the stack. Maybe a future Firefox OS phone will run a new processor that was specifically designed to execute JavaScript.

And perhaps my earlier point about HTML+CSS and web layout engines being designed for documents, not UIs, was too handwavy. One might argue that there is a sort of Greenspun's tenth rule of UI toolkits: Any sufficiently complex UI toolkit contains an ad hoc, informally specified, bug-ridden, slow implementation of half of HTML and CSS -- and then probably contains a full Web browsing engine, too.

It seems to me that the Web technology stack has plenty of inelegance of its own. But no platform is perfect. Maybe the Web platform, exposed to developers on its own without making the lower layers available, really is the best we've got.

Can you explain why you think the Java storage APIs are ill-suited to mobile devices?

Re:Firefox OS devices officially released by Yoric on Tuesday July 09, 2013 @04:28PM (#6015211)
> Maybe a future Firefox OS phone will run a new processor that was specifically designed to execute JavaScript.

I haven't heard of any such plans, but that would be fun. Ah, the good (?) old days of the Lisp machine...

> Any sufficiently complex UI toolkit contains an ad hoc, informally specified, bug-ridden, slow implementation of half of HTML and CSS -- and then probably contains a full Web browsing engine, too.

Let it be said that the Mwcampbell Law was first enunciated on Hacker News on the Ninth of July, 2013.

> Can you explain why you think the Java storage APIs are ill-suited to mobile devices?

Generally, it's a set of simple things. The File API, for instance, should forbid execution of any I/O call on the UI thread, or on any high-priority thread, as the duration of any I/O call is unbounded (Dalvik can be executed in a "strict mode" that prevents I/O calls on the UI thread, which is good, unfortunately that's not the default mode).

Also, the default manner of doing any copy with the File API is a read/write loop, which is very inefficient in terms of memory copies, especially when Linux offers in-kernel copy.

etc.

Re:Firefox OS devices officially released by lbenes on Tuesday July 09, 2013 @04:12PM (#6015087)
No, they are not plausible. The whole idea of using HTML, CSS, and JavaScript as the back end technology for a low-end smartphone is nuts. Even the best HTML rendering engines are CPU and memory hogs. CSS was never designed for and is nearly impossible to hardware accelerate, and JavaScript is notoriously difficult to optimize and even the best VMs run orders 3-10x slower than native code, while the JS VM takes up much more memory than the efficient dalvik.

All the early reviews of Firefox OS describe it as laggy and slow. For example this one from the verge: "Lag is a major concern — apps took multiple seconds to load, to change toggles, and to make UI transitions"[1]

Or this one from CNET: "unresponsive screen makes typing a laborious process requiring painstaking precision. Every action from swiping to tapping onscreen controls takes a beat until you see results, so using the phone for a prolonged period steals minutes of your time... Lag carries into the camera, which is slow to launch, snap, and reset."[2]

>"designed for documents, not UIs, was too handwavy" Not for anyone who's had to work with DOM for Web apps. We know all too well as its name suggests that it was never designed for apps and is well past its expiration date.

My 3yr old similarly spec'd SGS runs CM 10, Jellybean like a champ. My mom's worse spec'd 3GS is still smooth and fluid. Of course, a low end Android phone running the most resource intensive skin, TouchWiz, is going to perform poorly, but in my experience vanilla AOSP scales down quite nicely on low-end hardware.

So how does this phone benefit Joe User? It's an android kernel, but the user is cut off of the diverse android app ecosystem. The performance looks terrible, and the user is locked into the Firefox browser, like Safari on iOS.

[1]http://www.theverge.com/2013/2/24/4024530/ztes-open-is-the-f...

[2]http://reviews.cnet.com/smartphones/geeksphone-keon/4505-645...

Re:Firefox OS devices officially released by glogla on Wednesday July 10, 2013 @06:09AM (#6018436)
That's not all that surprising. IPhone 3GS and Samsung Galasy X had launch prices four to five times higher than the phones you are talking about. Of course they are faster, the same way that old BMW M5 is faster than new Ford Fiesta.

But that's not the point. FFOS can't really offer that much to rich people in US or Western Europe where iPhones grow on trees and streets are paved with high-end Android phones. It is not supposed to compete with the next iPhone or Nexus, but with the next Nokia Asha, cheap Bada phone or the next cheap ZTE, Alcatel or Huawei Android phone that is still sold with Android 2.3.

Re:Firefox OS devices officially released by Yoric on Wednesday July 10, 2013 @06:40AM (#6018537)
I'm guilty of handwavy explanation, so I will try and get back to concrete cases.

The reviews by CNet and The Verge were accurate a long time ago – given the date, CNet's review was done with an early beta, and I have no clue about the date at which The Verge's review was done, but I suspect that the review was published long after the actual review. I have seen the speed of my phone increase considerably since then, both when I was running 1.0.x and now that I'm running 1.1.x.

If you want to know for yourself the actual performance of a FirefoxOS phone, the only way is certainly to get your hands on one. My personal experience is that, comparing with equivalently-spec'd unmodified Android phones, my FirefoxOS phone runs absolutely great. I have not attempted to compare with Cyanogen-ed phones.

> The user is locked into the Firefox browser, like Safari on iOS.

Actually, with effort, it should be possible to port WebKit/KHTML or any other rendering engine to FirefoxOS, e.g. by using Emscripten or Mandreel. Of course, this port will have to use the platform's display API (typically, Gecko's implementation of <canvas>) and the platform's VM, so the benefit might be limited. But if somebody considers this useful or fun, please, by all means, do port any other browser to FirefoxOS, we will be glad to help you.

That's not quite the answer you would get from Apple if you wanted to port Firefox or old-generation Opera Mobile (not Turbo) to iOS.

> So how does this phone benefit Joe User? It's an android kernel, but the user is cut off of the diverse android app ecosystem.

Several comments have already provided an answer to that question. I will try and sum up a few of them quickly:

- all your private data doesn't belong by default to some company; - the Mozilla community has proved time and time again how it is able to provide applications localized for regions/minorities that big companies simply ignore, and I expect that this will also be the case for FirefoxOS phones; - payment APIs implementations are adapted to local markets, i.e. in countries where people typically don't have a credit card, they do not have to use one if they wish to buy an application; - users are even more free from the Marketplace than on Android - I expect that this means we'll soon see numerous marketplaces specialized in local interests (e.g. Venezuelian marketplaces, Catalan marketplaces, but also a company's internal marketplace, etc.), or in application domains (e.g. Gaming, e-books, adult stuff, safe-for-kids stuff, etc.); - cheaper phones through higher-performance on entry-level hardware – recall that, in Spain, the phone is sold at 69€ including 30€ prepaid communications, without contract; - no vendor lock-in – if you change phone or if you use your desktop computer, your applications follow you; - breaking monopolies in regions in which you have the choice between a feature phone or a 600$ smartphone + contract.

I realize that people following Hacker News are no Joe Users and that they often have access to technologies that Joe User hasn't even heard about, both in terms of hardware and in terms of software (e.g. Cyanogen). But this first generation of FirefoxOS phones is not designed with them in mind. It is designed primarily for Joe "I'm ignored because my region or my language is not fashionable or rich enough" User.

Re:Firefox OS devices officially released by glogla on Tuesday July 09, 2013 @12:34PM (#6013522)
I appears that new project starting from clean slate, and being able to use newest research and learn from mistakes of others, and therefore being better than the original project, is a pretty common pattern.

For example, see LLVM and GCC. LLVM is better compiler simply because it has much less legacy code to understand, maintain and support, less platforms, and mostly because it's twenty or more years younger. Similar thing can be stated about screen and tmux, apache and nginx, X and of course wayland (the whole point of Wayland is to do just this), and perhaps other tools.

While this may look sad, it shows, that despite the fact that everyone is still using algorithms from the 60's to find shortest path in a graph (1) it shows that our field is evolving. And that's a good thing.

(1): at least I hope. If there's a new one, please tell me!

Re:Firefox OS devices officially released by Ygg2 on Tuesday July 09, 2013 @01:12PM (#6013796)
(1) There is a modification of A * star. It's called A * jump point search.

http://harablog.wordpress.com/2011/09/07/jump-point-search/

Re:Firefox OS devices officially released by soapdog on Tuesday July 09, 2013 @10:01AM (#6012671)
mwcampbell,

Thanks for your reply. =D

In the high-end market, it doesn't matter, everyone is good. In the low-end market, Firefox OS has better performance than Android.

From a high level analysis, your comment appears spot on but unfortunately it is not that simple. Dalvik VM is GREAt and we all know the bad parts of JS. The problem is that there is a lot going on on android phones. Its not as if there is only Dalvik and your app. In Firefox OS Gecko is so close to the hardware that it doesn't need to go thru hops. Firefox OS can be said to be nothing but a browser running on bare metal. Android is not slow, but on low-end hardware it is not as responsive as it should be. Pick a Galaxy Ace for example, its specs are similar to ZTE Open (ZTE Open has better specs) and the price is similar but the experience is much better and more responsive on ZTE Open.

Dalvik was created to be efficient, and it is. My comment is not about Dalvik being bad, it is not. Its about low end phones running android offering a bad experience. I don't know if you ever used those phones or if you ever tried a Firefox OS phone.

> Hacks on top to turn this combination of hypertext markup language and poorly designed programming language into a tolerable UI toolkit and application platform

HTML evolved. The current standards and practices are pretty good. Check out new JS proposals, the language is evolving and becoming better. While you may perceive the combination of HTML/CSS/JS as something horrible, others like it. Check out enyojs at http://enyojs.com for example, it is a great framework for app development that shows the potential for pure web based solutions.

As you said:

> What matters is that, as far as I can tell, the Android platform was designed for efficiency, while the Web platform was not.

And yet, the web runs pretty well inside a browser in Android right? Even with all Android around it, open web apps running in a browser (when built correctly) do pretty great. Now remove Android and just leave the browser. Imagine how much complexity went away. How much CPU cycles and memory you saved if you have nothing but a web runtime.

We all agree that Android is a great platform. As I said, this is not an attack on Android. Firefox OS is a return to simplicity where you have just a web based architecture that is being optimized and refactored into a great mobile platform. We're not picking Desktop Firefox and shoehorning it into a mobile device. Firefox OS is being built for mobile.

You certainly know your tech and so I will leave you with an invitation. Android development is not open, Google releases new versions of Android when it wants to and then you see the source code. Even so, Android is hard to hack. On the other hand, Firefox OS is developed in the open. All source code, including whats is being worked on is live on github.

Better than me sprouting opinions and experiences here is for knowledgeable people such as you to check the code out. See how it is being built and how things work together. Help shape a better platform for everyone. Everyone is encouraged to contribute to Firefox OS. If you think SpiderMonkey (or IonMonkey or OdinMonkey) is slow, help improve it, we could all use some help! :D

https://github.com/mozilla-b2g/

As I said, one of the key thinks about Firefox OS is how open it is. Want to try to develop new features? Check out the repo, hack away and if it good enough, talk about a pull request on IRC.

If you want to check out the system without building it, pick the Firefox OS Simulator, it is just a add-on for Firefox at https://addons.mozilla.org/firefox/addon/firefox-os-simulato...

For example, you will notice that we use the Android kernel and parts of Android SDK tools such as adb and fastboot. The cool think about open source is that you can reuse the good bits and not use what you don't want to.

So I invite you to check out the platform. The web may appear badly designed and not build for performance but there are more and more people working on it and it just grows and surprises us. No one believed in JS for gaming until people saw the unreal engine running inside the browser without plugins. JS and its friends will keep improving and cross-plaform open solutions tend to win in the long run.

Re:Firefox OS devices officially released by Ygg2 on Tuesday July 09, 2013 @10:05AM (#6012685)
Your points aren't really strong either.

   > * Markup language processor and layout engine designed
       for hypertext documents, not UIs
Unlike XML which Andorid uses, right? I mean XML was made for designing arbitrary (potentially hyper-linked or linked) documents, no?

   > * Parser for a poorly designed programming language 
       and advanced JIT optimizations.
So are you talking Java or Javascript?! At this point it doesn't matter. Without doing any benchmarks and solid number crunching your claim is empty air.

This doesn't mean Firefox OS is more resource efficient than Android. Without benchmarks on same hardware neither can claim performance high ground.

Re:Firefox OS devices officially released by pjmlp on Tuesday July 09, 2013 @09:44AM (#6012590)
Plus all other mobile OS allow for the use of pure native code if you really need to go full performance, not so with FirefoxOS.