Lately a lot of discussion had the ActionScript language as its focus. People start complaining about complex language features but I think they are great because the end user will benefit from that. Yesterday evening I had my very first test with Silverlight — and I am really impressed.
It took me a short amount of time to port the strange attractor to Silverlight. I agree that this is may be not a fair comparison because I know C# already but have a look at the source code. I make heavy use of type inference and the Matrix4x4 class has the plus, multiply and array-index operator overloaded. The code is more readable. And besides: it executes really fast. Faster than my heavily optimized ActionScript version. Imagine I would write var bleh = 1.0 in ActionScript. Framerate would drop to something like zero. But this is sad since there is no reason for me to write var bleh: Number = 1.0. A modern compiler should be able to figure this out. haXe can do it, C# can do it, OCaml can do it and lots of others as well.
Remember: This was my first time using Silverlight. To achieve the same result with Flash you have to be kind of an expert in strange player and language “features”. Now tell me again that the end user will not benefit.




This is pretty neat. Time for Adobe to act… before it is too late and we’ll have to bury Flash (not because of SL, but HTML5 and new JS-Engines). Don’t get me wrong, I love Flash.
“Imagine I would write var bleh = 1.0 in ActionScript. Framerate would drop to something like zero. But this is sad since there is no reason for me to write var bleh: Number = 1.0″
Personally I think that this is something good. Strict typing makes code more readable for me and even though it’s obvisous that var blah = 1.0 is a number, I’d prefer var blah:Number = 1.0
I agree, I like to type my variables. But it is great that you can choose. A lot of developers love type inference.
Sometimes I like to have a type infered. Instead of writing
AbstractGraphTraversal<Graph<PrimimtiveVertex<Int>, Edge<PrimitiveVertex<Int>>>I could simply let the compiler infer the type for me without loosing anything.It is also a great feature for unexperienced developers. A variable will not stay untyped although you omit or forget its type declaration. This will result in faster execution time which will result in a better user experience.
You’re right about that, yet this kind of feature would not appear on my current ActionScript wish-list.
Seeing that your attractor example runs pretty “smooth” (approx. 16-18 fps) on my EeePC compared to your ActionScript version, I might start spending more time with Silverlight, just in case that I’ll start losing my love for ActionScript.
Nice to see that you support C# and these efforts from MS. I work on Apple, kind of dont like Windows and all, but am still a big fan of the C# language and ASP.Net . One of the few things I’m missing out on at the moment. With C# , MS is indeed ahead of the game with Adobe. Gonna dive into it too next weekend.
Maybe it would be a good idea to have a meta language like Groovy for Java in the ActionScript world, too. I’ve been playing around with Grails in the last weeks and now really miss Groovy’s super simple programming approach in AS3. It offers dynamic typing (which is not the same as C#’s implicit typing) and some other features that make coding really fast compared to pure Java. And you can always switch to Java syntax whenever you need to.
Something like “Groovy for ActionScript” could help beginners to get started with AS3 while at the same time allowing low-level language extension for guys like Joa ;)
type inference.. it feels like lazyness and assumptions, no?
It’s like the worst of dynamic and strict typing: you have to remember the datatype yourself (through the whole program flow), and if you mess-up it all breaks down in horrible compiler and runtime errors. We’ll have such fun with this in our late night debugging sessions, i cant wait.
It would be fun if somebody tunes the variables (var myVar = 1.1 to var myVar = 1), and the data type inferes to int and all of a sudden stuff doesnt work anymore.
The nice part about strict typing is that the machine checks tour typing, which frees brain-cycles for creating stuff. Writing a data-type behind a var (an hit Build/Run) costs less brainpower then following the flow of a var to find the place someone declared it.
@joa :
“Sometimes I like to have a type infered. Instead of writing AbstractGraphTraversal<Graph<PrimimtiveVertex, Edge<PrimitiveVertex>> I could simply let the compiler infer the type for me without loosing anything.”
C# 3 does know about type inference. To use it use the var keyword :
var blah = 1.0;
this will compile with blah having a float type.
Xavier: Oh no, I was not asking for it. I am using it in the example source code all the time.
Macaca: You have to understand how type inference works. In C# for instance you are allowed to use the var keyword only in method bodies. This means the problems you make up are all solved anyways.
Turning 1.1 into 1 is not a problem at all. An integer can safely be widened to a double value if that is necessary at some point. Only the inverse is not possible since it involves a loss in precision.
Type inference means your variables are still statically typed. So this does not involve anything like runtime errors. And the compile time errors would be the same as if you used explicit typing.
You suddenly decide AS3 is a failure after what? 2-3 years of using it?
Then it takes you two minutes to start lauding Silverlight.
Am I the only one who’s wondering why several bloggers all decided to slate as3, for no reason?
“Am I the only one who’s wondering why several bloggers all decided to slate as3, for no reason?”
Most probably yes. Becaue “for no reason” is something whole different.
@Macaca : work a few months with a type inference language and I’m pretty sure you’ll change your mind. People which have been using it like it. Period.
Yeah with C# MS is way ahead of many. 5 years ago on first year of university Java was my serious OOP language of choice. But then we had course on .Net 2003. Since then I haven’t looked on Java at all as it felt so much better to use it without any noticeable disadvantages (aside from no ActiveX version but then I already was in to Flash too). So now Flash is my “in browser” choice and C# desktop choice. And after C# AS3 is pain when you need to design some large and complex lib like UI library of physical engine.
John: It is not sudden. I think we will see a lot more from serious developers in coming months. It just grows on you little by little until it overflows. AS3 was a big improvement from AS2 but it is still very far from what it promised to achieve. Still weird OOP and some problems with expressiveness which still lead to a lot of pain in large projects.
But that’s not the only problem with Flash right now. I think Flash starts to be divided too much by styles of programmers :( That starts to hurt my professional life unfortunatly. We have Flash IDE designers and programmers (me included). We have Flex style programmers. We have FlashDecelop style programmers. And in the end we even have haXe programmers. And unfortunately those styles are not interchangeable. Project started like one of those can only be developed further using same style. I fear that can grow in to serious problem when platform is one but there is such large gap between those sub communities with all their advantages and disadvantages that it will become quite a mess :(
Very good post Joa.
You should maybe also try unity as you can code C#,Boo and JS there and also use any of em together in one project, too.
Erik, you might try it on mac, i use it on my mac, too :)
to john: Its not that suddenly all bloggers jump out of the woodwork after having loved it soo much, its that some problems become more and more obvious and annoying the more one uses something and also with time more and more alternative options become available and at the same time, well, time goes on and the longer Adobe doesn´t act the more time is wasted. I meanwhile still use flash for some stuff but for lots of things i´ve switched over to other tech and languages.
i´d like to use flash more and also enjoy using it more again but yeah, for that Adobe has to do something there.
@John
I think he’s not lauding Silverlight but C#. After using ActionScript for many years and then having a look at C# you simply notice the advantages that the language has over AS. And as a developer sometime you will reach the point where you are starting to think that AS needs better OOP features. i love ActionScript but I agree with Joa that it’s time for a big improvement in language features.
I made these complaints when I first started to use the language and then I got used to it and moved on. So did the entire flash community.
Why do several prominent bloggers just start moaning last week? What prompted the sudden change of heart? It’s weird.
If he’s lauding c# and not silverlight, why the title of the post?
Joa, I would really love to see the example but I’m giving up after installing silverlight 4 times now. I guess Adobe still has some time to fix actionscript before microsoft gets the installer right.
Mark: that is an interesting point =)
Cause i imagine in general flash player installation maybe is still running smoother for most, but to me personally silverlight updated automatically and flawlessly when i wanted to try joa´s example (and that in safari on mac) whereas i find the flash player installation quite annoying (have to download and manually run installer with various browser types and tick off the google toolbar or what it is auto download option when downloading the flash plugin, with some browsers restart is required before it works fine,too).
John he is lauding C#, but note that the “client/internet” version of C# is delivered through the Silverlight plugin.
This internet optimized .Net CLR with C# in the Silverlight plugin is why he mentions “Silverilght” in the title.
James – Unity also uses C#
Interestingly, getting silverlight setup and published is a pain in the neck compared to either unity or flash, C# is about the only thing attractive about silverlight development.
Microsoft originally had this pipedream about getting all of their .Net developers switching to silverlight and suddenly taking the place of the flash dev community.
This didn’t happen, so I guess Microsoft’s only option is to somehow start bribing/bringing flash developers over to their platform. It’s actually pretty transparent…
@John – your insinuation is incredibly rude. Can’t you just accept that the new Silverlight release may be having an impact and some Flash devs are trying it out for the first time, then blogging about their findings? Not everything is a conspiracy.
@Dave R
Completely, if silverlight *were* making an impact, I would be inclined to agree with you. It’s not though. At all.
I know a lot of flash developers, and all the migration I am seeing is to Unity, I-phone and Flex….. except for a couple of high-profile bloggers, being some of the same people who suddenly decide that AS3 isn’t that good in the same week.
If noticing something is weird == being rude, then yes, I concede that too.
I am not sure how much Silverlight has impact on Flash community but I am definitely living it everyday how Silverlight is impacting .Net community which is much larger then Flash in my opinion. Because now my company is beginning to receive lots of request on creating Silverlight application. Interesting thing is all my creative artist are Flash developers in fact when we prototype they are creating mock up using Flash and then porting it over to Silverlight. At least from my experience in given time I think Flash community will benefit from it in that mix of great designers from Flash community mixed with great pool of developers from .Net will make Silverlight that much more attractive.
John – do you think that maybe the recent release of SL3 might have something to do with it? Those that started checking it out after that should be coming out with opinions right about now…
BTW, some interesting demand graphs here:
http://www.itjobswatch.co.uk/jobs/uk/silverlight.do
http://www.itjobswatch.co.uk/jobs/uk/flash.do
@Jonas
yes, but not for the reason you’re suggesting.
Joa – great article. I’ve posted about taking your SL3 implementation and altering it to use multithreading in the code that clears and then updates the pixels in the bitmap. Check it out at
http://blog.efvincent.com/concurrency-optimization-silverlight
And let me know what you think! Again… great work.
-e
This poll, by Tim Heuer @Microsoft, is interestingly timed, too – I would assume most of the responders so far are already C# / Silverlight developers; what do flash geeks think?
“Do you have a need to convert SWF (Flash) assets to Silverlight? Maybe some with ActionScript?”: http://twtpoll.com/r/knuzik
Flash definitely is facing a stiff competition from Silverlight. Any information on market adoption and flash vs. SL rates?