- #1
lpetrich
- 988
- 180
Have any of you people tried writing math and physics demos that can be run in a web browser? The physics demos would have to be simulations, of course.
I myself have done so:
http://homepage.mac.com/lpetrich/Chatters/GeometryDemo_GMap.html - Spherical Delaunay triangulation, convex hull, Voronoi diagram. Yes, all in JavaScript, which I'd ported from my original in Python.
http://homepage.mac.com/lpetrich/ColorBlindnessSim/ColorBlindnessSim.html - has a standalone Java version and a version that you can load webpages into: http://homepage.mac.com/lpetrich/ColorBlindnessSim/WebpageCBSim.xhtml . These work by calculating new color-channel values for each pixel as functions of the original ones.
A page on http://homepage.mac.com/lpetrich/Science/Symmetries/Index.xhtml - a http://homepage.mac.com/lpetrich/Science/Symmetries/TwoDimPointGroupDemo.xhtml and an http://homepage.mac.com/lpetrich/Science/Symmetries/OrganismSymmetryDemo.xhtml .
My experiences:
One can do a surprising amount with JavaScript in a web browser these days. Its main downside, however, is that it's difficult to debug. alert() isn't a very good way to do logging, not nearly as good as writing to standard output or to a file.
One can do graphics in three ways:
The main downside is spotty browser support. I have the latest OSX versions of Firefox, Safari, Google Chrome, and Opera, and all of them support Canvas, and all but Opera support WebGL and inline SVG. However for Safari, WebGL must be enabled, though doing so is rather simple. I have no recent experience with a recent version of Microsoft Internet Explorer.
Windows, Linux, and various smartphone and tablet versions of these browsers likely have similar levels of support.
Control widgets?
HTML is rather limited in them, having only buttons, checkboxes, radio buttons, popup menus, lists, and text fields. However, there are various libraries available for creating additional widgets, like sliders and color pickers. On the plus side, you can attach functions to various actions, like mouse clicks, mouse drags, mousing over, and changing text.
Resource use?
For memory, web-browser JavaScript has no maximum. It can eat up all the available RAM and swap space, though it is not very good-mannered to do so. It can also hog the CPU, though that will make the browser seem to hang. But HTML5 has "Web Workers", a way of creating threads for compute-intensive tasks. I've never used it, however.
Inlined applets?
Mostly Java and Flash. I have experience with programming for Java, though not for Flash. I'm a bit averse to that for Java, because it can take a long time to load the Java runtime. However, it likely outperforms JavaScript.
I myself have done so:
http://homepage.mac.com/lpetrich/Chatters/GeometryDemo_GMap.html - Spherical Delaunay triangulation, convex hull, Voronoi diagram. Yes, all in JavaScript, which I'd ported from my original in Python.
http://homepage.mac.com/lpetrich/ColorBlindnessSim/ColorBlindnessSim.html - has a standalone Java version and a version that you can load webpages into: http://homepage.mac.com/lpetrich/ColorBlindnessSim/WebpageCBSim.xhtml . These work by calculating new color-channel values for each pixel as functions of the original ones.
A page on http://homepage.mac.com/lpetrich/Science/Symmetries/Index.xhtml - a http://homepage.mac.com/lpetrich/Science/Symmetries/TwoDimPointGroupDemo.xhtml and an http://homepage.mac.com/lpetrich/Science/Symmetries/OrganismSymmetryDemo.xhtml .
My experiences:
One can do a surprising amount with JavaScript in a web browser these days. Its main downside, however, is that it's difficult to debug. alert() isn't a very good way to do logging, not nearly as good as writing to standard output or to a file.
One can do graphics in three ways:
- HTML5 Canvas. Raster graphics; one commands a canvas object to paint various sorts of graphics objects.
- WebGL. OpenGL in a web browser for 3D graphics, as an extension of Canvas.
- Scalable Vector Graphics: SVG. One can do inline SVG objects in a webpage, and then control them the way that one controls other webpage objects. In effect, a controllable scene graph in a webpage. In Firefox, one can even do SVG filtering on non-SVG objects, like in my color-blindness simulator for webpages.
The main downside is spotty browser support. I have the latest OSX versions of Firefox, Safari, Google Chrome, and Opera, and all of them support Canvas, and all but Opera support WebGL and inline SVG. However for Safari, WebGL must be enabled, though doing so is rather simple. I have no recent experience with a recent version of Microsoft Internet Explorer.
Windows, Linux, and various smartphone and tablet versions of these browsers likely have similar levels of support.
Control widgets?
HTML is rather limited in them, having only buttons, checkboxes, radio buttons, popup menus, lists, and text fields. However, there are various libraries available for creating additional widgets, like sliders and color pickers. On the plus side, you can attach functions to various actions, like mouse clicks, mouse drags, mousing over, and changing text.
Resource use?
For memory, web-browser JavaScript has no maximum. It can eat up all the available RAM and swap space, though it is not very good-mannered to do so. It can also hog the CPU, though that will make the browser seem to hang. But HTML5 has "Web Workers", a way of creating threads for compute-intensive tasks. I've never used it, however.
Inlined applets?
Mostly Java and Flash. I have experience with programming for Java, though not for Flash. I'm a bit averse to that for Java, because it can take a long time to load the Java runtime. However, it likely outperforms JavaScript.
Last edited by a moderator: