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

> And indeed it is pretty impressive how fast the rendering happens given that the code operates at such lower level.

Sorry if this is a stupid question, but wouldn't you normally expect low level code, whilst more time consuming to write, be faster or just as fast as higher level code.

For example, how C is used as a standard for fast code since it's so low level.



If you are using C, you can afford to compute everything at low level as Notch is doing in this example. And you can afford writing pixel by pixel into a frame buffer that is later rendered.

However if you use this approach in Javascript you get poor performances unfortunately. And indeed this demo requires fast computers to do what otherwise could be done in C with direct access to the video frame buffer with maybe 50 times slower computers.

Even C coders almost no longer try to do this low level things and let the graphic chip do a lot of the work when the goal is to produce a game.

So in Javascript instead you want to usually call a library that implements a 3D engine in a lower level language like C and with more direct hardware access.

But in this case, it makes sense to do all this in a low level way and in Javascript: it is just a demo that is full of interesting code and with an appealing visual output.


Yes, but when you write in a high-level language like javascript without taking advantage of all of the high-level features like webgl (which are provided by the implementation and assumed to be fast), performance suffers.

In this case, Notch is writing code that doesn't necessitate the overhead of using JS. It could easily be rewritten as C and probably run faster that way. Not that it isn't interesting, of course.


You would expect low level code to be very fast in a low level language because it runs directly on metal. But on a high level language low level code get's translated into another code, so the code runs on the hardware is much more complicated. By using the high level features on Javascript actually leads to better optimized low level code.




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

Search: