Google does fractals in HTML5
Take a break with Julia and Mandelbrot
Regcast training : Hyper-V 3.0, VM high availability and disaster recovery
Fractals. They're porn for techies. Well, truth be told, porn is porn for techies. But fractals aren't far behind.
Fractals are far more interesting, at least in the long run. And you can look at fractals at the office without worrying if the boss will walk by.
If you're a techie, it's time you visited Google Labs project that uses the browser to render fractal images describing various Julia and Mandelbrot sets.
According to a blog post from Google software engineer Daniel Wolf, the fractal renderer is coded in HTML5 using the Google Maps API to allow you to zoom in and out on a fractal image and pan around the image as well.

The images described by the Julia and Mandelbrot sets, which you can play around with here, are calculated using JavaScript, and you can change the color palette to mess around with how the fractals are painted.

"Generating these images requires heavy computation resources," explains Wolf in his blog post. "Modern browsers have optimized JavaScript execution up to the point where it is now possible to render in a browser fractals like Julia sets almost instantly."

Wolf says that rendering each fractal image in the browser takes millions of floating point operations, and uses the Web Workers API, which allows for the JavaScript processing to spawn multiple and parallel rendering calculations to speed up the painting of each fractal image. The Web Workers API can also spread the rendering work over multiple cores and threads in a machine.
The images in this story were rendered on a single-socket workstation with a 2.27 GHz Xeon E5507 processor, 6 GB of memory, and an AMD FirePro V4800 graphics card. This machine is rated at a 7.0 on the Windows experience index, and it is running Windows 7 Professional 64-Bit and Google Chrome 9.0.597.84. As best as I can figure, the Google browser fractal generator is not using OpenGL and doing calculations on that graphics card. It didn't matter. They rendered in about a second.
And once again, raise a coffee mug to Benoit Mandelbrot, who used computers to render fractal images and popularized them and who died back in October.
Now get back to work. ®
COMMENTS
Been there, done that
I once coded the Mandelbrot algorithm in Postscript. I wasn't very popular when I hogged the department's Laserwriter for over 24 hours just to print one page!
Oh grief
Alright, I might be ancient, but why does the IT world have to keep re-inventing ways of doing things and making them slower. There'll now be a whole generation of youngsters growing up thinking that Javascript is the way to do high speed calculations. What Boll***s.
>and uses the Web Workers API, which allows for the JavaScript processing to spawn multiple and parallel rendering calculations to speed up the painting of each fractal image. The Web Workers API can also spread the rendering work over multiple cores and threads in a machine.
Woo-fu****g-hoo. This is a perfect example of how laziness breeds complexity and inefficiency. Fractal generation generally consists of one for loop executed inside another, covering each pixel on the screen, with no inter-iteration dependency. Yes, you can separate them out over different cores for speed using Web Workers, but why bother? Do a bit of reading and discover decent C/C++ compilers like the ones from Intel and Sun (maybe even GCC these days). These will both spot such loops for you and do the same thing with threads at run time without you ever having to think about it in your coding. And it will probably run significantly quicker as well. And that's before you start contemplating bending it to fit on a GPU.
Okay, so this is just an eye candy demo of no major consequence. But to say:
"Modern browsers have optimized JavaScript execution up to the point where it is now possible to render in a browser fractals like Julia sets almost instantly."
and so pushing browsers as a suitable platform for heavy duty work is doing the world a massive disservice. For the sake of your office's and data centre's electricity bill and equipment inventory, plan on avoiding web stuff like Ruby, Javascript, PHP etc. Twitter had to abandon Ruby for the slightly better SCALA, and Facebook had to invent a PHP compiler just to stay alive in the face of expansion costs. Continued expansion will put huge pressure on those stop gap measures in due course.
The only benefits of Ruby, PHP, and other such languages is that they provide rapid development enabling a service to be brought to market quicker. The labour costs are cheap too. That is an important commercial consideration. But if your service expands and your electricity and inventory bills start heading in to the millions (or billions if you've been very successful indeed), the costs of that initial laziness start looking very high indeed.
Javascript, being generally a client side language, just pushes the costs out to the clients, and that's their electricity bill. But it is also probably their battery these days. There are real benefits to be had on the client side to having a properly written natively compiled app that makes the absolute best use of the CPU. Battery technology is not making useful advances any more, and the abundance of smart portable devices makes the issue more important. Better to have a native app that downloads minimal data from a server than having to download the app, JIT compile it, and get the data too. Imagine a Javascript word processor; the javascript code is likely to take far longer to download over the client's expensive 3G link than the actual document they want to edit.
Of course many web traditionalists point to their great saviour, the JIT compiler. Sure, a JIT compiler does produce executable object code which runs modestly quickly. But CPUs are complicated beasts these days with pipelines, caches, etc. I'd put good money on most JIT compiler's object code not being as fast as that produced by, for example, Intel's native compiler. Intel build the chips. The writers of TraceMonkey, V8, etc. didn't. If your JIT compiler is 5% less efficient than a natively written app, for a really big data centre that could amount to millions in electricity and inventory bills a year, every year . You have to wonder how much properly written native application code you could get written for that much money.
Re: Wow!
You don't get it, do you, it's a proof of concept of the technology. No one *needs* a Mandelbrot set program, so it might as well be written in HTML5 as anything else. It's the graphical equivalent of a "Hello, world!" program.

IT infrastructure monitoring strategies
Agentless Backup is Not a Myth
Top 10 SIEM implementer’s checklist
Steps to Take Before Choosing a Business Continuity Partner
Enabling efficient data center monitoring