News for hackers. Stuff that matters.
Re:Unreal JavaScript by paraboul on Wednesday May 08, 2013 @07:01AM (#5673483)
with asm.js

Did you mean with emscripten to asm.js

Re:Unreal JavaScript by azakai on Wednesday May 08, 2013 @10:44AM (#5674375)
Yes, asm.js is a subset of JavaScript that emscripten compiled UE3 into, in this demo.
Re:Unreal JavaScript by paraboul on Wednesday May 08, 2013 @12:33PM (#5675160)
I know, I was correcting the title.
Re:Unreal JavaScript by azakai on Wednesday May 08, 2013 @12:52PM (#5675291)
Sorry if I wasn't clear, I was just trying to say you were right.
Re:Unreal JavaScript by Stranger2013 on Wednesday May 08, 2013 @08:19AM (#5673689)
It should really be named as 'web bytecode' or 'web assembly'.
Re:Unreal JavaScript by weego on Wednesday May 08, 2013 @09:22AM (#5673953)
Should they? Both terms appear to not make much sense even in context, and also appear from a quick google search to have no provenance at all.
Re:Unreal JavaScript by arethuza on Wednesday May 08, 2013 @09:37AM (#5674014)
To be fair, the idea of distributing executable bytecode to be run by some kind of VM in browsers has been around for almost as long as the web has (predating even Java), even if there never was a standard name for it.
Re:Unreal JavaScript by MasterScrat on Wednesday May 08, 2013 @10:07AM (#5674167)
Sure, but that's just not what's being used here.
Re:Unreal JavaScript by MasterScrat on Wednesday May 08, 2013 @08:30AM (#5673732)
What is this "web bytecode" you are referring to?
Re:Unreal JavaScript by okamiueru on Wednesday May 08, 2013 @08:35AM (#5673754)
I have no idea what people are talking about here (web bytecode and web assembly doesn't make any sense to me... thought the latter probably is intended to mean asm.js which is just a subset of js that allows for optimization based on the limitation of this subset).

They compiled C/C++-code using Clang (or possible gcc w/dragonegg, but my guess is Clang 3.2 as that's the supported compiler for emscripten) to LLVM bytecode and then to JS/HTML5 using emscripten, which is aware of asm.js and optimizes for it.

Mozilla (which Kripken is also highly involved with) are behind asm.js and is supported in the latest nightly of firefox (supposedly giving speeds to within 2x of native code, which is damn impressive), and the guy behind emscripten (again, Kripken) works for Mozilla.

I'm don't know to what extend emscripten is part of Mozilla or his own personal project.

---- Slides by Kripken on emscripten (http://kripken.github.io/mloc_emscripten_talk)

Re:Unreal JavaScript by mschuster91 on Wednesday May 08, 2013 @08:47AM (#5673810)
The "web bytecode" refers to the fact that the two script files are bytecode and not readable js.

Download them with: 1) curl "http://cdn.unrealengine.com/html5-4c0913f/UDKGame-Browser-Sh... -H "Referer: http://www.unrealengine.com/html5/ > UDKGame-Browser-Shipping.js

2) curl "http://cdn.unrealengine.com/html5-4c0913f/UDKGame_Data.js -H "Referer: http://www.unrealengine.com/html5/ > UDKGame_Data.js

And all you get is 5.4M / 4K of unreadable bytecode.

Re:Unreal JavaScript by kalleboo on Wednesday May 08, 2013 @09:15AM (#5673929)
> And all you get is 5.4M / 4K of unreadable bytecode.

It's just gzipped. ungzip the files (turns 5 MB into 50 MB) and you can read them as plain text javascript.

Re:Unreal JavaScript by jerf on Wednesday May 08, 2013 @10:27AM (#5674278)
Yes and no... once you hit the

   // EMSCRIPTEN_START_ASM
it becomes

    if((d|0)!=36620|(d|0)!=0&(c[b+4>>2]|0)!=0)
    {c[1779323]=6}b=c[1312365]|0;d=7084512;
    c[d>>2]=c[1312364]|0;c[d+4>>2]=b;b=7084520;
    d=c[b>>2]|0;if((d|0)!=36620|(d|0)!=0&(c[b+4>>2]|0)!=0)
    {c[1779323]=7}b=c[1312363]|0;d=7084520;
    c[d>>2]=c[1312362]|0;
all on one line for nearly the rest of the file. It might as well be bytecode. Actually many bytecodes are more understandable.
Re:Unreal JavaScript by MasterScrat on Wednesday May 08, 2013 @10:33AM (#5674306)
No, it's still JavaScript. The fact that it's compressed or not human-readable doesn't make it bytecode.
Re:Unreal JavaScript by jerf on Wednesday May 08, 2013 @12:55PM (#5675316)
"It might as well be bytecode."
Re:Unreal JavaScript by CmonNoReg on Wednesday May 08, 2013 @02:58PM (#5676128)
So can you add some dynamic code into asm.js and expect same performance? Asm.js is an assembly that looks like JavaScript for compatibility and readability.
Re:Unreal JavaScript by ndesaulniers on Wednesday May 08, 2013 @08:53PM (#5678136)
No, asm.js code that parses successfully is compiled ahead of time. It is a strict subset of the JavaScript programming language. If you use parts other than the subset, it will fail to parse as valid asm.js code and revert to the interpreter/JITs.
Re:Unreal JavaScript by azakai on Wednesday May 08, 2013 @12:55PM (#5675315)
Well yes, but the same is true of any minified JavaScript, handwritten or compiled. For example look at the output of the closure compiler minifier.
Re:Unreal JavaScript by jerf on Wednesday May 08, 2013 @12:58PM (#5675344)
Minified Javascript does not operate on an enormous buffer of bytes, such that you get seven and eight digit numbers flying everywhere. It's still easier to understand and manipulate than ASM.

asm.js isn't just an evocative name, it's a reasonable description... it's assembly in Javascript.

Re:Unreal JavaScript by mschuster91 on Wednesday May 08, 2013 @11:22AM (#5674697)
THERE is the code. LOL, I actually did not spot it in the file and asked myself "just where the ... is the code"?
Re:Unreal JavaScript by mschuster91 on Wednesday May 08, 2013 @09:29AM (#5673982)
Ah, that helps. I wonder why the gzip is not done automatically by curl/wget...
Re:Unreal JavaScript by kalleboo on Wednesday May 08, 2013 @10:19AM (#5674235)
Yeah, it confused me at first as well, but I ran `file` to see what was going on and that clued me in.
Re:Unreal JavaScript by deno on Wednesday May 08, 2013 @02:01PM (#5675775)
It will if you pass in --compressed flag, e.g.:

   curl --compressed "http://cdn.unrealengine.com/html5-4c0913f/UDKGame_Data.js" -H "Referer: http://www.unrealengine.com/html5/" -O