<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Wisdom and Wonder &#187; Ruby</title>
	<atom:link href="http://www.wisdomandwonder.com/tag/ruby/feed" rel="self" type="application/rss+xml" />
	<link>http://www.wisdomandwonder.com</link>
	<description>Science and Philosophy</description>
	<lastBuildDate>Wed, 25 Jan 2012 05:09:54 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Calling Java Under Cygwin</title>
		<link>http://www.wisdomandwonder.com/link/5228/calling-java-under-cygwin</link>
		<comments>http://www.wisdomandwonder.com/link/5228/calling-java-under-cygwin#comments</comments>
		<pubDate>Sun, 12 Sep 2010 18:40:30 +0000</pubDate>
		<dc:creator>Grant</dc:creator>
				<category><![CDATA[Link]]></category>
		<category><![CDATA[Clojure]]></category>
		<category><![CDATA[Cygwin]]></category>
		<category><![CDATA[Emacs]]></category>
		<category><![CDATA[Ide]]></category>
		<category><![CDATA[Lisp]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://www.wisdomandwonder.com/?p=5228</guid>
		<description><![CDATA[While trying to set up Clojure under Cygwin I found that doing mixed-mode between Cygwin and Java isn&#8217;t very happy due to the &#8216;;&#8217; vs &#8216;:&#8217; in the classpath. This post (via this post) provided an obfuscated Ruby program to take care of that for you&#8230; thanks! #!/bin/ruby # Slightly obfuscated cygwin + windows java [...]]]></description>
			<content:encoded><![CDATA[<p>While trying to set up Clojure under Cygwin I found that doing mixed-mode between Cygwin and Java isn&#8217;t very happy due to the &#8216;;&#8217; vs &#8216;:&#8217; in the classpath.  </p>
<p><a href="http://whollyweirdwyrd.blogspot.com/2010/04/cygwin-tip-1.html">This</a> post (via this <a href="http://ketain.blogspot.com/2010/03/clojure-with-cygwin-emacs-on-windows.html">post</a>) provided an obfuscated Ruby program to take care of that for you&#8230; thanks!</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color: #000000; font-style: italic; ">#!/bin/ruby</span>
<span style="color: #000000; font-style: italic; "># Slightly obfuscated cygwin + windows java wrapper, automate cygpath</span>
&nbsp;
cpi = ARGV.index<span style="color: #000000; font-weight: bold; ">&#40;</span><span style="color: #000000; ">&quot;-cp&quot;</span><span style="color: #000000; font-weight: bold; ">&#41;</span> <span style="color: #000000; font-weight: bold; ">+</span> <span style="color: #000000; ">1</span>
cp = ARGV<span style="color: #000000; font-weight: bold; ">&#91;</span>cpi<span style="color: #000000; font-weight: bold; ">&#93;</span> <span style="color: #000000; ">if</span> cpi
&nbsp;
XBCP = <span style="color: #000000; ">&quot;-Xbootclasspath/a:&quot;</span>
&nbsp;
xbcpi = ARGV.index<span style="color: #000000; font-weight: bold; ">&#123;</span><span style="color: #000000; font-weight: bold; ">|</span>i<span style="color: #000000; font-weight: bold; ">|</span>i=~<span style="color: #000000; font-weight: bold; ">/</span>^<span style="color: #000000; font-style: italic; ">#{XBCP}.*/}</span>
xbcp = ARGV<span style="color: #000000; font-weight: bold; ">&#91;</span>xbcpi<span style="color: #000000; font-weight: bold; ">&#93;</span> <span style="color: #000000; ">if</span> xbcpi
&nbsp;
<span style="color: #000000; ">if</span> cp <span style="color: #000000; ">or</span> xbcpi
  <span style="color: #000000; ">def</span> convert_paths<span style="color: #000000; font-weight: bold; ">&#40;</span>paths<span style="color: #000000; font-weight: bold; ">&#41;</span>
    paths = paths.<span style="color: #000000; ">gsub</span><span style="color: #000000; font-weight: bold; ">&#40;</span><span style="color: #000000; ">':'</span>, <span style="color: #000000; ">';'</span><span style="color: #000000; font-weight: bold; ">&#41;</span>.<span style="color: #000000; ">split</span><span style="color: #000000; font-weight: bold; ">&#40;</span><span style="color: #000000; ">';'</span><span style="color: #000000; font-weight: bold; ">&#41;</span>
    paths.map<span style="color: #000000; font-weight: bold; ">&#123;</span><span style="color: #000000; font-weight: bold; ">|</span>p<span style="color: #000000; font-weight: bold; ">|</span><span style="color: #000000; ">`cygpath -aw #{p}`</span>.strip<span style="color: #000000; font-weight: bold; ">&#125;</span>.join <span style="color: #000000; ">';'</span>
  <span style="color: #000000; ">end</span>
  ARGV<span style="color: #000000; font-weight: bold; ">&#91;</span>cpi<span style="color: #000000; font-weight: bold; ">&#93;</span> = convert_paths<span style="color: #000000; font-weight: bold; ">&#40;</span>cp<span style="color: #000000; font-weight: bold; ">&#41;</span> <span style="color: #000000; ">if</span> cp
  ARGV<span style="color: #000000; font-weight: bold; ">&#91;</span>xbcpi<span style="color: #000000; font-weight: bold; ">&#93;</span> = XBCP <span style="color: #000000; font-weight: bold; ">+</span> convert_paths<span style="color: #000000; font-weight: bold; ">&#40;</span>xbcp.<span style="color: #000000; ">sub</span><span style="color: #000000; font-weight: bold; ">&#40;</span>XBCP, <span style="color: #000000; ">''</span><span style="color: #000000; font-weight: bold; ">&#41;</span><span style="color: #000000; font-weight: bold; ">&#41;</span> <span style="color: #000000; ">if</span> xbcp
<span style="color: #000000; ">end</span>
&nbsp;
java = <span style="color: #000000; ">'/cygdrive/c/Program Files/Java/jdk1.6.0_18/bin/java'</span>
cmd = <span style="color: #000000; font-weight: bold; ">&#91;</span>java<span style="color: #000000; font-weight: bold; ">&#93;</span>.concat ARGV
&nbsp;
<span style="color: #000000; ">def</span> e<span style="color: #000000; font-weight: bold; ">&#40;</span>s<span style="color: #000000; font-weight: bold; ">&#41;</span>; <span style="color: #000000; ">&quot;<span style="color: #000000; ">\&quot;</span>#{s.strip.gsub('&quot;</span><span style="color: #000000; ">','</span>\<span style="color: #000000; ">&quot;')}<span style="color: #000000; ">\&quot;</span>&quot;</span>; <span style="color: #000000; ">end</span>
&nbsp;
<span style="color: #000000; ">exec</span><span style="color: #000000; font-weight: bold; ">&#40;</span>cmd.map<span style="color: #000000; font-weight: bold; ">&#123;</span><span style="color: #000000; font-weight: bold; ">|</span>a<span style="color: #000000; font-weight: bold; ">|</span>e a<span style="color: #000000; font-weight: bold; ">&#125;</span>.join<span style="color: #000000; font-weight: bold; ">&#40;</span><span style="color: #000000; ">' '</span><span style="color: #000000; font-weight: bold; ">&#41;</span><span style="color: #000000; font-weight: bold; ">&#41;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.wisdomandwonder.com/link/5228/calling-java-under-cygwin/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Adding Soft Typing to Ruby</title>
		<link>http://www.wisdomandwonder.com/link/2969/adding-soft-typing-to-ruby</link>
		<comments>http://www.wisdomandwonder.com/link/2969/adding-soft-typing-to-ruby#comments</comments>
		<pubDate>Sat, 09 May 2009 20:02:25 +0000</pubDate>
		<dc:creator>Grant</dc:creator>
				<category><![CDATA[Link]]></category>
		<category><![CDATA[Programming Language]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://www.wisdomandwonder.com/?p=2969</guid>
		<description><![CDATA[Here is an interview with two of the Diamondback Ruby developers. You can read more about how there system works in this paper: Static Type Inference for Ruby. It is interesting that they took the approach to compromise by neither being too aggressive nor to permissive; in other words they wanted to make sure that [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://on-ruby.blogspot.com/2009/05/diamondback-ruby-interview.html">Here</a> is an interview with two of the <a href="http://www.cs.umd.edu/projects/PL/druby/index.html">Diamondback Ruby</a> developers. You can read more about how there system works in this paper: <a href="http://www.cs.umd.edu/projects/PL/druby/papers/druby-oops09.pdf">Static Type Inference for Ruby</a>.</p>
<p>It is interesting that they took the approach to compromise by neither being too aggressive nor to permissive; in other words they wanted to make sure that people would actually use the tool. As such, type inference is strong enough to detect type errors, but permissive enough to allow for the same variable to have a different type of object assigned to it within the flow (dynamic extent) of a single method. </p>
<p>Another nice feature is the addition of a contract system for cases where type inference would not work; the two primary examples being utilization of the built-in classes which are implemented in C or the use of eval. The contracts specify the behavior and the implementation needs to conform to it.</p>
<p>With things like Diamondback Ruby, <a href="http://docs.plt-scheme.org/guide/contract-boundaries.html">PLT Scheme Contracts</a>, and <a href="http://www.ccs.neu.edu/home/samth/typed-scheme/">Typed Scheme</a> (mentioned in the paper) becoming available; I wonder if the statically vs lately typed language arguments will eventually go away.</p>
<p>(via <a href="http://lambda-the-ultimate.org/node/3307">LtU</a>)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.wisdomandwonder.com/link/2969/adding-soft-typing-to-ruby/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Macros in Ruby</title>
		<link>http://www.wisdomandwonder.com/link/2614/macros-in-ruby</link>
		<comments>http://www.wisdomandwonder.com/link/2614/macros-in-ruby#comments</comments>
		<pubDate>Thu, 16 Apr 2009 00:26:40 +0000</pubDate>
		<dc:creator>Grant</dc:creator>
				<category><![CDATA[Link]]></category>
		<category><![CDATA[Macros]]></category>
		<category><![CDATA[Programming Language]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://www.wisdomandwonder.com/?p=2614</guid>
		<description><![CDATA[This looks like an interesting article about writing macros in Ruby.]]></description>
			<content:encoded><![CDATA[<p><a href="http://weblog.raganwald.com/2008/06/macros-hygiene-and-call-by-name-in-ruby.html">This</a> looks like an interesting article about writing macros in Ruby.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.wisdomandwonder.com/link/2614/macros-in-ruby/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Maglev Ruby</title>
		<link>http://www.wisdomandwonder.com/link/266/maglev-ruby</link>
		<comments>http://www.wisdomandwonder.com/link/266/maglev-ruby#comments</comments>
		<pubDate>Mon, 14 Jul 2008 01:09:40 +0000</pubDate>
		<dc:creator>Grant</dc:creator>
				<category><![CDATA[Link]]></category>
		<category><![CDATA[Programming Language]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://www.wisdomandwonder.com/link/266/maglev-ruby</guid>
		<description><![CDATA[Ruby is often compared to Smalltalk; and I&#8217;m sure a bunch of folks have always wondered when someone would implement Ruby either on top of Smalltalk (or even in a similar manner to Smalltalk, aka Rubinius). Avi Bryant wondered as such, and seems to have gotten a job out of it in producing Maglev Ruby [...]]]></description>
			<content:encoded><![CDATA[<p>Ruby is often compared to Smalltalk; and I&#8217;m sure a bunch of folks have always wondered when someone would implement Ruby either on top of Smalltalk (or even in a similar manner to Smalltalk, aka <a href="http://rubini.us/">Rubinius</a>). </p>
<p>Avi Bryant wondered as such, and seems to have gotten a job out of it in producing <a href="http://www.vimeo.com/1147409">Maglev Ruby</a> (it is a video).</p>
<p>Maglev seems to be the combination of a Ruby VM implemented along with a distributed, concurrent object system to support the needs of Ruby on Rails. </p>
<p>I heard Avi speak at OSCON 06, and he seems to be a nice fellow; I&#8217;ll be interested to see how this pans out.</p>
<p>Strangely, I haven&#8217;t heard Maglev mentioned by anyone I know, perhaps Ruby VMs aren&#8217;t interesting.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.wisdomandwonder.com/link/266/maglev-ruby/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Emacs influence on Ruby</title>
		<link>http://www.wisdomandwonder.com/link/104/emacs-influence-on-ruby</link>
		<comments>http://www.wisdomandwonder.com/link/104/emacs-influence-on-ruby#comments</comments>
		<pubDate>Sun, 20 Apr 2008 22:17:52 +0000</pubDate>
		<dc:creator>Grant</dc:creator>
				<category><![CDATA[Link]]></category>
		<category><![CDATA[Emacs]]></category>
		<category><![CDATA[Ide]]></category>
		<category><![CDATA[Programming Language]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://www.wisdomandwonder.com/link/104/emacs-influence-on-ruby</guid>
		<description><![CDATA[Who would&#8217;ve thought that Ruby&#8217;s block &#8216;end&#8217; keyword was created to facilitate Emacs? Oh man! When [Matz] was first starting out writing Ruby, he was coding the Emacs ruby-mode.el for it at the same time. He expressed some frustration with modes for other languages like Python and Pascal in which the editor could not look [...]]]></description>
			<content:encoded><![CDATA[<p>Who would&#8217;ve thought that <a href="http://technomancy.us/97">Ruby&#8217;s block &#8216;end&#8217; keyword was created to facilitate Emacs</a>? Oh man!</p>
<blockquote><p>When [Matz] was first starting out writing Ruby, he was coding the Emacs ruby-mode.el for it at the same time. He expressed some frustration with modes for other languages like Python and Pascal in which the editor could not look at a line of code and figure out where it should be indented to, so he resolved that Ruby as a language should not fall into that particular trap. With that in mind he chose the end keyword as a block delimiter so that it would be easier to write an Emacs mode for.</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://www.wisdomandwonder.com/link/104/emacs-influence-on-ruby/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Rubys Upto in a Scheme macro</title>
		<link>http://www.wisdomandwonder.com/article/21/rubys-upto-in-a-scheme-macro</link>
		<comments>http://www.wisdomandwonder.com/article/21/rubys-upto-in-a-scheme-macro#comments</comments>
		<pubDate>Thu, 27 Dec 2007 20:04:51 +0000</pubDate>
		<dc:creator>Grant</dc:creator>
				<category><![CDATA[Article]]></category>
		<category><![CDATA[Lisp]]></category>
		<category><![CDATA[Macros]]></category>
		<category><![CDATA[Programming Language]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Scheme]]></category>

		<guid isPermaLink="false">http://www.wisdomandwonder.com/article/21/ruby%e2%80%99s-upto-with-a-scheme-macro</guid>
		<description><![CDATA[For a lot of folks, Ruby has a syntax that is really irresistible. Iteration is one of the things in particular that is described as being quite simply, fun. Here is how it works: Pass a message to the integer start index which includes both the inclusive stop index and a single argument function that [...]]]></description>
			<content:encoded><![CDATA[<p>For a lot of folks, Ruby has a syntax that is really irresistible. Iteration is one of the things in particular that is described as being quite simply, fun. Here is how it works:</p>
<p><span id="more-21"></span></p>
<p>Pass a message to the integer start index which includes both the inclusive stop index and a single argument function that is to be called with the current index in the iteration. The implementation of this feature, which can be found <a href="http://ruby-doc.org/core/classes/Integer.src/M001158.html">here</a>, is written nearly as you would imagine, albeit in C. Here is how the code looks when you call this function:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color: #000000; ">1</span>.upto<span style="color: #000000; font-weight: bold; ">&#40;</span><span style="color: #000000; ">3</span><span style="color: #000000; font-weight: bold; ">&#41;</span> <span style="color: #000000; font-weight: bold; ">&#123;</span><span style="color: #000000; font-weight: bold; ">|</span>x<span style="color: #000000; font-weight: bold; ">|</span> <span style="color: #000000; ">printf</span> <span style="color: #000000; ">&quot;#{x}<span style="color: #000000; ">\n</span>&quot;</span><span style="color: #000000; font-weight: bold; ">&#125;</span>
<span style="color: #000000; ">1</span>
<span style="color: #000000; ">2</span>
<span style="color: #000000; ">3</span></pre></div></div>

<p>With my programmer’s glasses on this, I would say that this syntax feels nice. In fact, it feels nice enough to think about adding a feature like this to Scheme. Here is what I came up with:</p>

<div class="wp_syntax"><div class="code"><pre class="scheme" style="font-family:monospace;"><span style="color: #000000; font-weight: bold; ">&#40;</span><span style="color: #000000; ">define-syntax</span> from
  <span style="color: #000000; font-weight: bold; ">&#40;</span><span style="color: #000000; ">syntax-rules</span> <span style="color: #000000; font-weight: bold; ">&#40;</span>upto<span style="color: #000000; font-weight: bold; ">&#41;</span>
    <span style="color: #000000; font-weight: bold; ">&#40;</span><span style="color: #000000; font-weight: bold; ">&#40;</span>from x upto y fn<span style="color: #000000; font-weight: bold; ">&#41;</span>
     <span style="color: #000000; font-weight: bold; ">&#40;</span><span style="color: #000000; ">let</span> <span style="color: #000000; font-weight: bold; ">&#40;</span><span style="color: #000000; font-weight: bold; ">&#91;</span>finish <span style="color: #000000; font-weight: bold; ">&#40;</span>add1 y<span style="color: #000000; font-weight: bold; ">&#41;</span><span style="color: #000000; font-weight: bold; ">&#93;</span><span style="color: #000000; font-weight: bold; ">&#41;</span>
       <span style="color: #000000; font-weight: bold; ">&#40;</span><span style="color: #000000; ">let</span> loop <span style="color: #000000; font-weight: bold; ">&#40;</span><span style="color: #000000; font-weight: bold; ">&#91;</span>cur x<span style="color: #000000; font-weight: bold; ">&#93;</span><span style="color: #000000; font-weight: bold; ">&#41;</span>
         <span style="color: #000000; font-weight: bold; ">&#40;</span><span style="color: #000000; ">if</span> <span style="color: #000000; font-weight: bold; ">&#40;</span><span style="color: #000000; ">not</span> <span style="color: #000000; font-weight: bold; ">&#40;</span><span style="color: #000000; font-weight: bold; ">=</span> cur finish<span style="color: #000000; font-weight: bold; ">&#41;</span><span style="color: #000000; font-weight: bold; ">&#41;</span>
             <span style="color: #000000; font-weight: bold; ">&#40;</span><span style="color: #000000; ">begin</span>
               <span style="color: #000000; font-weight: bold; ">&#40;</span>fn cur<span style="color: #000000; font-weight: bold; ">&#41;</span>
               <span style="color: #000000; font-weight: bold; ">&#40;</span>loop <span style="color: #000000; font-weight: bold; ">&#40;</span>add1 cur<span style="color: #000000; font-weight: bold; ">&#41;</span><span style="color: #000000; font-weight: bold; ">&#41;</span><span style="color: #000000; font-weight: bold; ">&#41;</span><span style="color: #000000; font-weight: bold; ">&#41;</span><span style="color: #000000; font-weight: bold; ">&#41;</span><span style="color: #000000; font-weight: bold; ">&#41;</span><span style="color: #000000; font-weight: bold; ">&#41;</span><span style="color: #000000; font-weight: bold; ">&#41;</span><span style="color: #000000; font-weight: bold; ">&#41;</span></pre></div></div>

<p>Here is how the Ruby sample from above looks in Scheme.</p>

<div class="wp_syntax"><div class="code"><pre class="scheme" style="font-family:monospace;"><span style="color: #000000; font-weight: bold; ">&#40;</span>from <span style="color: #000000; ">1</span> upto <span style="color: #000000; ">3</span> <span style="color: #000000; font-weight: bold; ">&#40;</span>λ <span style="color: #000000; font-weight: bold; ">&#40;</span>x<span style="color: #000000; font-weight: bold; ">&#41;</span> <span style="color: #000000; font-weight: bold; ">&#40;</span>printf <span style="color: #000000; ">&quot;~a~n&quot;</span> x<span style="color: #000000; font-weight: bold; ">&#41;</span><span style="color: #000000; font-weight: bold; ">&#41;</span><span style="color: #000000; font-weight: bold; ">&#41;</span>
<span style="color: #000000; ">1</span>
<span style="color: #000000; ">2</span>
<span style="color: #000000; ">3</span></pre></div></div>

<p>What do you think? The two samples really don&#8217;t look all that different.</p>
<p>Grow-able languages are truly exciting. If you want to add a feature to the language, you add it. </p>
<p>Programming with grow-able languages takes you from “power-user” to <em>empowered-user</em>!</p>
<p>Which would you rather be?</p>
]]></content:encoded>
			<wfw:commentRss>http://www.wisdomandwonder.com/article/21/rubys-upto-in-a-scheme-macro/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

