🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Why didnt flash just compile to javascript/webgl?

Started by
15 comments, last by kop0113 3 years, 5 months ago

Hi,

This is something silly that's been bothering me, I'm not a flash developer nor do I know anything really about flash except that it compiles to a specific flash format that needs a browser plugin to run, I am however experienced in webgl and in my current project I transpile into javascript/webgl.

As I grew up in the golden era of flash content and have fond memories of it it saddens me a little to see it die (even though I 100% agree with the reasons, all NPAPI plugins needed to die) but even though the flash plugin needed to die I don't see why flash itself needs to die with it, why cant it just compile to javascript and use use webgl? keeping all existing tools and projects intact. Simply requiring the flash developer to recompile. Did adobe not find it worth the effort or is there other reasons why that could not work? (ok I'm making it sound easy, There would be alot of work for adobe to do and I'm sure there would be nasty edge cases when compiling existing projects but considering the amount of flash content out there I don't see why adobe didn't go this route)

Advertisement

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 ?

You do in a sence “compile to javascript” though, “transpiling” seems to be the most accepted term. For example I compile my entire java application (empirerising.net) to javascript. a java application that could just as easily run on my desktop VM (I use a tool/library called TeaVM). even though java is type safe and completely different from javascript. I know Unity engine also allows for transpiling when targetting the web and I assume it transpiles from C#. So yea javascript is certianly not “binary compiled code” but more and more it gets used as if it is :D (what the transpiler outputs is certianly not human readable anymore even though its “plain text”)

then about webgl, Yea in my case sure I port glsl over to webgl but for flash I was thinking more about using webgl in the background (so the flash developer doesnt actualy use glsl or anything, he just continues programming in flash… the compiler ("transpiler") and runtime libraries would just use webgl in the background for the actual rendering.

It is doeable, even for shock wave format files, but it would mean exposing all IP of Adobe bounded to Flash, as JS is client compiled, Plus, it would take a lot of effort, and, not realy outsmart html5 developers. My opinion.

Ah I guess the IP aspect makes sense, they do after all still sell their other horribly overpriced solutions like illustrator.

EternityZA said:

As I grew up in the golden era of flash content and have fond memories of it it saddens me a little to see it die (even though I 100% agree with the reasons, all NPAPI plugins needed to die) but even though the flash plugin needed to die I don't see why flash itself needs to die with it, why cant it just compile to javascript and use use webgl? keeping all existing tools and projects intact. Simply requiring the flash developer to recompile. Did adobe not find it worth the effort or is there other reasons why that could not work? (ok I'm making it sound easy, There would be alot of work for adobe to do and I'm sure there would be nasty edge cases when compiling existing projects but considering the amount of flash content out there I don't see why adobe didn't go this route)

I don't know how big the community is now, but recently it was recognised as something that wasn't just dying off despite the move to HTML games. I think it might be a little late to do something about it, but yours is a really good idea.

I'm sure it wouldn't be “just” compiling. It would be transpiling the flash project into another project using a specific set of features, solving the flash objects in a particular way. Some assumptions would have to be made, but plain canvas might be the way to go. Using WebGL would be applicable to some project. Determining when to utilise what might be a challenge.

I'm not sure what @ddlox points are exactly. They seem to think that compiling to javascript isn't compiling, then they proceed to comment on why Flash wasn't meant to do this and that javascript should be less fit because it isn't typed, overlooking many other projects that compile to javascript (even strongly typed languages). What "flash is meant to do" is in my opinion is besides the point as long as fla and as3 can be parsed and turned into anything. I'm also at a loss as to why you'd necessarily need to expose any IP. I think that @eternityza's suggestion is something that could be realised.

But it's a lot of work for sure, and it might be difficult to get a result similar to that of the original fla project.

SuperVGA said:
I'm also at a loss as to why you'd necessarily need to expose any IP

At best you can obfuscate javascript instructions, but anything that client can run in html5 browser must be delivered to his js compiler straight. Is there anything you are hiding behind the shelfs?

JohnnyCode said:

SuperVGA said:
I'm also at a loss as to why you'd necessarily need to expose any IP

At best you can obfuscate javascript instructions, but anything that client can run in html5 browser must be delivered to his js compiler straight. Is there anything you are hiding behind the shelfs?

Ah, alright. I thought you were referring to Adobe IP. Still though, it's no different from other clients. The executables are (often) delivered via a secure connection, and the logic contained within the client can be reverse engineered, have its assets extracted etc. Js applications are just as secure as any other, whether delivered to a full browser or within a dedicated wrapper.

SuperVGA said:
I'm not sure what @ddlox points are exactly.

I was coming from the direction of flash and npapi "works" that could not be transpiled to javascript without carrying sins of their past (for the reasons I mentioned and others not mentioned here) - that's in a nutshell what i was saying, sorry if this wasn't clear ?

but yes i do agree that where IP is not an issue such as with C++ then the concept of transpiling a language to another is nowadays slowly becoming common ground (like emscripten, etc…) and flash alone could benefit from this ground too in this direction, but with html5, flash is not really needed. Remember: Flash came about really because HTML at the time was not rich enough to do things Flash did.

Someone at Adobe had a Eureka moment and thought ‘what if we let users/browsers download a player that can run our scripted code’ thus Flash was born. And flash overcame … well for a moment … the limitations of HTML;

but today HTML5 is beefier and it can even play mp4 video with a simple <video> which the old HTML did not do and hence u needed Flash for this…(for example);

so yes i understand the nostalgia, i have also written flash image gallery code that loaded a server-side PHPObject and created an animated login window which i miss -lol- but u have to understand that all this was because of “lack of features” in html back then. This is different today; html5 is alot richer;

if Adobe decides to create a tool that transpiles fla to js to use webgl, fine, great! but it is not necessary for this reason alone;

hope this clarifies my answer ?

ddlox said:
if Adobe decides to create a tool that transpiles fla to js to use webgl, fine, great

I think if someone was to do it, it wouldn't be Adobe. I think those in the flash community might benefit from it, it will make them productive "faster" compared to learning another framework or getting into web development. Adobe though, I doubt they care at this point.

This topic is closed to new replies.

Advertisement