Check out Peter Elst’s collection of Sneek Peek sessions from MAX. I’m on the verge of tears looking at Scott Peterson’s C/C++ on Flash demonstration. What… the… hell. He seems to indicate that he’s written a C++ to AS3 translator, not a C++ compiler that targets ABC. Peterson mentions including scripting hosts for other languages into the AVM, so you could run PHP or Ruby or whatever inside a SWF. Why not? I’m really interested to see how one would implement multithreading in a performant way… you could always chunk up your translated AS3 code into equal sized blocks, managing your scope and running only one block per frame, but how would you tune this to the speed of your processor dynamically, doing more or less code per frame to fully utilize your available CPU time? No idea. Then he proceeds to shit everyone’s pants by showing his AS3 translation of Quake I. Now this baffles me. At some point he simply must have replaced one of the display libraries with a for-Flash-Player BitmapData adapter library. And the sound control seems even more improbable to have been ported automatically. Anyway, this seems completely outrageous. I thirst for more information. I’d love to read a much more detailed article on how Scott approached this; whether he really let the AS3 compiler do all that work, or how much he dug into the AVM itself. But for now, I have to pick up my jaw from the floor, please excuse me.
Archives
The Authors
Categories
- AIR (21)
- Architecture (21)
- AS3 (86)
- Client-side (9)
- Conferences and User Groups (4)
- Data (1)
- Design (15)
- Discussion (7)
- Flash (109)
- Flex (68)
- Hydra (3)
- In Real Life (32)
- iphone (3)
- Lab (6)
- Meta (4)
- Mobile (1)
- News (73)
- Objective-C (1)
- physics & motion (10)
- Process (4)
- Programming (71)
- Project (3)
- Server-side (1)
- Site-seeing (49)
- Tips, Tricks, and Hacks (28)
- Tutorial (38)
- User Experience (25)
- Videogames (35)
The guy giving the demo is Scott Peterson — the whole thing was a little over my head but from what I could see he was extending AS3 with C.
The approximation of multi threading he called green threading.
From what I hear this is an extremely early proof of concept and not something we will necessarily see any time soon.
Thanks for the info, Peter! I’ll update the article.
I did forget to mention, the Sneak Peeks series is definitely of software that you may never see, so READERS BEWARE! However, that doesn’t make me want to know how he did it any less :)
I really have my doubts that you could simulate multithreading successfully without tighter control of the AVM than AS3 exposes…
Don’t be that dramatic :)
It would be actually quite useful to have some native extensibility, especially when it comes to AIR applications. But it’s true that’s not in the “ubiquity” philosophy thing…
But those extensions he presented (xslt, multithreading, interpreters…) are really well chosen. It would be cool to have them included in the player some day.
{Maz}
PS : MAX just finished :’(
I heard that the sound was not done in AS, but that everything else was. Watching the demo you could notice a command line window also opened when he launched. That led me to question the validity of the whole thing, but when I asked someone from Adobe I was told that it was only needed to do the sound, but other than that it’s all being run as compiled AS3 code by the player. That demo was out of control.
Yeah, I think when Scott gave the demo there was a collective “NO FRACKING WAY!!!” as a billion Flash developers screamed in disbelief.
The thing is, he could’ve whipped up a port of DOOM and everyone would have been amazed. The Flash DOOM port that’s been getting buzz recently is awesome, but it’s still quite slow. But no, Scott had to turn it to “11″ and port Quake. I don’t understand the performance of that thing…it’s just insane.
This may be a “Sneak Peak” but judging by the reaction of the crowd I think Adobe had better start cranking on it now. It would basically give Flash the “win” button.
Its legit and Scott is brilliant. Hopefully more information about what he’s done will get distilled into the blogosphere soon.
OK, I’m counting on you to keep us posted, Deepa! Good luck on your preso :)
I have known Scott Petersen for over 15 years. He is the smartest guy I have ever met. When you see a demo from him you need to realize this is just the material he’s letting you see. The really awesome stuff is still floating around in his head.
Nice, but doesn’t impress me at all. Why waste time doing this when ActionScript 3 is capable enough?? To make flash development available for those too lazy to learn a new language? WTF…and OMG.
C/C++ coders swear they are so smart because they do memory management and all this other hooplah. I’ve done C++ and haven’t touched it since 1998-1999.
I moved on to learn new stuff: ASP, Flash, VB/VB.Net, C#, PHP, ASP.Net…
Therefore, I have no need to use C/C++ code for flash development. What is the use? I noticed Scott Peterson kinda stuttered there in the video…LOL. Genius – Yes! Wasting talents on B.S. – Yes!!
Write some code that will help humanity, or NASA or something Mr. Peterson…then I’ll be impressed. Better yet, make a new OS and get rid of developer woes towards Microsoft.
It’s not about not making someone learn a new language. It’s about speed barriers. AS3 is not capable of doing the necessary calculations to run Quake. Even the 3D engines running today for AS3 max out at a few hundred triangles in the viewing area. It’s about the fact that he just increased the speed limit of AS3 immensely. That’s a big deal. I’ve done C++ too, and I can tell you that there are very few people that use it for it’s ease of use, it’s about speed. And merging C++ and Flash in an effective way that will allow much faster speeds for AS3 programs. After that it’s the developers who can help humanity, or NASA, or build a build a better OS. If he were able to give the developers the building block to do that, he would be assisting in everything done with that tool.
I had exactly the same reaction as Roger (except I’m too lazy to blog about it.)
Does he have a libc emulation layer? Did he write a generic audio driver that dynamically creates audio files in ByteArray and loadBytes() them? (like the 8-bit boy player?)
The most likely explanation is, this doesn’t run on the flash player as we know it. This runs on some experimental version of the flash player that happens to have all the right APIs needed for this to happen, with probably very little consideration for bothersome trivialities like web sandboxing.
I wonder how much of it is driven as a response for Silverlight, which plans to allow developers to port code easily from their .NET apps into their web apps.
Interestingly enough, it seems like it would be much easier to generate as3 from C# than from C++, although I’d be surprised to see Adobe acknowledging C# exists, at least not until Silverlight becomes a serious contender.
I don’t have an exact answer just 20 years of computing knowledge that tells me… This is 80% c++ and 20% as3, the sound and video are too synchronized. It’s also probably 80MB of data hot loaded from the local drive… full of cached calculations, textures, scene, lighting (probably baked and cached as well) and uncompressed audio. I don’t see how the payload for this app could be delivered over the web, even on a cable modem. I’d foresee a 10 minute preload… But then again… maybe he’s using a quad 8-core with 16 gigs of ram…. ;)
I totally agree with Pedram and Metal, this cannot all be done in flash without using a whole load of new APIs or a heavily modified/optimized AVM. Flash runs through a virtual machine, thus making it pretty bad at performing processor-intensive tasks, such as running a 3D game. Flash is also pretty lousy at memory management, which leads me to believe that the game wouldn’t have lasted more than an hour without falling over.
With performance issues aside, I still find this demo pretty far fetched due to this magical translator of his. Have you ever tried porting VB.NET 2003 -> VB.NET 2005? You get problems. What about porting VB6 -> VB.NET 2005? You get even bigger problems, and sometimes it just doesn’t happen.
Can you see where I’m going with this? C/C++ -> AS3? It’s not going to happen. These are two completely different languages which are governed by two completely different organizations. For starters, you can’t even use pointers in AS3 let alone use native APIs, inline ASM, structures and unions. Also, the stack frames are built up completely differently in C/C++ as they are in AS3, which would introduce all sorts of problems if you were translating a bit of C code which interacts directly with the stack. What about C/C++ code which uses compiled libraries such as ws2_32.lib, or even DirectX? You’d have a good job converting those native binaries into AS3.
All this leads me to believe that a very large portion of this game was in fact running natively on the machine, much like Pedram suggested. Nevertheless, I’m always open to correction, and I’m certainly going to keep myself updated on this interesting development.