incubator-flex-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Kevin Newman <>
Subject Re: FalconJS has landed
Date Tue, 27 Nov 2012 23:38:12 GMT
On 11/27/12 5:56 PM, Daniel Wasilewski wrote:
> However, when comes to FalconJS the task is to use strict proper OOP 
> language like AS3 to translate into JS. In my humble opinion, this is 
> what is all about, to protect us and give us more robust development 
> environment and target the platform we need without writing FOR the 
> platform. The fact that we are using AS3, output doesn't need to 
> leverage all those concepts on the target level at all. Even if the 
> output code would be set of plain objects or procedural style chain of 
> objects, if better for performance and the final result, better for 
> everyone. Good for marketing Apache Flex JS as the robust environment, 
> web RIA development environment.

I agree, and I can't see how you'd emulate certain things in a clean way 
anway - like protected or internal class members. You can kinda do 
privates with closures and literals, but you lose a bunch of stuff, like 
instanceof, it uses more memory, and it's actually slower at runtime 
(even if definition - boot up - is a bit faster).

As for perf tests, maybe throw one of these in there:

function BaseClass( yourVal ) {
     this.someVal = yourVal;
BaseClass.prototype = {
     myMethod: function() {
         console.log( this.someVal );

function Extended( yourVal ) {
     // super
     BaseClass.apply( this, arguments );

     this.someOtherVal = yourVal + " other";
Extended.prototype = Object.create( BaseClass.prototype ); // avoids 
constructing parent
Extended.prototype.myExtendedMethod = function() {
     console.log( this.someOtherVal );

var ext = new Extended( "test" );
ext.myMethod(); // test
ext.myExtendedMethod(); // test other

ext instanceof BaseClass; // true
ext instanceof Extended; // true

That's the closest I think you can get to classical inheritance in pure 
JS (you'll need to polyfill Object.create for IE), while maintaining the 
prototype chain.

Kevin N.

View raw message