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

> x | 0 as declaring int. +x as declaring float. Math.imul to multiply integers. seriously???!!!

|0, + etc. are how compilers to JavaScript - emscripten, mandreel, others - have been implementing integers and so forth for years. The bitwise operators and + have the right semantics for that, and are concise. So these are not ways to "declare" integers - they are functional syntax, things that actually do something.

In the asm.js type system, it was therefore natural to use them to also "declare" types. But only in the sense that asm.js figures out the types exactly as JS engines do, from code that has actual effects. (Compare to closure compiler type annotations, which are arbitrary and have no effects.)

Math.imul is not strictly necessary, but it fixes a specific pain point in JS (that multiplying large integers can be rounded due to JS numbers being doubles). You can use asm.js without it though, might be some slowdown with large ints but not large. asm.js is perfectly viable without Math.imul.

Besides all this though, the important bit to remember is that this is a compiler output. It's not a human-readable language. It doesn't matter if multiplication is * or DO_MUL or anything else, just like it doesn't matter how multiplication commands look (in terms of binary data) in x86 or ARM machine code.

> Also javascript (without introducing new concepts) is not low level enough to write down everything you might need (have fun implementing 64bit integer operations with overflow for example).

Depends on what you need. Current asm.js can run Sauerbraten, a 100 KLOC complete game engine with physics, AI, rendering, world geometry system, scripting language - not JS! :) - , level file formats etc etc. It is also enough to run large projects like Python, Bullet, etc. So it already supports quite a lot. In fact almost the entire emscripten test suite runs as asm.js, and that's a lot of C/C++ code.

But yes, there are some areas that are trickier, like true 64-bit ints.




| Depends on what you need. Current asm.js can run Sauerbraten, a 100 KLOC complete game engine with physics, AI, rendering, world geometry system, scripting language - not JS! :) - , level file formats etc etc. It is also enough to run large projects like Python, Bullet, etc. So it already supports quite a lot. In fact almost the entire emscripten test suite runs as asm.js, and that's a lot of C/C++ code.

well, yes, computers got a lot faster. I just wish the software stop getting slower at a similar or faster pace. The fact that I have to buy a new computer to play 8-bit games that were available on DOS and run fine on 386 is kind of ridiculous (but hey, they're over the internet).

-----


>> Depends on what you need. Current asm.js can run Sauerbraten, a 100 KLOC complete game engine with physics, AI, rendering, world geometry system, scripting language - not JS! :) - , level file formats etc etc. It is also enough to run large projects like Python, Bullet, etc. So it already supports quite a lot. In fact almost the entire emscripten test suite runs as asm.js, and that's a lot of C/C++ code.

> well, yes, computers got a lot faster. I just wish the software stop getting slower at a similar or faster pace.

First, asm.js is the opposite of that. As shown in the data in my slides here,

http://kripken.github.com/mloc_emscripten_talk/#/

with asm.js we already (after just a few months of speccing and engineering) get to 2x slower than native - same range as Java and C# - which compared to before is up to 5x faster than normal JS engines. asm.js is making the web faster, not slower.

Second, the context I was replying to is your saying asm.js is missing stuff as a compiler target. That a full-featured game engine can run in asm.js - as well as Python, Bullet, etc. and many other real-world projects - shows it is not missing crucial features as a compiler target IMO.

-----


>The fact that I have to buy a new computer to play 8-bit games that were available on DOS and run fine on 386 is kind of ridiculous (but hey, they're over the internet).

320x200 with 16 or 256 colors and maybe 15 fps?

Your magical nostalgia glasses are perhaps a little bit too thick.

-----




Applications are open for YC Summer 2015

Guidelines | FAQ | Support | Lists | Bookmarklet | DMCA | Y Combinator | Apply | Contact

Search: