<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
		>
<channel>
	<title>Comments for Fun Script</title>
	<atom:link href="http://pmougin.wordpress.com/comments/feed/" rel="self" type="application/rss+xml" />
	<link>http://pmougin.wordpress.com</link>
	<description>Interactive Cocoa</description>
	<lastBuildDate>Mon, 23 Nov 2009 15:05:56 +0000</lastBuildDate>
	<generator>http://wordpress.com/</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>Comment on Beyond Blocks by Philippe Mougin</title>
		<link>http://pmougin.wordpress.com/2009/11/17/beyond-blocks/#comment-598</link>
		<dc:creator>Philippe Mougin</dc:creator>
		<pubDate>Mon, 23 Nov 2009 15:05:56 +0000</pubDate>
		<guid isPermaLink="false">http://pmougin.wordpress.com/?p=1207#comment-598</guid>
		<description>Craig, Scala does indeed introduce sophisticated syntactic sugar. The &quot;_ &quot; placeholder trick for anonymous functions is quite nice (btw, your code examples appear to have been somewhat mangled). The point of the article is not to provide an argument against blocks in general, but to show that for some common problems there are alternative approaches that provide solutions that can be as nice or even better than the classic block-based approach (of course, this is open for debate). The idea is also to introduce a more general message sending mechanism (i.e., messaging patterns) and then to look at what kind of effect this has on the code we write and on the way we think when programming. One of the effect, in F-Script, is that people tend to use blocks less than in classic Smalltalk, and, for some parts of their code, can more easily think in terms of high level manipulation of entire sets of objects (vs. &quot;one object at a time&quot;). But block closures are still useful for a number of other things in F-Script.</description>
		<content:encoded><![CDATA[<p>Craig, Scala does indeed introduce sophisticated syntactic sugar. The &#8220;_ &#8221; placeholder trick for anonymous functions is quite nice (btw, your code examples appear to have been somewhat mangled). The point of the article is not to provide an argument against blocks in general, but to show that for some common problems there are alternative approaches that provide solutions that can be as nice or even better than the classic block-based approach (of course, this is open for debate). The idea is also to introduce a more general message sending mechanism (i.e., messaging patterns) and then to look at what kind of effect this has on the code we write and on the way we think when programming. One of the effect, in F-Script, is that people tend to use blocks less than in classic Smalltalk, and, for some parts of their code, can more easily think in terms of high level manipulation of entire sets of objects (vs. &#8220;one object at a time&#8221;). But block closures are still useful for a number of other things in F-Script.</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Beyond Blocks by Philippe Mougin</title>
		<link>http://pmougin.wordpress.com/2009/11/17/beyond-blocks/#comment-595</link>
		<dc:creator>Philippe Mougin</dc:creator>
		<pubDate>Sat, 21 Nov 2009 18:19:25 +0000</pubDate>
		<guid isPermaLink="false">http://pmougin.wordpress.com/?p=1207#comment-595</guid>
		<description>Chuck, thanks for the comment. It is nice to see Ruby 1.9 standardize this automatic conversion of symbols to blocks. I will update the article to include it.
Actually, for new languages I think it is worth going one step further and completely unify things like symbols and blocks (what is now a symbol becomes a compact notation for a block). That&#039;s how it works in F-Script and this is very useful.</description>
		<content:encoded><![CDATA[<p>Chuck, thanks for the comment. It is nice to see Ruby 1.9 standardize this automatic conversion of symbols to blocks. I will update the article to include it.<br />
Actually, for new languages I think it is worth going one step further and completely unify things like symbols and blocks (what is now a symbol becomes a compact notation for a block). That&#8217;s how it works in F-Script and this is very useful.</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Beyond Blocks by has</title>
		<link>http://pmougin.wordpress.com/2009/11/17/beyond-blocks/#comment-594</link>
		<dc:creator>has</dc:creator>
		<pubDate>Fri, 20 Nov 2009 10:01:41 +0000</pubDate>
		<guid isPermaLink="false">http://pmougin.wordpress.com/?p=1207#comment-594</guid>
		<description>Well, okay; I&#039;ll give you that. You could in principle abstract over the Apple event mechanism to make it look like array programming. That said, trying to dress up Apple events (RPC+queries) as something they&#039;re not (OOP) is one of the reasons SB doesn&#039;t (and can&#039;t) work quite right. Aside from the inevitable impedance mismatch, there&#039;s the practical problem of dealing with all of the different scriptable applications that are out there and all of the variations in how they do business. 

For example, SB likes to dress up the &#039;make&#039; event as Cocoa-style object instantiation - i.e. alloc+init, and add to a collection - but if you try using -[SBElementArray addObject:] with iTunes, it barfs because -addObject: makes certain assumptions about how the &#039;make&#039; event&#039;s parameters should be formed, which are correct for Cocoa Scripting-based apps but often wrong for Carbon ones. 

FWIW, early versions of appscript also tried to impose heavier OO-like abstractions on Apple events, so I learned that lesson the hard way. Unlike SB, I had the luxury of being able to rewrite appscript into its current form, which is about as thin an abstraction as it can be without being unpleasant. 

If AE behaviours had been rigorously specced and enforced from the get-go, today&#039;s scriptable apps might not be so lamentably inconsistent in how they implement their APIs, and creating robust, reusable high-level abstractions over those APIs might then be relatively straightforward. But I really doubt anyone could abstract over the current mess without the resulting abstractions regularly springing leaks on unsuspecting users.


&lt;blockquote&gt;That being said, it is perfectly possible that, given the current state or even the whole approach of the Apple’s Scripting Bridge, appscript is a better Apple Event bridge. I’d love to see it support F-Script.&lt;/blockquote&gt;

I love to see that too. FWIW, the Appscript framework&#039;s AEM layer is deliberately language-agnostic, allowing other Cocoa-speaking languages to apply their own choice of high-level syntactic sugar on top - e.g. objc-appscript uses a static glue generator, while macruby-appscript (in svn) uses rb-appscript&#039;s #method_missing approach. Unfortunately, I don&#039;t have the time to do any more appscript ports for now (I can&#039;t even keep up on the existing ones), but if you or anyone else wants to give it a go I&#039;m always happy to provide whatever advice I can.</description>
		<content:encoded><![CDATA[<p>Well, okay; I&#8217;ll give you that. You could in principle abstract over the Apple event mechanism to make it look like array programming. That said, trying to dress up Apple events (RPC+queries) as something they&#8217;re not (OOP) is one of the reasons SB doesn&#8217;t (and can&#8217;t) work quite right. Aside from the inevitable impedance mismatch, there&#8217;s the practical problem of dealing with all of the different scriptable applications that are out there and all of the variations in how they do business. </p>
<p>For example, SB likes to dress up the &#8216;make&#8217; event as Cocoa-style object instantiation &#8211; i.e. alloc+init, and add to a collection &#8211; but if you try using -[SBElementArray addObject:] with iTunes, it barfs because -addObject: makes certain assumptions about how the &#8216;make&#8217; event&#8217;s parameters should be formed, which are correct for Cocoa Scripting-based apps but often wrong for Carbon ones. </p>
<p>FWIW, early versions of appscript also tried to impose heavier OO-like abstractions on Apple events, so I learned that lesson the hard way. Unlike SB, I had the luxury of being able to rewrite appscript into its current form, which is about as thin an abstraction as it can be without being unpleasant. </p>
<p>If AE behaviours had been rigorously specced and enforced from the get-go, today&#8217;s scriptable apps might not be so lamentably inconsistent in how they implement their APIs, and creating robust, reusable high-level abstractions over those APIs might then be relatively straightforward. But I really doubt anyone could abstract over the current mess without the resulting abstractions regularly springing leaks on unsuspecting users.</p>
<blockquote><p>That being said, it is perfectly possible that, given the current state or even the whole approach of the Apple’s Scripting Bridge, appscript is a better Apple Event bridge. I’d love to see it support F-Script.</p></blockquote>
<p>I love to see that too. FWIW, the Appscript framework&#8217;s AEM layer is deliberately language-agnostic, allowing other Cocoa-speaking languages to apply their own choice of high-level syntactic sugar on top &#8211; e.g. objc-appscript uses a static glue generator, while macruby-appscript (in svn) uses rb-appscript&#8217;s #method_missing approach. Unfortunately, I don&#8217;t have the time to do any more appscript ports for now (I can&#8217;t even keep up on the existing ones), but if you or anyone else wants to give it a go I&#8217;m always happy to provide whatever advice I can.</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Beyond Blocks by Rob Rix</title>
		<link>http://pmougin.wordpress.com/2009/11/17/beyond-blocks/#comment-591</link>
		<dc:creator>Rob Rix</dc:creator>
		<pubDate>Thu, 19 Nov 2009 08:57:08 +0000</pubDate>
		<guid isPermaLink="false">http://pmougin.wordpress.com/?p=1207#comment-591</guid>
		<description>I think it is more precisely an argument against closures in sequence comprehensions. There are also arguments for internalizing external iterators (e.g. for the sake of encapsulation), which has you reduce a multi-line closure into another higher-order sequence comprehension. The closure is still being used internally, if applicable, but the external interface uses HOM.

There are also arguments for using the highest-order abstraction that will accomplish what you need; in this case, as Philippe points out, array programming allows for optimizations that would be more explicit otherwise, like building a query to be sent to a database. (This isn’t impossible with closures in the presence of, say, sufficient syntax tree introspection; Ambition is one example of doing this with closures: http://ambition.rubyforge.org/ )

On the whole, I would definitely agree that HOM doesn’t replace closures any more than closures replace blocks. It’s fascinating to see what’s possible these days (:</description>
		<content:encoded><![CDATA[<p>I think it is more precisely an argument against closures in sequence comprehensions. There are also arguments for internalizing external iterators (e.g. for the sake of encapsulation), which has you reduce a multi-line closure into another higher-order sequence comprehension. The closure is still being used internally, if applicable, but the external interface uses HOM.</p>
<p>There are also arguments for using the highest-order abstraction that will accomplish what you need; in this case, as Philippe points out, array programming allows for optimizations that would be more explicit otherwise, like building a query to be sent to a database. (This isn’t impossible with closures in the presence of, say, sufficient syntax tree introspection; Ambition is one example of doing this with closures: <a href="http://ambition.rubyforge.org/" rel="nofollow">http://ambition.rubyforge.org/</a> )</p>
<p>On the whole, I would definitely agree that HOM doesn’t replace closures any more than closures replace blocks. It’s fascinating to see what’s possible these days (:</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Beyond Blocks by Chuck</title>
		<link>http://pmougin.wordpress.com/2009/11/17/beyond-blocks/#comment-589</link>
		<dc:creator>Chuck</dc:creator>
		<pubDate>Thu, 19 Nov 2009 08:40:03 +0000</pubDate>
		<guid isPermaLink="false">http://pmougin.wordpress.com/?p=1207#comment-589</guid>
		<description>As of Ruby 1.9, all of those samples along the lines of songs.collect {&#124;aSong&#124; aSong.name} and so on can be more concisely written as songs.map(&amp;:name). (The &amp;: is sugar for a block that just sends a single message to its argument, so it&#039;s somewhat similar to the simple syntax of higher-order messaging.)</description>
		<content:encoded><![CDATA[<p>As of Ruby 1.9, all of those samples along the lines of songs.collect {|aSong| aSong.name} and so on can be more concisely written as songs.map(&amp;:name). (The &amp;: is sugar for a block that just sends a single message to its argument, so it&#8217;s somewhat similar to the simple syntax of higher-order messaging.)</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Beyond Blocks by Craig Mirkan</title>
		<link>http://pmougin.wordpress.com/2009/11/17/beyond-blocks/#comment-588</link>
		<dc:creator>Craig Mirkan</dc:creator>
		<pubDate>Thu, 19 Nov 2009 06:34:52 +0000</pubDate>
		<guid isPermaLink="false">http://pmougin.wordpress.com/?p=1207#comment-588</guid>
		<description>Sorry, the first sentence of my previous comment should read:

I’m not sure I understand why the argument for HOM is an argument against closures.</description>
		<content:encoded><![CDATA[<p>Sorry, the first sentence of my previous comment should read:</p>
<p>I’m not sure I understand why the argument for HOM is an argument against closures.</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Beyond Blocks by Craig Mirkan</title>
		<link>http://pmougin.wordpress.com/2009/11/17/beyond-blocks/#comment-587</link>
		<dc:creator>Craig Mirkan</dc:creator>
		<pubDate>Thu, 19 Nov 2009 06:33:46 +0000</pubDate>
		<guid isPermaLink="false">http://pmougin.wordpress.com/?p=1207#comment-587</guid>
		<description>I&#039;m not sure I understand why the argument for HOM isn&#039;t an argument against closures.

Sequence comprehensions are only a small part of the usefulness of closures, and indeed, there&#039;s no reason that you can&#039;t apply syntactic sugaring to make them as clean as your examples above. Translating the final example to Scala:

for (song = 256) yield song.name

OR

songs filter (_.bitRate &gt;= 256) map (_.name)

Are either worse than F-Script&#039;s syntax?

songs name where: songs bitRate &gt;= 256

I&#039;d argue no, and moreover, the use of closures permits the use of multi-statement expressions.</description>
		<content:encoded><![CDATA[<p>I&#8217;m not sure I understand why the argument for HOM isn&#8217;t an argument against closures.</p>
<p>Sequence comprehensions are only a small part of the usefulness of closures, and indeed, there&#8217;s no reason that you can&#8217;t apply syntactic sugaring to make them as clean as your examples above. Translating the final example to Scala:</p>
<p>for (song = 256) yield song.name</p>
<p>OR</p>
<p>songs filter (_.bitRate &gt;= 256) map (_.name)</p>
<p>Are either worse than F-Script&#8217;s syntax?</p>
<p>songs name where: songs bitRate &gt;= 256</p>
<p>I&#8217;d argue no, and moreover, the use of closures permits the use of multi-statement expressions.</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Reprogram your Cocoa applications on the fly! by Reprogram Cocoa on the Fly &#171; Clark&#39;s Tech Blog</title>
		<link>http://pmougin.wordpress.com/2009/11/18/reprogram-your-cocoa-applications-on-the-fly/#comment-586</link>
		<dc:creator>Reprogram Cocoa on the Fly &#171; Clark&#39;s Tech Blog</dc:creator>
		<pubDate>Wed, 18 Nov 2009 23:58:18 +0000</pubDate>
		<guid isPermaLink="false">http://pmougin.wordpress.com/?p=1396#comment-586</guid>
		<description>[...] Reprogram Cocoa on the Fly. OK, that&#8217;s almost enough to get me to learn F-Script. I&#8217;ve been kind of dubious of its use until now. [...]</description>
		<content:encoded><![CDATA[<p>[...] Reprogram Cocoa on the Fly. OK, that&#8217;s almost enough to get me to learn F-Script. I&#8217;ve been kind of dubious of its use until now. [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Reprogram your Cocoa applications on the fly! by Reprogram Cocoa on the Fly : Mormon Metaphysics</title>
		<link>http://pmougin.wordpress.com/2009/11/18/reprogram-your-cocoa-applications-on-the-fly/#comment-585</link>
		<dc:creator>Reprogram Cocoa on the Fly : Mormon Metaphysics</dc:creator>
		<pubDate>Wed, 18 Nov 2009 23:57:56 +0000</pubDate>
		<guid isPermaLink="false">http://pmougin.wordpress.com/?p=1396#comment-585</guid>
		<description>[...] Reprogram Cocoa on the Fly. OK, that&#8217;s almost enough to get me to learn F-Script. I&#8217;ve been kind of dubious of its use until now. [...]</description>
		<content:encoded><![CDATA[<p>[...] Reprogram Cocoa on the Fly. OK, that&#8217;s almost enough to get me to learn F-Script. I&#8217;ve been kind of dubious of its use until now. [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Beyond Blocks by Philippe Mougin</title>
		<link>http://pmougin.wordpress.com/2009/11/17/beyond-blocks/#comment-583</link>
		<dc:creator>Philippe Mougin</dc:creator>
		<pubDate>Tue, 17 Nov 2009 21:42:20 +0000</pubDate>
		<guid isPermaLink="false">http://pmougin.wordpress.com/?p=1207#comment-583</guid>
		<description>Has, you raise an interesting question regarding speed optimization, but your conclusions about array programming are incorrect.

By expressing code at a relatively high level, array programming excels at providing under the hood, transparent speed optimizations. This is a well studied property of array languages. There is nothing in array programming that requires actually sending one event per track. On the contrary, because the intent of the code is expressed in terms of manipulations of whole collections, the array programming system can apply very efficient optimizations.

For example, in this particular situation related to generating Apple Events, F-Script can automatically translate the expression &lt;code&gt;songs name&lt;/code&gt; into the following Objective-C code: &lt;code&gt;[songs arrayByApplyingSelector:@selector(name)]&lt;/code&gt;. This code will lead to just one round trip between F-Script and iTunes. The same applies for the other messages such as &lt;code&gt;songs bitRate&lt;/code&gt;. This is just one possible approach, other optimizations (e.g., generating the equivalent of the AppleScript code you showed) are possible.

This optimization is not active by default, but you can activate it by recompiling F-Script after uncommenting the code related to SBElementArray in FSExecEngine.m and see that the queries get executed ultra quickly. The reason this is not on by default is a bug in the Scripting Bridge (it won&#039;t be news for you that some parts of it are half broken!). But regardless, the important point here is that from a programming model perspective, array programming does not leads to inefficient execution but is on the contrary an enabler for optimizations impossible or hard to do in classic &quot;one object at a time&quot; models. You can find more about this in the OOPAL paper referenced in the blog post.

That being said, it is perfectly possible that, given the current state or even the whole approach of the Apple&#039;s Scripting Bridge, appscript is a better Apple Event bridge. I&#039;d love to see it support F-Script.</description>
		<content:encoded><![CDATA[<p>Has, you raise an interesting question regarding speed optimization, but your conclusions about array programming are incorrect.</p>
<p>By expressing code at a relatively high level, array programming excels at providing under the hood, transparent speed optimizations. This is a well studied property of array languages. There is nothing in array programming that requires actually sending one event per track. On the contrary, because the intent of the code is expressed in terms of manipulations of whole collections, the array programming system can apply very efficient optimizations.</p>
<p>For example, in this particular situation related to generating Apple Events, F-Script can automatically translate the expression <code>songs name</code> into the following Objective-C code: <code>[songs arrayByApplyingSelector:@selector(name)]</code>. This code will lead to just one round trip between F-Script and iTunes. The same applies for the other messages such as <code>songs bitRate</code>. This is just one possible approach, other optimizations (e.g., generating the equivalent of the AppleScript code you showed) are possible.</p>
<p>This optimization is not active by default, but you can activate it by recompiling F-Script after uncommenting the code related to SBElementArray in FSExecEngine.m and see that the queries get executed ultra quickly. The reason this is not on by default is a bug in the Scripting Bridge (it won&#8217;t be news for you that some parts of it are half broken!). But regardless, the important point here is that from a programming model perspective, array programming does not leads to inefficient execution but is on the contrary an enabler for optimizations impossible or hard to do in classic &#8220;one object at a time&#8221; models. You can find more about this in the OOPAL paper referenced in the blog post.</p>
<p>That being said, it is perfectly possible that, given the current state or even the whole approach of the Apple&#8217;s Scripting Bridge, appscript is a better Apple Event bridge. I&#8217;d love to see it support F-Script.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
