<?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: Scala as a Scripting Language?</title>
	<atom:link href="http://www.codecommit.com/blog/scala/scala-as-a-scripting-language/feed" rel="self" type="application/rss+xml" />
	<link>http://www.codecommit.com/blog/scala/scala-as-a-scripting-language</link>
	<description>(permanently in beta)</description>
	<lastBuildDate>Mon, 09 Jan 2012 20:21:24 -0800</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Daniel Spiewak</title>
		<link>http://www.codecommit.com/blog/scala/scala-as-a-scripting-language/comment-page-1#comment-4355</link>
		<dc:creator>Daniel Spiewak</dc:creator>
		<pubDate>Sat, 29 Nov 2008 01:54:35 +0000</pubDate>
		<guid isPermaLink="false">http://www.codecommit.com/blog/scala/scala-as-a-scripting-language#comment-4355</guid>
		<description>@Fabio

Strange, but true!  It would help if inject were given a better name (like one that was, maybe, descriptive of what it does).  :-)</description>
		<content:encoded><![CDATA[<p>@Fabio</p>
<p>Strange, but true!  It would help if inject were given a better name (like one that was, maybe, descriptive of what it does).  <img src='http://www.codecommit.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Fabio Kung</title>
		<link>http://www.codecommit.com/blog/scala/scala-as-a-scripting-language/comment-page-1#comment-4354</link>
		<dc:creator>Fabio Kung</dc:creator>
		<pubDate>Sat, 29 Nov 2008 01:48:23 +0000</pubDate>
		<guid isPermaLink="false">http://www.codecommit.com/blog/scala/scala-as-a-scripting-language#comment-4354</guid>
		<description>Your article would be wonderful, if you just remove the Scala vs JRuby comparison. Five years of experience with Ruby and can&#039;t remember inject? Oh, c&#039;mon...</description>
		<content:encoded><![CDATA[<p>Your article would be wonderful, if you just remove the Scala vs JRuby comparison. Five years of experience with Ruby and can&#8217;t remember inject? Oh, c&#8217;mon&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Det</title>
		<link>http://www.codecommit.com/blog/scala/scala-as-a-scripting-language/comment-page-1#comment-4316</link>
		<dc:creator>Det</dc:creator>
		<pubDate>Tue, 18 Nov 2008 07:35:05 +0000</pubDate>
		<guid isPermaLink="false">http://www.codecommit.com/blog/scala/scala-as-a-scripting-language#comment-4316</guid>
		<description>&gt; I’ve probably written a lot more Ruby than I have Scala. I’ve certainly been using that language longer. 
&gt; So if I still can’t remember basic collections methods like #inject after *5 years* of experience with 
&gt; the language, I’m either a little slower than most or the libraries just aren’t consistently organized.

I think this has totally another reason:  Ruby started to be the &quot;better Perl&quot; and was heavily pushed by showing that it really is. The backtick solution of Jules (shell exec) is a typical example of that style of influence. Beside that, Ruby was introduced as &quot;truly object oriented&quot;, targeting at Java, leaving behind Python and especially the Perl OO.  Functional style was never really discussed in Ruby communities, unless in niche threads.

OTOH Scala was introduced as being &quot;functional&quot; (beside OO) and all focus was on documenting what that means, how this is applied a.s.o. (among that your article, covering &quot;functional scripting&quot; ;-) ).

No wonder, that people grown up with such documentation background end thinking imperatively or object-imperatively in Ruby, whilst they are driven to think functional in Scala.

You have to explicitly think about &quot;functional Ruby&quot; to approach the API from this perspective.</description>
		<content:encoded><![CDATA[<p>&gt; I’ve probably written a lot more Ruby than I have Scala. I’ve certainly been using that language longer.<br />
&gt; So if I still can’t remember basic collections methods like #inject after *5 years* of experience with<br />
&gt; the language, I’m either a little slower than most or the libraries just aren’t consistently organized.</p>
<p>I think this has totally another reason:  Ruby started to be the &#8220;better Perl&#8221; and was heavily pushed by showing that it really is. The backtick solution of Jules (shell exec) is a typical example of that style of influence. Beside that, Ruby was introduced as &#8220;truly object oriented&#8221;, targeting at Java, leaving behind Python and especially the Perl OO.  Functional style was never really discussed in Ruby communities, unless in niche threads.</p>
<p>OTOH Scala was introduced as being &#8220;functional&#8221; (beside OO) and all focus was on documenting what that means, how this is applied a.s.o. (among that your article, covering &#8220;functional scripting&#8221; <img src='http://www.codecommit.com/blog/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' />  ).</p>
<p>No wonder, that people grown up with such documentation background end thinking imperatively or object-imperatively in Ruby, whilst they are driven to think functional in Scala.</p>
<p>You have to explicitly think about &#8220;functional Ruby&#8221; to approach the API from this perspective.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Daniel Spiewak</title>
		<link>http://www.codecommit.com/blog/scala/scala-as-a-scripting-language/comment-page-1#comment-4282</link>
		<dc:creator>Daniel Spiewak</dc:creator>
		<pubDate>Sat, 08 Nov 2008 20:07:54 +0000</pubDate>
		<guid isPermaLink="false">http://www.codecommit.com/blog/scala/scala-as-a-scripting-language#comment-4282</guid>
		<description>Oh, I&#039;m backwards:

for (f &lt;- myDir.listFiles; if !f.isDrectory) {
// do your thing…
}</description>
		<content:encoded><![CDATA[<p>Oh, I&#8217;m backwards:</p>
<p>for (f <- myDir.listFiles; if !f.isDrectory) {<br />
// do your thing…<br />
}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Daniel Spiewak</title>
		<link>http://www.codecommit.com/blog/scala/scala-as-a-scripting-language/comment-page-1#comment-4281</link>
		<dc:creator>Daniel Spiewak</dc:creator>
		<pubDate>Sat, 08 Nov 2008 20:07:27 +0000</pubDate>
		<guid isPermaLink="false">http://www.codecommit.com/blog/scala/scala-as-a-scripting-language#comment-4281</guid>
		<description>&gt; It’s strange that there isn’t a built-in way to iterate over all files 
&gt; in a directory in either Ruby or Scala (I could be wrong). You
&gt; almost always want to get the files, not directories.

I suspect this is partially because most operating systems treat files and directories identically under the surface.  Ever wonder why directories need to have the executable bit set in order to allow cd?  That&#039;s it.  :-)

As to a built-in mechanism, I think the Java 7 NIO&lt;sup&gt;2&lt;/sup&gt; will have something like this.  But until then, you can do the following in Scala:

for (f &lt;- myDir.listFiles; if f.isDrectory) {
  // do your thing...
}</description>
		<content:encoded><![CDATA[<p>&gt; It’s strange that there isn’t a built-in way to iterate over all files<br />
&gt; in a directory in either Ruby or Scala (I could be wrong). You<br />
&gt; almost always want to get the files, not directories.</p>
<p>I suspect this is partially because most operating systems treat files and directories identically under the surface.  Ever wonder why directories need to have the executable bit set in order to allow cd?  That&#8217;s it.  <img src='http://www.codecommit.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p>As to a built-in mechanism, I think the Java 7 NIO<sup>2</sup> will have something like this.  But until then, you can do the following in Scala:</p>
<p>for (f <- myDir.listFiles; if f.isDrectory) {<br />
  // do your thing&#8230;<br />
}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jules</title>
		<link>http://www.codecommit.com/blog/scala/scala-as-a-scripting-language/comment-page-1#comment-4280</link>
		<dc:creator>Jules</dc:creator>
		<pubDate>Sat, 08 Nov 2008 19:58:54 +0000</pubDate>
		<guid isPermaLink="false">http://www.codecommit.com/blog/scala/scala-as-a-scripting-language#comment-4280</guid>
		<description>Here&#039;s how you can count lines in a file with Ruby:

n = 0
IO.foreach(fname){&#124;line&#124; n += 1}

&gt;  If we just go off LoC (Lines of Code), Scala actually wins here.  This was a more-than-slightly surprising discovery for me [...]

Could it be that your Scala program is shorter because you know Scala better?

&gt; On the readability score, I think Scala wins here too.  The file processing and set creation is all done in a highly functional style (using foldLeft).   At least to my eyes, this is a lot easier to follow than the imperative form in Ruby. 

I don&#039;t agree with this.

val init = new BloomSet[String](optimalM, optimalK)
val set = src.reset.getLines.foldLeft(init) { _ + _.trim }

I find this less readable than the Ruby version:

set = BloomSet.new(optimal_m, optimal_k)
IO.foreach(fname){&#124;line&#124; set += line.strip}

And less writable too (mostly because I can&#039;t remember the order of arguments to fold).

So while I don&#039;t agree with everything you said, this is a very good article. Keep it up :)

It&#039;s strange that there isn&#039;t a built-in way to iterate over all files in a directory in either Ruby or Scala (I could be wrong). You almost always want to get the files, not directories.</description>
		<content:encoded><![CDATA[<p>Here&#8217;s how you can count lines in a file with Ruby:</p>
<p>n = 0<br />
IO.foreach(fname){|line| n += 1}</p>
<p>&gt;  If we just go off LoC (Lines of Code), Scala actually wins here.  This was a more-than-slightly surprising discovery for me [...]</p>
<p>Could it be that your Scala program is shorter because you know Scala better?</p>
<p>&gt; On the readability score, I think Scala wins here too.  The file processing and set creation is all done in a highly functional style (using foldLeft).   At least to my eyes, this is a lot easier to follow than the imperative form in Ruby. </p>
<p>I don&#8217;t agree with this.</p>
<p>val init = new BloomSet[String](optimalM, optimalK)<br />
val set = src.reset.getLines.foldLeft(init) { _ + _.trim }</p>
<p>I find this less readable than the Ruby version:</p>
<p>set = BloomSet.new(optimal_m, optimal_k)<br />
IO.foreach(fname){|line| set += line.strip}</p>
<p>And less writable too (mostly because I can&#8217;t remember the order of arguments to fold).</p>
<p>So while I don&#8217;t agree with everything you said, this is a very good article. Keep it up <img src='http://www.codecommit.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>It&#8217;s strange that there isn&#8217;t a built-in way to iterate over all files in a directory in either Ruby or Scala (I could be wrong). You almost always want to get the files, not directories.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Daniel Spiewak</title>
		<link>http://www.codecommit.com/blog/scala/scala-as-a-scripting-language/comment-page-1#comment-4274</link>
		<dc:creator>Daniel Spiewak</dc:creator>
		<pubDate>Mon, 03 Nov 2008 22:26:16 +0000</pubDate>
		<guid isPermaLink="false">http://www.codecommit.com/blog/scala/scala-as-a-scripting-language#comment-4274</guid>
		<description>@Charles

Ah, very clever!  I was unaware of those handy conversion methods.  I seem to remember a ClassCastException arising from some dynamic JVM language (not necessarily JRuby) passing objects of the wrong type into a Java method, thus I assumed that the result would be the same here.

In any case, the code given was still not going to work.  There certainly were more concise ways that I could have written the Ruby code...mostly because I wasn&#039;t aware of them.  However, that doesn&#039;t really affect my point.  I was trying to illustrate how Ruby and Scala aren&#039;t really too far separated in concision, contrary to popular perception of statically typed languages.  In fact, even if Scala *were* significantly more concise than Ruby for this script, it wouldn&#039;t mean anything.  This script was interacting with a Java (actually, Scala) API for most of its functionality.  *Naturally* Scala is going to be a little more in its element than Ruby.  It&#039;s a credit to JRuby&#039;s Java integration that the script was as concise as it was.</description>
		<content:encoded><![CDATA[<p>@Charles</p>
<p>Ah, very clever!  I was unaware of those handy conversion methods.  I seem to remember a ClassCastException arising from some dynamic JVM language (not necessarily JRuby) passing objects of the wrong type into a Java method, thus I assumed that the result would be the same here.</p>
<p>In any case, the code given was still not going to work.  There certainly were more concise ways that I could have written the Ruby code&#8230;mostly because I wasn&#8217;t aware of them.  However, that doesn&#8217;t really affect my point.  I was trying to illustrate how Ruby and Scala aren&#8217;t really too far separated in concision, contrary to popular perception of statically typed languages.  In fact, even if Scala *were* significantly more concise than Ruby for this script, it wouldn&#8217;t mean anything.  This script was interacting with a Java (actually, Scala) API for most of its functionality.  *Naturally* Scala is going to be a little more in its element than Ruby.  It&#8217;s a credit to JRuby&#8217;s Java integration that the script was as concise as it was.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Charles Oliver Nutter</title>
		<link>http://www.codecommit.com/blog/scala/scala-as-a-scripting-language/comment-page-1#comment-4273</link>
		<dc:creator>Charles Oliver Nutter</dc:creator>
		<pubDate>Mon, 03 Nov 2008 22:17:25 +0000</pubDate>
		<guid isPermaLink="false">http://www.codecommit.com/blog/scala/scala-as-a-scripting-language#comment-4273</guid>
		<description>Daniel: Do not speak about what you have not tried. Passing a Ruby File to a method that takes OutputStream does not ClassCastException, it raises a Ruby error saying it does not know how to automatically convert a Ruby File to an OutputStream. And then you can turn around and do this

set.store file.to_outputstream

This will take the &quot;out&quot; channel of the File object and present it as an output stream suitable for any Java API. There&#039;s also to_inputstream and to_channel.</description>
		<content:encoded><![CDATA[<p>Daniel: Do not speak about what you have not tried. Passing a Ruby File to a method that takes OutputStream does not ClassCastException, it raises a Ruby error saying it does not know how to automatically convert a Ruby File to an OutputStream. And then you can turn around and do this</p>
<p>set.store file.to_outputstream</p>
<p>This will take the &#8220;out&#8221; channel of the File object and present it as an output stream suitable for any Java API. There&#8217;s also to_inputstream and to_channel.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Daniel Spiewak</title>
		<link>http://www.codecommit.com/blog/scala/scala-as-a-scripting-language/comment-page-1#comment-4272</link>
		<dc:creator>Daniel Spiewak</dc:creator>
		<pubDate>Mon, 03 Nov 2008 22:07:23 +0000</pubDate>
		<guid isPermaLink="false">http://www.codecommit.com/blog/scala/scala-as-a-scripting-language#comment-4272</guid>
		<description>&gt; Is this the right way to set this in scala?

Good question.  :-)  I don&#039;t think so.  To be safe, try it like this:

java -Xms8m -cp ${SCALA_HOME}/lib/scala-library.jar HelloWorld

You may have to use HelloWorld$ as the main class if your main object has a companion class.</description>
		<content:encoded><![CDATA[<p>&gt; Is this the right way to set this in scala?</p>
<p>Good question.  <img src='http://www.codecommit.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' />   I don&#8217;t think so.  To be safe, try it like this:</p>
<p>java -Xms8m -cp ${SCALA_HOME}/lib/scala-library.jar HelloWorld</p>
<p>You may have to use HelloWorld$ as the main class if your main object has a companion class.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: reck</title>
		<link>http://www.codecommit.com/blog/scala/scala-as-a-scripting-language/comment-page-1#comment-4271</link>
		<dc:creator>reck</dc:creator>
		<pubDate>Mon, 03 Nov 2008 22:02:38 +0000</pubDate>
		<guid isPermaLink="false">http://www.codecommit.com/blog/scala/scala-as-a-scripting-language#comment-4271</guid>
		<description>I tried to run it like this and it didn&#039;t seem to have any effect (it always used about 18MB)

$ scala -DXms8m HelloWorld
and
$ scala -DXms128m HelloWorld

Is this the right way to set this in scala?</description>
		<content:encoded><![CDATA[<p>I tried to run it like this and it didn&#8217;t seem to have any effect (it always used about 18MB)</p>
<p>$ scala -DXms8m HelloWorld<br />
and<br />
$ scala -DXms128m HelloWorld</p>
<p>Is this the right way to set this in scala?</p>
]]></content:encoded>
	</item>
</channel>
</rss>

