Why didnt flash just compile to javascript/webgl?
well that's because javascript/webgl are not binary compiled code, they're human readable programming languages just like flash was;
as u know, compilers convert human readable code to machine code or to virtual environment codes:
- c++ to asm (further steps take place to turn this into the actual targeted cpu instruction sets, x86, x64, amd, sse, avx, etc…)
- java to javabyte code (to run in jvm using a jre)
- scumm to scumm v6 bytecode (to run in scvm .. haxe platform… or whatever Monkey Island was interpreted on ?)
- fla (flash files) to swf (to run on the security plagued interpreter that could easily let one hacker chat with another on your pc while u clicked on hapless white rabbits)….errm… no thank you, sir
EternityZA said:
I transpile into javascript/webgl.
ok leet's be clear here, in simple terms:
- u write yr webgl code in glsl (ogl es v2, v3 or later)
- this code is wrapped up in a javascript script code section
- which is in turned wrapped up in html (so u can still benefit from css as well)
- then when you run the whole thing, your browser loads the html, the js is interpreted which ultimately calls webgl to rasterize;
they key thing is that you're not compiling from one language to another (per-se), your browser is interpreting as usual … of course, u can say that the glsl part is compiled to a shader object that will run on the gpu.. but that's all really;
when u understand this, u should now understand that (fla) Flash code was not designed to be interpreted on the fly like browsers do, it was designed to be compiled into a runnable/executable proprietary format that was executed by a Flash player v1million (goodness sakes!);
But more importantly, Flash & ActionScript code were typed languages with variables such as String, Array, etc… whereas Javascript is weakly typed and often called untyped because it doesn't enforce types. So u see those 2 couldn't really marry well;
in an ideal world, Flash code and the NPAPI could still exist, the code complexity behind NPAPI and security vulnerabilities of the two, were just not helping;
finally, the uptake of HTML5 also means that things are better now than a port of npapi and flash to another language, no need really..
we're supposed to have fun here man, not suffer the consequences of poor programming languages -sorry flashers lol-
have fun ?