JavaScript V8

 
 
By Jeff Cogswell  |  Posted 2008-09-10 Email Print this article Print
 
 
 
 
 
 
 


JavaScript Engine: V8

Chrome sports a new JavaScript engine called V8. V8 is an open-source project that was developed by one of Google's development teams in Denmark. (You can download and compile V8; I did just to try it out. I built it with Visual Studio 2008, and it compiled just fine, and I was able to start up the command-line sample application. You can get it here.)

The V8 engine has an interesting history. During the short time I had to write this article, I was able to find a few facts, but by no means a complete history. The engine was worked on by people who came from two diverse groups that ultimately came together at Sun. One group at Sun was working on a rather powerful virtual machine for a language called Self. The other group was working on a Smalltalk implementation called Strongtalk. The Self group developed a technology that uses nested inlines, which sounds scary, but in fact allows for heavy optimization. The end result was a Smalltalk implementation that was powerful-but one that never saw the light of day. As we all know, Smalltalk hasn't exactly taken the world by storm. Ultimately, Sun released the product to the open-source world. And Google apparently hired (at least) one of the Self team experts to help resurrect parts of the system and build a JavaScript virtual machine. And this virtual machine is called V8.

V8 ultimately has little in common with the original Self and Strongtalk systems, but it is built on some core, proven pieces, including an assembler. The end result is that V8 can compile JavaScript into native code that runs within a virtual machine that even implements optimized garbage collection (including incremental pointers and the like) and multithreaded processing. That's pretty cool if you ask me. And that's far more than just a scripting language; it's a full runtime.

And incidentally, V8 also makes use of a third-party, open-source library called JSCRE, which is a JavaScript-adapted version of the classic PCRE Perl-style regular expressions library.

(If you want to know more about V8, download the source code and just look at the names of the files. You'll see names like assembler-ia32.cc, assembler-arm.cc, codegen-ia32.cc, codegen-arm.cc, compiler.cc, v8threads.cc, macro-assembler-ia32.cc, and others that are indicative of the many features of the architeture. And if you're really interested, you can open up the source code and look at it in detail. The file objects.cc is pretty fascinating to look at.)

JavaScript: For Developers

I'll be talking more about this in future articles, but for now I'll point out that Chrome has built right into it several tools to assist Web developers.

For starters, Chrome includes a full JavaScript console, as shown here:

Figure 3. Chrome's JavaScript console.

 

There's also a JavaScript debugger. I haven't yet worked with this, although it looks somewhat rudimentary. (But I should qualify this: I only looked at it briefly, so I could be wrong. Or, if I'm right, perhaps that's because this is still a beta version of Chrome. More on this in my next article on Chrome development.) Here's a screenshot:

Figure 4. Chrome's JavaScript debugger.

 



 
 
 
 
Jeff Cogswell is the author of Designing Highly Useable Software (http://www.amazon.com/dp/0782143016) among other books and is the owner/operator of CogsMedia Training and Consulting.Currently Jeff is a senior editor with Ziff Davis Enterprise. Prior to joining Ziff, he spent about 15 years as a software engineer, working on Windows and Unix systems, mastering C++, PHP, and ASP.NET development. He has written over a dozen books.
 
 
 
 
 
 
 

Submit a Comment

Loading Comments...
 
Manage your Newsletters: Login   Register My Newsletters























 
 
 
 
 
 
 
 
 
 
 
Rocket Fuel