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

I always found it silly to compare an expensive language like JavaScript, that couldn't be further away from the machine, to assembly language. A language where data stuctures are hash maps with string keys, where numbers are boxed doubles on the heap, etc.

An array of points in C: http://s3.mrale.ph/images/array-of-points-structure-c.png

An array of points in JavaScript: http://s3.mrale.ph/images/array-of-points-structure-javascri...



I think the point is something like this: Assembly is the only language your machine can run. Everything else your machine does must eventually be converted to a machine instruction. Javascript is the only client side DOM manipulation scripting language that all browsers can run. Everything else (CoffeeScript, for example) must eventually be converted to javascript.

I think that is the core of the analogy, and it is not talking about how high or low level each language is in an absolute sense but in a relative sense. It is talking about it being the "at the metal" language of machine instructions and browser "instructions" respectively.

Of course, there are other parallels, but they aren't as strong. Part of the reason for using CoffeeScript is because of a perceived increase in expressiveness, but that increase is very small compared to the improvement of C over assembly (as the author of this article points out).


"where numbers are boxed doubles on the heap, etc."

Actually, you don't know that. Since doubles are immutable, the runtime can (and does) cheat, including turning many of them into integers. It all boils down to predictable usage patterns.


That is not the only way to do it in Javascript though. if you allocate an ArrayBuffer then you are dealing with a plain block of bytes that you can treat as points (or anything else).

These are the things that Javascript has been growing to facilitate the idea of js as asm. Emscripten uses ArrayBuffers to allow C to compile to JS without the messiness.


You really feel that JS "couldn't be further away from the machine?" What about languages that don't have a specified execution model? Haskell and other MLs, for example.


I believe that these languages do have a specified execution model (how would you execute them without one?), they just don't have any hard prescription as to how to map it onto hardware the same way that, for example, C does.


nobody serious said javascript was the assembly of the web,that's the issue.


But there lies the issue, it IS serious when you cross meanings in any professional field.




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

Search: