WebGL makes inroads into the browser for the foot soldiers of Biochemisty

06 Mar 2011 // protein

The future of the web, as everybody knows, is Javascript.

Okay, maybe not everybody knows this. But if you want an experimental glimpse of the future of the web, look no further than this tech preview from the guys at ChemDoodle (these guys are building up an impressive open-source graphics library ChemDoodleWeb that could open up whole realms of biochem programming). If you have the latest Chrome browser installed, you should see an interactive 3D model of Crambin:

Alas, if you have a different browser, you won't see anything :(. That's what I meant by experimental. However, all the major browsers have promised to bring this technology online in the next few months. If you have new Chrome, then you will notice that the protein viewer loads almost instantaneously. ChemDoodleWeb only uses programming elements intrinsic in the Chrome web browser, and nothing else. That's why it's so fast.

Why is this powerful? For years, if you wanted do something fancy on your website, you would have to rely on a plugin. For instance, the venerable protein viewer Jmol is written in Java, and to run Jmol, you have to install the Java Virtual Machine (JVM) plugin in your browser. This kind of dependency is troublesome on two fronts. First, installing the JVM can be a bitch, and using Jmol requires that you load both the JVM and Jmol itself, leading to excruciating loading times. Second, as Oracle has now bought out Sun (who built the JVM), users are running scared of the scorched-earth management of Oracle.

The technology that allows this is WebGL. WebGL defines a way of using javascript, the language built into all web-browsers, to access the OpenGL driver on your computer. OpenGL is the industry standard in talking to graphics drivers on computers to display 3D graphics (it's used in a whole bunch of FPS games). With OpenGL, you can write very high level graphics code, and let the OpenGL library handle all the low-level stuff, where the OpenGL library is able to reroute library calls to use dedicated graphics card circuitry.

In contrast, Jmol only uses the JVM, and has to re-implement all the low-level 3D graphics. So when you run Jmol on a browser on your very expensive work-station, your graphics card will sit idly by while the JVM in your browser is madly calculating all the 3D graphics rendering. Talk about unfulfilled potential.

But with WebGL, your native web javascript program tunnels straight through the browser to the graphics card to render 3D graphics. In theory, that is. The speed will depend on the maturity of the WebGL implementation. Still, the advantage is obvious already. The ChemDoodleWeb javascript code is very light and very high-level, as it lets the WebGL do all the heavy lifting. This lets the ChemDoodle guys focus on the interactive goodies so that you can have all the browser fun in the world.