Saturday, 16 February 2013

Why John Gruber is wrong about WebKit, Mozilla and Opera

John Gruber, of Daring Fireball fame, has recently commented on Opera's decision to switch to the WebKit rendering engine in place of Opera's proprietary Presto rendering engine. Some of his commentary has missed the mark. WebKit has not yet won the war. Even suggesting that the current healthy level of competition in the web browser market is a fight to the bitter end where one browser will emerge victorious is a dangerous misconception. It harks back to the bad old days of a decade ago where Microsoft's Internet Explorer had supplanted Netscape's Navigator as the predominant web browser. The early 2000's were a bad time for web browser innovation. The majority of websites were tested for Internet Explorer 6 compatibility only. Web developers made use of proprietary Microsoft extensions to HTML and JavaScript and payed scant attention to following web standards. I remember being terribly excited to hear about the development of a new open source web browser, Firefox, based upon the legacy of Netscape. Firefox was backed by Mozilla, a new not profit organization formed specifically to promote web technolgies. Firefox was a breath of fresh air back in those dark times for the web. I started using it at about version 0.6 or 0.7. Tabbed browsing, whilst pioneered by Opera, was such an awesome feature in comparision to the inconvenience of opening a new window for each site you wanted to remain open.

The rise of the Gecko rendering engine and WebKit in the guise of Apple's Safari and most recently Google's Chrome in the past decade has been a great thing for the advancement of web standards and exciting new features. JavaScript engine performance has advanced in leaps and bounds. From humble beginnings where Brendan Eich rushed to create a scripting language for use in Netscape, inspired by the Scheme and Self languages, although married to a C-like syntax, JavaScript has grown to be the most used programming language on Earth. Obviously it has many flaws but as put by Douglas Crokford in his classic JavaScript: The Good Parts, some of the core functional ideas in the language make for a simple, elegant and expressive programming language. The SpiderMonkey JavaScript engine created by Mozilla was for years a bytecode interpreted language, making for slow performance when executing computationally demanding web applications. The competition created first by Apple's SquirrelFish JavaScript engine, and later by its successor Nitro, and Google's V8 engine has resulted in a much better performance landscape today. And it's not over by a long shot.

As an interesting aside, things have come full circle in a funny way. The Self language was created by Sun as a research project. Self is a dynamically typed, message passing language similar in ways to SmallTalk. Much research effort was put into creating a performant execution engine for the language. Java's HotSpot engine is derived in part from the techniques used in Self's engine. Some super clever things were done to identify the types of objects and their constituent fields at runtime and to dynamically create class definitions for these instances. This let the runtime create type driven dispatch tables at callsites to jump to type-specific implementations of functions operating on the instances. With Nitro and V8, Apple and Google pioneered compiling JavaScript functions directly to assembly instead of first interpreting bytecode. Later Mozilla was driven to add similar features to its latest generation of JavaScript engine, IonMonkey. JavaScript engines are an example of how healthy competition between web browser implementations have driven forward both innovation and performance. If any one browser were to become predominant, there is the distinct possibility that they would sit on their laurels as did Microsoft and that the web browser market would become stagnant.

A second point in rebuttal of John Gruber's claims is the difference in nature between Mozilla as an organization and Apple and Google. Mozilla is a non-profit whose sole goal is the advocacy of web standards and technologies. They are not driven by commercial goals as are Apple and Google. They do a lot of good work in the area of developer education and have built up a strong community of followers who believe in the importance of advancing the web as an open platform that accessible to all. Whilst Firefox continues to improve in performance, it also continues to expand onto new platforms. Firefox OS will launch in Brazil later this year and for many it will be their first experience of the web. iPhones are extremely expensive in Brazil and Firefox OS phones will will priced and specced to be affordable. Think of how exciting an experience it was to use your smartphone for the first time. Now Mozilla will be helping bring that experience and all the benefits that derive from it to people for whom the experience would otherwise be unavailable.

I've talked for long enough. I hope that this article might shine some light on how important it is to continue to have a healthy competition in the browser market.