Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

It's not really JS, shaders are doing all the heavy lifting.


Could you explain what's really going on here. What part is JS responsible for and how is native code being used? Thanks.

EDIT: I assume the "native-code" part is something like webgl?


WebGL is just a JavaScript API specification that exposes an OpenGL-like interface to scripts running within a webpage. The calls that your JavaScript makes to WebGL functions are translated behind the scenes to actual OpenGL calls (although, it doesn't have to be opengl, i think IE uses directx under the hood). Both opengl and directx are API interfaces that allow you to talk to graphics hardware.

Graphics hardware is incredibly fast and programmable (via shaders), and now that WebGL is part of the standard, Javascript programs can actually use the hardware's capabilities. What we see in a lot of this demos is not the javascript interpreter being fast. Although chrome's V8 actually is fast (compared to other js implementations at least), most of the work is being done by the video card.


Firefox and Safari JS compilers are actually fast too. Even faster than V8 in some cases.

For example, I was surprised to find out recently that Firefox 25 is smoother and faster nowadays than Chrome on Mac Os X when running my interactive geometry genereator that is based on javascript/canvas (http://GeoKone.NET).


WebGL (or OpenGL ES) is not written in JS (obviously). JS calls into it, but the heavy lifting is being done by a native library. Calling this a "particle generator in javascript" is somewhat disingenuous.


The Javascript uses the WebGL library to compile and upload a piece of native code called a shader to the graphics card. The graphics card is then instructed to run the shader, which produces the image buffer, the image buffer is rendered directly to the screen.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: