Monday, 27 December 2010

WebGL and HTML5, Can They Replace Desktop Applications?

In short the answer is yes. They can replace a lot of Flash usages, Flex.
Can you rewrite a NaroCAD-like application? The main blocks appear to be there: GWT is a Java framework that makes possible to create your own controls in your browser.
Also, WebGL is enabled by default in nightly builds of the recent browsers (excluding IE9 line and Opera for now). You can see a nice demo here.
But the hardest problems are things that NaroCAD do for free: fast undo/redo logic: we depend on reflection for it, even the logic can be simplified based on VM reflection. Another problem is tooling: we have from time to time performance problems as bugs occur, but we do have tools for it, I tend to use the great visual profiler of SharpDevelop, if you don't want to use a commercial one.
Another reason is just how WebGL demo shows: 10 year old graphics, performance is good, still a bit too slow (on my fairly powerful machine: i5 CPU, 330M graphics, some G of RAM and 1G VRAM). So if you will want responsive for more than just validating forms, it will be hard to spot: you have to test with almost all rutimes.
At the end the problem is on the big picture: developing with GWT, you will have like slow disk, slow performance for anything that your JS engine will excel (FF for mathematical loops, Chrome for OOP object).
So in short the answer for NaroCAD to be implemented in a web technology: changing logic to do some dispatch type logic, changing shape creation (the entire OpenCascade logic) to use JavaScript, will create a slow version of what is NaroCAD (or any other CAD on market). Can we seee something more in time? Probably as Silverlight plugins, or as web applets, without them, I'm not sure will be ever something possible.
In fact NaroCAD uses Generics in a way that even porting to Java or to C++ is fairly hard, as is combined with reflection, and C++ have better generics (templates) but no reflection, when Java have great reflection but bad generics.
So what are options to extend NaroCAD using more "open" languages. a language similar with Python we use already (Boo) which can be used to do scripting, but you can write an entire plugin if needed using SharpDevelop. I also found a lot of paradigms like functional one (F#), IronPython or IronRuby can be used with a small wrapper, UnityScript for people that like JS syntax.
Which is the main advantage of using .Net at the end? You will get a responsive application from top to bottom, and if you still have bottlenecks that you find that .Net does not generate a code as good as you want, you can call your C/C++ optimized code using P/Invoke. If you want to do the same for a web application, you're stuck with the version of your JavaScript machine implementation.

No comments:

Post a Comment