Home RSS

ActionScript 3 as a Server-Side Language

The more I code in AS3 the more I want to be able to use it as a server side programming language - mainly as a replacement for PHP. I might be missing something, but at first glance, I don't see any reasons this wouldn't be possible with a little effort from Adobe.

Let's look at the current manifestations of ECMAScript 4, the standard on which ActionScript 3 and the new version of JavaScript are based. There is Flash/Flex (SWF) with delivery to the web browser via a plug-in, JavaScript for direct interaction with the web browser, and AIR (Apollo) for desktop delivery. The only missing piece is server-side deployment, a fact of which I'd bet Adobe is well aware.

PHP is a great server-side language which I use very often, but every language has its own nuances, and switching continuously between PHP and AS3 often opens the door for several small bugs due to the syntactical differences.

As a framework for how much effort it would take to port AS3 for server-side usage, let's look at how PHP5 and AS3 compare on key web development factors. These core features are supported in both PHP5 and AS3:

- MySQL/database integration (PHP built-in, AS3 through classes)
- Open source and free
- Extendable (PHP through plugins, AS3 through classes)
- Large developer community
- Class-based development possible (Full OOP in AS3)

So with most of the features needed already included in AS3 or written by the community, why not take the extra step and port it to the server side? I'm sure Adobe doesn't want to sell Coldfusion 8 short, so there is that corporate hurdle. I could see it being integrated with Coldfusion in a similar manner that ActionScript can be included in MXML through the usage of a code/cdata block.

All said, nothing is stopping the community from developing an open source project based around this concept. A quick search of Google reveals that at least one other person is having similar thoughts.

Would you use AS3 if it was ported for server-side usage?

wade arnold said,

July 25, 2007 @ 11:24 am

I was actually on wikipedia looking for ecma4 standard server side languages last week so that I could stopping messing with syntax errors between php and as3. Sign me up and make it multi threaded!

Wade

akeem said,

July 25, 2007 @ 11:41 am

I started working on air project a while ago and looking into the sql lite api in AIR and I got to thinking. One thought led to another and next thing you know I am writing a jdbc port for action script (as3dbc) adapting the assql driver to it and building up to creating a OR/M solution for actionscript. I agree that in theory it is possible to have server-side actionscript (I have put some mild thought in it myself) and while it may not be the best with regards to performance for regular server use it could be a good jump off for running “servers” on devices that support flash. Start a google project and sign me up.

Theo said,

July 25, 2007 @ 12:21 pm

It would be very nice indeed.

However, there is C# on .NET (ASP.NET or whatever they call it), which is basically the same thing. Ok, not open source, but otherwise very similar. AS3 and C# are very similar as languages go (but the API is not, but that would always be the case going from client to server side), much more so than AS3 and Java, for example.

I feel a bit odd suggesting .NET as I have never and will probably never work with it, but it is true.

There is also Haxxe (maybe only one x, can’t remember), which is a language and API similar to AS3 that can be deployed on the server side and in Flash. The downside, as with most server side technologies other than PHP, Java and .NET is that you can’t use them if you don’t have control over the deployment server, and in my experience you usually don’t. Either the client already has a server environment and it’s not based on the new cool technology you want or the client’s sysadmin isn’t too keen on trying it. It takes a lot of time for a server side technology to get mainstream enough to actually be usable (but you have to start somewhere, of course).

But yeah, I too would like a server side environment based on AS3, it’s a good language.

Theo said,

July 25, 2007 @ 12:21 pm

Oh, and Netscape once had a server side environment based on JavaScript once upon a time.

Benny said,

July 25, 2007 @ 1:51 pm

Like I also commented on the other blog item you mentioned, I would applaud an AS3 server side solution. There is ofcours already HAXE and it would be just what we wanted but unfortunately most of my customers are setup with shared hosting solutions (either on Linux/Apache or Windows/IIS) and in such a setting HAXE is no option. So if such a solution would run in a shared hosting environment, for example if it could compile to a (fast)CGI binary or maybe code in AS3 and then compile to PHP/ASP/ASP.NET then that would be a very welcom solution.

jonnymac said,

July 25, 2007 @ 2:14 pm

Theo – C# is close, but you hit the nail on the head: it is not open source. I have always been pretty hesitant to choose a platform that is controlled by one party who can make significant changes without consulting the developers. With AS3 being open source, it would be fairly simple to take the language as a starting point for a server-side ECMAScript 4 implementation.

Benny – The shared hosting issue is exactly why I was suggesting it be combined with Coldfusion, because there is already a nice install base for the server. It is by no means at the level of PHP/ASP/ASP.NET, but you can at least find shared hosting for Coldfusion.

So, I’m not really sure what I would suggest in terms of getting the install base to a level that will really allow the language to take off and become popular. All those languages you mention have been available for years, so there would be a lot of catching up to do.

One thought, however, is that Ruby on Rails has become fairly popular over the past year seeing a significant gain in install base, including popular shared hosting providers such as Dreamhost. I think this goes to show you that if you put out an effort to make sure something is secure, there is a demand and it is fairly easy to install, hosting providers will offer it.

Chris Dawes said,

July 25, 2007 @ 5:10 pm

Actionscript server-side is called ‘Coldfusion script’. :-) Smith is open source. Go for gold!

Campbell said,

July 25, 2007 @ 6:48 pm

Micro$oft have a DLR for ruby, python etc, Im guessing writing the parser for AS3 wouldnt be too hard, still in beta (isnt everything these days) though.

Nghia Nguyen said,

July 27, 2007 @ 12:20 am

whats better actionscript serverside or php????

nghia

zwetan said,

July 29, 2007 @ 11:13 am

technically AS3 on the server-side is possible

it not have been done yet
and it requires a lot of work
but definitively possible

it would require that:
– take the tamarin code base
– make an apache module in C++ based on tamarin
– add a hell lot to the C++ base to have a somewhat useable server side API

but before being able to do that we have to wait
for an open source ASC (ActionScript Compiler)

Rostislav Siryk said,

August 8, 2007 @ 12:24 am

I often catch myself with the same thoughts: I want to AS everythihg. Actually, now we have ActionScript as the web client language (Flash Player) and desktop too (AIR). So why not to have the server variant too?

At least, as the some kind macro language.

Victor Dramba said,

July 10, 2008 @ 8:49 am

take a look at this speed comparison http://www.victordramba.com/?p=16

the Tamarin based AVM is flash fast!
it beats PHP by far

so, why don’t we start a open source project
pick a cute name
all software is there, the AS3 (abc) compiler is open-source too (it’s included in Tamarin)

AND WRITE IT OURSELVES!
sooner the better!

who’s in?

write me at victor.dramba at gmail.com

Quince said,

July 22, 2008 @ 1:28 pm

The reason there is code(ASP, PHP, Java, .NET) between Flash and the DB is security. Flash is loaded client-side the other languages are server-side protecting your DB.

I have already wrote two extensions one uses PHP for MySQL, the other uses ASP for MS SQL or .mdb.
Creates your PHP or ASP depending on which extension you choose.

The flash extension has built in classes and writes the FLash AS2 or AS3 for you insid Flash. I have made everything iterchangable between ASP and PHP classes so by changing the import from …php.as2.* (or…php.as3) to …asp.as2. To change from as2 to as3 you must also change your publish setting from as2 to as3. finally you need to change the loadVars variable type in the return function to URLVariables. That’s it!

All you have to do is set the variables for your query and what you want flash to do with the data on the return function.

It does the insert, update, select and delete queries.
You can also you where like what and sortby as well as joins unions and so on.

You can learn more about it at http://peakstudios.com.

Hope this helps.
Thanks!
Quince

mRA said,

November 13, 2008 @ 1:39 pm

Hi

Very good idea to use AS3 as server side language.
But, to be a serious competitor, AS should support multi-threading and offer speed performances that stand comparison with Java.

Best regards

jonnymac blog » MAX 2008 Sneak Peek: ActionScript 3 as a Server-Side Language said,

November 18, 2008 @ 8:38 pm

[…] While I wasn’t able to make it to MAX this year, I did follow Serge Jespers and Andrew Shorten’s live blogging of the keynotes and the sneak peek session. Lots of amazing sneaks revealed tonight, but by far the best announcement for developers (in my opinion) was ActionScript 3 as a server-side language. I had actually blogged about how I wish this would be released back in July, 2007. […]

RSS feed for comments on this post

 
Powered by WordPress.