Return-Path: X-Original-To: apmail-incubator-flex-dev-archive@minotaur.apache.org Delivered-To: apmail-incubator-flex-dev-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 1616AE188 for ; Tue, 27 Nov 2012 23:38:39 +0000 (UTC) Received: (qmail 31914 invoked by uid 500); 27 Nov 2012 23:38:38 -0000 Delivered-To: apmail-incubator-flex-dev-archive@incubator.apache.org Received: (qmail 31888 invoked by uid 500); 27 Nov 2012 23:38:38 -0000 Mailing-List: contact flex-dev-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: flex-dev@incubator.apache.org Delivered-To: mailing list flex-dev@incubator.apache.org Received: (qmail 31880 invoked by uid 99); 27 Nov 2012 23:38:38 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 27 Nov 2012 23:38:38 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=5.0 tests=RCVD_IN_DNSWL_LOW,SPF_NEUTRAL X-Spam-Check-By: apache.org Received-SPF: neutral (athena.apache.org: 207.97.245.191 is neither permitted nor denied by domain of CaptainN@unfocus.com) Received: from [207.97.245.191] (HELO smtp191.iad.emailsrvr.com) (207.97.245.191) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 27 Nov 2012 23:38:33 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp59.relay.iad1a.emailsrvr.com (SMTP Server) with ESMTP id 730003F040E for ; Tue, 27 Nov 2012 18:38:12 -0500 (EST) X-Virus-Scanned: OK Received: by smtp59.relay.iad1a.emailsrvr.com (Authenticated sender: captainn-AT-unfocus.com) with ESMTPSA id 58AF03F05BB for ; Tue, 27 Nov 2012 18:38:12 -0500 (EST) Message-ID: <50B54EE4.4010402@unFocus.com> Date: Tue, 27 Nov 2012 18:38:12 -0500 From: Kevin Newman User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:16.0) Gecko/20121026 Thunderbird/16.0.2 MIME-Version: 1.0 To: flex-dev@incubator.apache.org Subject: Re: FalconJS has landed References: <50B4E8C3.5040201@gmail.com> <50B5052E.6000301@gmail.com> <50B54518.4050204@gmail.com> In-Reply-To: <50B54518.4050204@gmail.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org 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. https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object/create Kevin N.