With the Web becoming the default development platform, we are witnessing major innovations in browser technology. In the spirit of time, Opera has announced plans for “the fastest JavaScript engine on the market” code named Carakan and Apple has released Safari 4 in public beta with several new features and improvements.
One of the major technical improvements of the Caracan VM over Opera’s older engine Futhark, is the fact that it doesn’t use a stack-based bytecode instruction set anymore but rather a register-based:
In the new engine, we’ve instead opted for a register-based bytecode instruction set. In a register-based machine, instead of a dynamically sized stack of values, there’s a fixed size block of them, called “registers”. Instead of only looking at the values at the top of the stack, each instruction can access any register. Since there is no need to copy values to and from the top of the stack to work on them, fewer instructions need to be executed, and less data needs to be copied.
Caracan will also support native code generation:
Although our new engine’s bytecode instruction set permits the implementation of a significantly faster bytecode execution engine, there is still significant overhead involved in executing simple ECMAScript code, such as loops performing integer arithmetics, in a bytecode interpreter. To get rid of this overhead we are implementing compilation of whole or parts of ECMAScript programs and functions into native code.
Another area of improvement is in the representation of JavaScript objects:
In the new engine, each object is assigned a class that collects various information about the object, such as its prototype and the order and names of some or all of its properties. Class assignment is naturally very dynamic, since ECMAScript is a very dynamic language, but it is organized such that objects with the same prototype and the same set of properties are assigned the same class.
This representation allows compact storage of individual objects, since most of the complicated structures representing the object’s properties are stored in the class, where they are shared with all other objects with the same class. In real-world programs with many objects of the same classes, this can save significant amounts of memory.
Opera claims that with these enhancements Caracan is currently 2.5 times faster than the engine which is featured in Opera 10 Alpha. With no release date yet, it will be interesting to see if these improvements will boost the popularity of the Opera browser, whose market share for January 2009 was 0,70% according to NetApplications.
On the other side of the river, Apple has released Safari 4 beta which also features a new JavaScript Engine named Nitro:
Using the new Nitro Engine, for example, Safari executes JavaScript up to 30 times faster than Internet Explorer 7 and more than 3 times faster than Firefox 3 based on performance in leading industry benchmark tests: iBench and SunSpider.
This new version of Safari supports several advanced and new technologies like:
- CSS Animations
- CSS Effects
- CSS 3 Web Fonts
- CSS Canvas
- HTML 5 Media Support
- HTML 5 Offline Support
- Acid 3 Compliance (the only browser to pass the test)
- Speculative Loading
Safari also comes with several new features and UI improvements like:
- Tabs on Top
- Cover Flow
- Full History Search
- Windows Native Look and Feel
- Smart Address Field
- Full-Page Zoom
- Smart Search Field
- Phishing and Malware Protection
For more information on how to leverage these new features in the development of applications both for the desktop and the mobile version of Safari, you can visit Apple’s Safari Dev Center.
Paul Stamatiou has been spending some quality time with the new beta and is sharing his thoughts:
If this were a real review and I were to bestow Safari 4 beta with a Stammy rating, it would come in at around 6.5-7 out of 10 with emphasis on its stability and speed. So what’s Safari 4 good for? Browsing the web, not tweaking it. Let’s not forget that Safari is the king of private browsing mode *wink wink*… well not for long, Firefox 3.1 gets native support for that too.
If you’re using Safari 4 Beta take a look at some of the hidden preferences (OS X only), such as putting the tab bar back where it belongs.
With all major browser vendors doing separate work to improve their engines, Dion Almaer wonders if it would be better for them to collaborate:
Nice to see, and interesting that the browsers aren’t (or aren’t able too?) share their VM work. Each browser has a new VM implementation going. Wouldn’t it be nice if they could share effort?
Iliad replied to Dion question:
If they share the VM engines, there’s no competition, and less incentive to push for better and faster implementations. This way they keep trying to outdo each other - and that’s good.
You can find more information about Browsers, JavaScript and Rich Internet Applications right here on InfoQ.