3 ms·
> those who code C++, Java and ActionScript 3.0 just love piling on > boilerplate code and long names like FactoryBuilderFacadeInterface boilerplate code is
by zwetan 16y ago
> those who code C++, Java and ActionScript 3.0 just love piling on
> boilerplate code and long names like FactoryBuilderFacadeInterface
boilerplate code is not caused by the language, but by the programmer,
I know more than few examples of compact/clean/well-named code in C++, Java, AS3, etc.
> since old AS 2.0 looked like JS
no, that was AS 1.0
AS 2.0 was statically checked at compilation time
> [...] but the non-programmers are still using AS 2.0 or switched to JS.
it's not a problem of being a non-programmer vs being a programmer,
it's a problem of a group of people learning a certain way to program with AS 2.0,
and when an update occurs to the language are too lazy to change their habits
> Did AS 3.0 have to be as verbose? Did it need giant frameworks and
> Java developers? Did it need types? No.
You're mixing a bit of everything there
AS 3.0 is not verbose, you can still compile it "AS 1.0 style", just use
the compiler MXMLC -ES and yes by doing that nothing is statically checked
and all built-in classes default to "prototype" mode.
(for ex: http://hg.mozilla.org/tamarin-central/file/fbecf6c8a86f/core/Array.as http://hg.mozilla.org/tamarin-central/file/fbecf6c8a86f/core...)
For the giant framework part, yes the Flex framework is big, but it does not
define what I would call an official AS 3.0 framework, in fact AS 3.0 at the language
level is pretty compact, the "real" framework is the Flash Platform API (or if
you prefer the native classes available in the Flash Player or AIR).
So, again a problem of understanding with types, let be clear about something here,
you seem to think that because JavaScript or AS 1.0 does not need to assign types
to variables and because they are not statically type checked at compilation or interpretation, that there is no types, sorry they have types.
Read those articles from Eric Lippert
The JScript Type System, Part One
http://blogs.msdn.com/b/ericlippert/archive/2003/11/05/53336.aspx http://blogs.msdn.com/b/ericlippert/archive/2003/11/05/53336...
"JScript Classic is a weakly typed language. This means that any value of any type may be assigned to any variable without restriction. It is often said -- inaccurately -- that "JScript has only one type". This is true only in the sense that JScript has no restrictions on what data may be assigned to any variable, and in that sense every variable is "the same type" – namely, the "any possible value" type. However, the statement is misleading because it implies that JScript supports no types at all, when in fact it supports six built-in types. The "weak" in "weakly typed" refers to the weak restrictions on variables, not on the type system per se."
There are 8 parts of "The JScript Type System" and mho it is a must read if your language of choice is based on ECMAScript.
> The performance improvements from AS 3.0 types were negligible, they can be left out in
> a non-strict mode and the difference is 2 FPS, maybe. For typical Flash projects,
> debugging with types isn't necessary. Supposedly the situation improved performance
> wise for types, but that's the wrong priority.
negligible ?
OK, first thing first, when you compile AS 1.0/2.0 code, the generated bytecode (in the SWF)
is run by the AVM1 (ActionScript Virtual Machine).
The Flash Player support 2 VM: AVM1 and AVM2, AVM2 is the Tamarin VM (http://www.mozilla.org/projects/tamarin/ http://www.mozilla.org/projects/tamarin/).
So when you compile AS 3.0 code, the generated bytecode is run by the AVM2, which support runtime type annotations and is much much much faster because of that.
But let's see hard data
http://www.masonchang.com/blog/2008/4/28/tamarin-benchmarks-part-3.html http://www.masonchang.com/blog/2008/4/28/tamarin-benchmarks-...
http://www.masonchang.com/blog/2008/4/28/tamarin-benchmarks-now-featuring-type-annotations.html http://www.masonchang.com/blog/2008/4/28/tamarin-benchmarks-...
see the difference with and without type annotation ?
now if you want all the greedy details of why this AVM2 is much faster you can look at
http://www.adobe.com/devnet/actionscript/articles/avm2overview.pdf http://www.adobe.com/devnet/actionscript/articles/avm2overvi...
- Detrus 16y ago"boilerplate code is not caused by the language, but by the programmer, I know more than few examples of compact/clean/well-named code in C++, Java, AS3, etc." That's right, I said the language attracts a certain type of programmer, who codes with boilerplate. There are quick and dirty AS 3.0 libraries, but there is an abundance of frameworks that help you organize code like PureMVC and Robotlegs which add a healthy amount of complexity. JS world has a higher proportion of simple libraries like JQuery than big and heavy ones like Google's Closure, a visitor from Java land. Flex framework is what Adobe thought would help developers. They spent some effort promoting it and integrating it into their IDE. This means they're not focused on graphics heavy projects that Flash is famous for, but are expanding into the big utilitarian app territory. Such moves attract verbose programmers, who write complex example code etc.. The standard API in AS 3.0 is also more verbose than the AS 1.0, 2.0 or canvas equivalents. This gives advanced programmers better control, while neglecting the needs of novice coders. Adobe is pretty worried about the situation actually, very few novice coders bother with AS 3.0 because they judge syntax visually and AS 3.0 looks longer. "you can still compile it "AS 1.0 style", just use the compiler MXMLC -ES" I mentioned that online examples and libraries would use types, which pushes everyone to use them. Using non-strict mode when everyone is using strict is less convenient than just using strict. I don't know what VM non-strict mode in AS3.0 uses, I thought it uses AVM2, but I shouldn't need to know. I've tried 2D AS 3.0 physics simulations with types and without and the difference was difficult to measure. Most of the time was spent on rendering visuals, not on calculations, so there was no real world speed advantage in that situation. The cases where there would be, like encoding images, need threading anyway. For a language that isn't a speed demon in the first place, it makes no sense to worry about silly optimizations that are noticeable only in unrealistic benchmarks. Knowing that you need to use int instead of uint to access indexed arrays slightly faster is distracting. "it's not a problem of being a non-programmer vs being a programmer, it's a problem of a group of people learning a certain way to program with AS 2.0, and when an update occurs to the language are too lazy to change their habits" I picked up programming a few years ago so I still remember how painful it was to switch languages when I was a novice. Now that I'm not a novice, switching to similar languages is barely noticeable because I understand the fundamentals. Keep in mind, lots of these novices code a simple thing here and there, they don't write large programs so they don't really learn programming. When things change drastically, it makes more sense for these people to stick to AS 2.0 if they can or let a developer handle it. This is not so much a problem for novices, because they have options, this is a problem for Adobe since novices have options and are choosing Processing and HTML5. "let be clear about something here, you seem to think that because JavaScript or AS 1.0 does not need to assign types to variables and because they are not statically type checked at compilation or interpretation, that there is no types, sorry they have types." Yes there are types, but I'm talking about perceived language complexity and boilerplate code psychology. There are few instances where you have to worry about types in JS, but it's a constant time drain in AS 3.0.