<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: CommonJS: Bridging client and server, and why JavaScript desperately needs first class modules</title>
	<atom:link href="http://almaer.com/blog/commonjs-bridging-client-and-server-and-why-javascript-desperately-needs-first-class-modules/feed" rel="self" type="application/rss+xml" />
	<link>http://almaer.com/blog/commonjs-bridging-client-and-server-and-why-javascript-desperately-needs-first-class-modules</link>
	<description>blogging about life, the universe, and everything tech</description>
	<lastBuildDate>Sat, 08 Sep 2012 07:06:53 -0700</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Alex Russell</title>
		<link>http://almaer.com/blog/commonjs-bridging-client-and-server-and-why-javascript-desperately-needs-first-class-modules/comment-page-1#comment-47306</link>
		<dc:creator>Alex Russell</dc:creator>
		<pubDate>Sat, 25 Sep 2010 20:20:32 +0000</pubDate>
		<guid isPermaLink="false">http://almaer.com/blog/?p=2768#comment-47306</guid>
		<description>The lack of any real attention to async loading from the CommonJS camp dooms it. It&#039;s just &quot;ServerJS&quot; until they get on board with what browsers need. In any case, I don&#039;t have a lot of hope that they&#039;ll be the ones to solve it. Browsers need to step up and bless this with syntax. The Simple Modules proposal is the best I&#039;ve seen yet:

http://wiki.ecmascript.org/doku.php?id=strawman:simple_modules

Regards</description>
		<content:encoded><![CDATA[<p>The lack of any real attention to async loading from the CommonJS camp dooms it. It&#8217;s just &#8220;ServerJS&#8221; until they get on board with what browsers need. In any case, I don&#8217;t have a lot of hope that they&#8217;ll be the ones to solve it. Browsers need to step up and bless this with syntax. The Simple Modules proposal is the best I&#8217;ve seen yet:</p>
<p><a href="http://wiki.ecmascript.org/doku.php?id=strawman:simple_modules" rel="nofollow">http://wiki.ecmascript.org/doku.php?id=strawman:simple_modules</a></p>
<p>Regards</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Kevin Dangoor</title>
		<link>http://almaer.com/blog/commonjs-bridging-client-and-server-and-why-javascript-desperately-needs-first-class-modules/comment-page-1#comment-47157</link>
		<dc:creator>Kevin Dangoor</dc:creator>
		<pubDate>Mon, 13 Sep 2010 01:05:43 +0000</pubDate>
		<guid isPermaLink="false">http://almaer.com/blog/?p=2768#comment-47157</guid>
		<description>I have always contended that there are reasonable ways to make CommonJS modules work in the browser. They&#039;re not perfect or as simple as adding a script tag, but they make for a module system that compares reasonably with that of, for example, Python.

I certainly hope that TC39 gives us native module support in ECMAScript Harmony. With bult-in syntax, we can have modules that load simply and have synchronous imports that don&#039;t block the browser.

In my view, no one should have to write a transport format and there are plenty of ways to load modules that provide correct line numbers, good performance, etc.

I have always been in favor of a common transport format, but never in favor of authoring in that style.

Kevin</description>
		<content:encoded><![CDATA[<p>I have always contended that there are reasonable ways to make CommonJS modules work in the browser. They&#8217;re not perfect or as simple as adding a script tag, but they make for a module system that compares reasonably with that of, for example, Python.</p>
<p>I certainly hope that TC39 gives us native module support in ECMAScript Harmony. With bult-in syntax, we can have modules that load simply and have synchronous imports that don&#8217;t block the browser.</p>
<p>In my view, no one should have to write a transport format and there are plenty of ways to load modules that provide correct line numbers, good performance, etc.</p>
<p>I have always been in favor of a common transport format, but never in favor of authoring in that style.</p>
<p>Kevin</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ben Gerrissen</title>
		<link>http://almaer.com/blog/commonjs-bridging-client-and-server-and-why-javascript-desperately-needs-first-class-modules/comment-page-1#comment-47154</link>
		<dc:creator>Ben Gerrissen</dc:creator>
		<pubDate>Sun, 12 Sep 2010 11:04:37 +0000</pubDate>
		<guid isPermaLink="false">http://almaer.com/blog/?p=2768#comment-47154</guid>
		<description>The thing about using code on both server side and client side has another dimension to it I rarely see discussed. In the wrong hands (and this is quite common tbh) one could end up with business logic or sensitive data (user info) on the client side when code is shared cross platform indiscriminatly. Is everyone overlooking this due to the excitement of code working both ends or doesn&#039;t anyone care about the dangerous implications?

That said, like James Burke I&#039;ve been working on a client side module loader (think we started at the same time but his was a lot simpler). After seeing his API I simplified mine as well and read the CommonJS specs.

There&#039;s a &#039;module&#039; namespace there which could be used to define modules rather then just hold some data.

module(function(exp, req){ /* code */ });

Here&#039;s my client side version of it (still beta) http://github.com/bgerrissen/modulejs

It uses fn.toString() so it can be parsed looking for what to &#039;require&#039;, loads that first and then fires the fn passed to &#039;module();&#039;. The parser I wrote is currently quite simplistic and should be expanded to something more elaborate, but the proof of concept is on the table. James Burke came up with require.def(); which is similar but passing the require strings is made mandatory.

It also seems both James Burke and me came up with a .run() method about the same time (I used it for JSoo) and not sure why he abandoned it, but it&#039;s a great way to kickstart modules into life.

module.run(&#039;myApp&#039;); // load myApp.js, it&#039;s dependencies and run it.

Explicit code invocation should really be a feature of CommonJS as well and when looking at this in depth could make require in Ryan Dahl&#039;s NodeJS async as well.</description>
		<content:encoded><![CDATA[<p>The thing about using code on both server side and client side has another dimension to it I rarely see discussed. In the wrong hands (and this is quite common tbh) one could end up with business logic or sensitive data (user info) on the client side when code is shared cross platform indiscriminatly. Is everyone overlooking this due to the excitement of code working both ends or doesn&#8217;t anyone care about the dangerous implications?</p>
<p>That said, like James Burke I&#8217;ve been working on a client side module loader (think we started at the same time but his was a lot simpler). After seeing his API I simplified mine as well and read the CommonJS specs.</p>
<p>There&#8217;s a &#8216;module&#8217; namespace there which could be used to define modules rather then just hold some data.</p>
<p>module(function(exp, req){ /* code */ });</p>
<p>Here&#8217;s my client side version of it (still beta) <a href="http://github.com/bgerrissen/modulejs" rel="nofollow">http://github.com/bgerrissen/modulejs</a></p>
<p>It uses fn.toString() so it can be parsed looking for what to &#8216;require&#8217;, loads that first and then fires the fn passed to &#8216;module();&#8217;. The parser I wrote is currently quite simplistic and should be expanded to something more elaborate, but the proof of concept is on the table. James Burke came up with require.def(); which is similar but passing the require strings is made mandatory.</p>
<p>It also seems both James Burke and me came up with a .run() method about the same time (I used it for JSoo) and not sure why he abandoned it, but it&#8217;s a great way to kickstart modules into life.</p>
<p>module.run(&#8217;myApp&#8217;); // load myApp.js, it&#8217;s dependencies and run it.</p>
<p>Explicit code invocation should really be a feature of CommonJS as well and when looking at this in depth could make require in Ryan Dahl&#8217;s NodeJS async as well.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: J Chris A</title>
		<link>http://almaer.com/blog/commonjs-bridging-client-and-server-and-why-javascript-desperately-needs-first-class-modules/comment-page-1#comment-47152</link>
		<dc:creator>J Chris A</dc:creator>
		<pubDate>Sun, 12 Sep 2010 04:59:19 +0000</pubDate>
		<guid isPermaLink="false">http://almaer.com/blog/?p=2768#comment-47152</guid>
		<description>We&#039;ve been doing a lot of brower / server CommonJS code in the CouchDB and CouchApp projects.

Here is an example of a CommonJS module that is used on both the client and the server of my CouchApp Twitter client. (This is app-specific code, but I also tend to use Mustache.js in CommonJS form on both the client and in CouchDB show and list functions.)

Module:
http://github.com/jchris/twebz/blob/master/lib/twebz.js

In the Node.js async job handler:
http://github.com/jchris/twebz/blob/master/node/twebzbot.js#L23

In the browser:
http://github.com/jchris/twebz/blob/master/evently/profile/profileReady/selectors/div.controls/setup_user.js#L5

The CouchApp CommonJS runtime is interesting because it preloads all the application code when the page is launched, from the CouchDB design document. Then the require function can be used to selectively load modules.

I&#039;ve definitely gotten addicted to the peace of mind that comes from knowing that requiring a module won&#039;t effect my other code, or litter the window object with new references.</description>
		<content:encoded><![CDATA[<p>We&#8217;ve been doing a lot of brower / server CommonJS code in the CouchDB and CouchApp projects.</p>
<p>Here is an example of a CommonJS module that is used on both the client and the server of my CouchApp Twitter client. (This is app-specific code, but I also tend to use Mustache.js in CommonJS form on both the client and in CouchDB show and list functions.)</p>
<p>Module:<br />
<a href="http://github.com/jchris/twebz/blob/master/lib/twebz.js" rel="nofollow">http://github.com/jchris/twebz/blob/master/lib/twebz.js</a></p>
<p>In the Node.js async job handler:<br />
<a href="http://github.com/jchris/twebz/blob/master/node/twebzbot.js#L23" rel="nofollow">http://github.com/jchris/twebz/blob/master/node/twebzbot.js#L23</a></p>
<p>In the browser:<br />
<a href="http://github.com/jchris/twebz/blob/master/evently/profile/profileReady/selectors/div.controls/setup_user.js#L5" rel="nofollow">http://github.com/jchris/twebz/blob/master/evently/profile/profileReady/selectors/div.controls/setup_user.js#L5</a></p>
<p>The CouchApp CommonJS runtime is interesting because it preloads all the application code when the page is launched, from the CouchDB design document. Then the require function can be used to selectively load modules.</p>
<p>I&#8217;ve definitely gotten addicted to the peace of mind that comes from knowing that requiring a module won&#8217;t effect my other code, or litter the window object with new references.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
