Return-Path: X-Original-To: apmail-incubator-callback-dev-archive@minotaur.apache.org Delivered-To: apmail-incubator-callback-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 579E39DA6 for ; Fri, 18 Nov 2011 18:23:55 +0000 (UTC) Received: (qmail 7975 invoked by uid 500); 18 Nov 2011 18:23:55 -0000 Delivered-To: apmail-incubator-callback-dev-archive@incubator.apache.org Received: (qmail 7951 invoked by uid 500); 18 Nov 2011 18:23:55 -0000 Mailing-List: contact callback-dev-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: callback-dev@incubator.apache.org Delivered-To: mailing list callback-dev@incubator.apache.org Received: (qmail 7936 invoked by uid 99); 18 Nov 2011 18:23:55 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 18 Nov 2011 18:23:55 +0000 X-ASF-Spam-Status: No, hits=1.5 required=5.0 tests=FREEMAIL_FROM,HTML_MESSAGE,RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of alunny@gmail.com designates 209.85.212.47 as permitted sender) Received: from [209.85.212.47] (HELO mail-vw0-f47.google.com) (209.85.212.47) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 18 Nov 2011 18:23:50 +0000 Received: by vbbey12 with SMTP id ey12so435561vbb.6 for ; Fri, 18 Nov 2011 10:23:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:reply-to:in-reply-to:references:date:message-id :subject:from:to:content-type; bh=2gCX9whYUFsO1AWcgmXWON51h9/e4sPbgz5XJQ4CWok=; b=WPX3smRlIWuoUcXX7Xnx4xPPrnQvrcmq6OCM/Tgbiz4VLe94uTWgDCt7IySG6OTT9I lgHbPews8zd3zzBW7VN9iElAZr1dkb22IE3Oif4xLi0I9GLRsiM8/71dgT4kjtQpgV8Q 5rmdq6oH5dT3b2isTGkLWBs8XRAHWzJWlQV84= MIME-Version: 1.0 Received: by 10.229.246.18 with SMTP id lw18mr477562qcb.162.1321640609047; Fri, 18 Nov 2011 10:23:29 -0800 (PST) Received: by 10.229.85.200 with HTTP; Fri, 18 Nov 2011 10:23:28 -0800 (PST) Reply-To: alunny@gmail.com In-Reply-To: References: Date: Fri, 18 Nov 2011 10:23:28 -0800 Message-ID: Subject: Re: Unified phonegap javascript layer incorperating modules / plugins From: Andrew Lunny To: callback-dev@incubator.apache.org Content-Type: multipart/alternative; boundary=00163630fdd705e5b704b2066fc2 --00163630fdd705e5b704b2066fc2 Content-Type: text/plain; charset=ISO-8859-1 On 18 November 2011 08:47, Gord Tanner wrote: > I would also love to see an AMD module example, in fact you can see that I > am basically using a define statement in the build script: > https://github.com/gtanner/phonegap/blob/master/Jakefile#L50-51 Sorry I missed that - I think you're aware of the same issues running Node modules in the browser as I am. > We have the luxury of having a compile step for PhoneGap which allows us to > use the CommonJS approach and syntax without really worrying about sync vrs > async loading or the other weird problems attempting to handle CommonJS > modules the browser brings. > The concern I have is that the project becomes dependent on this compile step - I would much prefer having working code that can always run in the browser. The discussion, to my mind, isn't AMD vs CommonJS/Node but an explicit function-for-scope (explicit define) versus an implicit/generated function-for-scope (generated define). I think scoping is one of the most important tools a JavaScript programmer has, and hiding it away as something that gets generated as part of a compile-step muddles the abstraction layers, and makes programs harder to debug and reason about. I have worked on projects that required compile-to-JS steps - not for module loading, but for switching out mobile platform specific code - and it became an unwieldy mess very quickly. For a project the size of Callback, I think a runtime dependency for uncompiled code (a module loader) is far preferable to a compile-time one. > > The main reason I have used CommonJS in this project and in the past is the > ability to run unit tests in nodeJS. This was an amazing boost in > development time for Ripple and just felt nice to develop in. Also it > feels like CommonJS is the way Harmony is headed and the optimism of "it > will all just work" is a powerful driver for my choice. > > > On Fri, Nov 18, 2011 at 4:27 AM, Patrick Mueller > wrote: > > > On Fri, Nov 18, 2011 at 02:50, Brian LeRoux wrote: > > > > > So in short, CommonJS gives us: > > > > > > - better performance > > > - better aesthetics > > > - closer to the future > > > > > > > +1 on all that > > > > > > > +1 for AMD > > > > > > > um, what? :-) > > > > Seems pretty clear that we will have to easily tolerate AMD - I'm sure > IBM > > folk will be using Dojo, which uses AMD-style loading. While we could > try > > what Node did for a couple weeks - implement a define() function - this > > doesn't seem feasible as the API surface for define() is quite large; eg, > > requireJS and Dojo both support "plugins" somehow. But requireJS has > some > > kind of shim they can use to run in Node, and I suspect we would want to > > aim for that shim also working with us. Not clear to me if Dojo has a > > similiar shim (dunno, but doubt they could share requireJS's shim). > > > > Another nice things about using CommonJS/node style modules is that > > consuming existing npm modules is a snap. I've found this to be true for > > some personal projects I've worked on, using modjewel, the > CommonJS-styled > > loader I use for weinre. > > > > -- > > Patrick Mueller > > http://muellerware.org > > > > > > -- > Gord Tanner > Senior Developer / Code Poet > tinyHippos Inc. > @tinyhippos > --00163630fdd705e5b704b2066fc2--