<?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>The long way round... &#187; ruby</title>
	<atom:link href="http://www.clevegibbon.com/wordpress/category/ruby/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.clevegibbon.com/wordpress</link>
	<description>Stuff you pick up on the way...</description>
	<lastBuildDate>Tue, 02 Jun 2009 05:11:10 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Ruby is the R in Rails</title>
		<link>http://www.clevegibbon.com/wordpress/2008/06/11/ruby-is-the-r-in-rails/</link>
		<comments>http://www.clevegibbon.com/wordpress/2008/06/11/ruby-is-the-r-in-rails/#comments</comments>
		<pubDate>Wed, 11 Jun 2008 08:46:22 +0000</pubDate>
		<dc:creator>Cleve Gibbon</dc:creator>
				<category><![CDATA[cognifide]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[scalability]]></category>

		<guid isPermaLink="false">http://www.clevegibbon.com/wordpress/archives/106</guid>
		<description><![CDATA[I would love to have attended RailsConf 2008 but alas you can only do so much in a day.  Although this was a Rails conference, it seems that this year there was less talk about Rails and more about Ruby.  This is hardly surprising really given that Rails is just a web framework. [...]]]></description>
			<content:encoded><![CDATA[<p>I would love to have attended <a href="http://en.oreilly.com/rails2008/public/content/home">RailsConf 2008</a> but alas you can only do so much in a day.  Although this was a Rails conference, it seems that this year there was less talk about Rails and more about Ruby.  This is hardly surprising really given that Rails is just a web framework.  Yep, Rails is just a web framework.  And just like any other web framework, its serves as a gateway from the web and into your enterprise.  Now, after a year of doing Rails, you&#8217;re basically done.  Coasting.  Yes, there are tips and tricks you can pick up along the way but for all intense purposes you&#8217;ve got the badge.  You&#8217;re done. You know Rails. </p>
<p>Now the more pressing problems and prickly questions around the enterprise, integration and scalability need to be addressed and this is where Ruby is  amore compelling story.  In fact, things in the Ruby space are really moving forward at break neck speed.  It&#8217;s not surprising really, given the relatively few Ruby conferences there are each year, that Ruby gets to play out and steal some of Rail&#8217;s thunder at RailConf.</p>
<p>So what is going on in Ruby space that&#8217;s so interesting?</p>
<p><strong>Ruby Implementations &#8211; Where integration is Key</strong></p>
<p>First up there&#8217;s <a href="http://jruby.codehaus.org/">JRuby</a>.  This is a 100% pure Java implementation of the Ruby programming language.  And right there is JRuby&#8217;s sweet spot.  The ability to seamlessly integrate with the Java platform through Ruby is a big win for some.  So running Rails under JRuby and using it as a web gateway into your Java enterprise, together with the ability to leverage mature/known Java tools and the free performance hikes that accompany it has been a very appealing proposition to some.  A prime example being the <a href="http://studios.thoughtworks.com/mingle-project-intelligence">ThoughtWorks Mingle</a> product.  Also, having access to the abstract syntax tree which can be shared between multiple Ruby runtimes hosted within the same JVM process is pretty neat and a highly efficient way of managing memory.</p>
<p><a href="http://ruby.macosforge.org/trac/wiki/MacRuby">MacRuby</a>!  As a Mac User I&#8217;m excited by this implementation of Ruby 1.9.  With MacRuby you can write Mac OS X applications in Ruby without the performance hit typically attributed to standard Ruby and Ruby Cocoa.   MacRuby is native to Mac OS X core technologies.  Damned quick with all the elegance of Ruby to boot.  </p>
<p><a href="http://www.ironruby.net/">IronRuby</a>, backed my Microsoft and sits on top of its Dynamic Language Runtime (check out <a href="http://www.microsoft.com/Downloads/details.aspx?FamilyID=b2a28e91-4ee3-4a79-8900-e4de253950bd&amp;displaylang=en">John Lam&#8217;s</a> talk on the DLR), is a .NET implemention of Ruby.  IronRuby enables Ruby programmers seamlessly integrate with the .NET platform, in much the same way that JRuby does on the Java platform.  <a href="http://rubydotnet.googlegroups.com/web/Home.htm">Ruby.NET</a> is open source .NET implementation that does not have the same pull as IronRuby.</p>
<p>In fact, the main draw for Ruby developers that target JRuby, MacRuby, Ruby.NET or IronRuby is integration with the Java, Mac OS X or .NET plaforms respectively.</p>
<p><strong>Ruby implementations &#8211; Standards are key</strong></p>
<p>Let&#8217;s park integration.  Let&#8217;s focus upon Ruby developers building Ruby apps with an Ruby-oriented environment.  Both <a href="http://rubini.us/">Rubinius</a> (a spec led Ruby implementation) and<a href="http://ruby-lang.org/en/about"> MRI</a>/<a href="http://www.atdot.net/yarv/">YARV</a> (currently the official Ruby) are competing VMs for running Ruby applications.  Everyone started with Matzs Ruby Interpreter  (MRI) but now we have many more alternatives.  The Yet Another Ruby VM (YARV) project has officially merged into MRI as of May 2008 to combine the best of both worlds to enhance the official Ruby implementation.</p>
<p><strong>RubySpec</p>
<p></strong>But unlike Smalltalk that was really killed by competing implementations, the Ruby community, through <a href="http://rubyspec.org/">RubySpec</a> are collaborating on standards and competing on implementation.  This is good.  No, hold up, this is great! This will hopefully provide more choice to the developers to select the appropriate Ruby implementation that best fits their solution requirements.  Hopefully, this will hold the community together and keep everyone pulling in the same direction.  So far, that appears to be the case&#8230;</p>
<p><strong>..but then there was Ruby for Scale &#8211; Maglev<br />
</strong><br />
<a href="http://ruby.gemstone.com/">Maglev</a> is a Ruby implementation built on top of Gemstone&#8217;s VM that is written in Smalltalk.  <a href="http://www.chadfowler.com/2008/6/5/maglev">Chad Fowler</a> goes into the why and when you would choose to use this Ruby implementation other the others.  But the problem is very few people have access to Maglev.  It promises the world and come on guys its time to <em>show me the money</em>!  The community has seen is a presentation.  A damned fine presentation I&#8217;m told but <a href="http://headius.blogspot.com/2008/06/maglev.html">Charles Nutter </a>of JRuby is not convinced and <a href="http://fukamachi.org/wp/2008/06/02/maglev-and-the-naiivety-of-the-rails-community/">other people</a> are already dismissing outright Maglev&#8217;s claim to scale.  100 times performance improvement is a big claim.   One to watch I guess.</p>
<p><strong>And Finally!</strong></p>
<p>Take a look at the following code snippet:</p>
<pre>#!/usr/local/bin/ruby

require 'scalability'

# your code
</pre>
<p>Now the Twitter guys must be get this all the time.  Twitter is growing in size and its architecture will mature and incorporate different technologies I&#8217;m sure that best fits their current problems.  Time will time.  But to say its Ruby&#8217;s fault is a little naive at best.  That said, wouldn&#8217;t it be just great if only you could <strong><em>include scalability</em></strong> in Ruby applications, Java apps, .NET apps, or whatever the platform.  </p>
<p>Now, that would be awesome.  But the simple fact is you can&#8217;t include it, you have design it in.  Boooooo say the crowd.  Kill joy chant the business.  But unfortunately, like so many things in the software industry, you have to go <em>the long way round (read as experience) </em>to get desired results.   Because there are no short cuts (<em>read as foolish hacks, or inexperience</em>) on the road to scalability&#8230;only blood, sweat and tears!  But there are leg ups, tools and techniques and people to assist, but that&#8217;s any story for another day&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.clevegibbon.com/wordpress/2008/06/11/ruby-is-the-r-in-rails/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>The Beauty of Ruby</title>
		<link>http://www.clevegibbon.com/wordpress/2008/04/16/the-beauty-of-ruby/</link>
		<comments>http://www.clevegibbon.com/wordpress/2008/04/16/the-beauty-of-ruby/#comments</comments>
		<pubDate>Wed, 16 Apr 2008 21:20:19 +0000</pubDate>
		<dc:creator>Cleve Gibbon</dc:creator>
				<category><![CDATA[development]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://www.clevegibbon.com/wordpress/archives/98</guid>
		<description><![CDATA[I&#8217;m more of a fan of Ruby than Rails.  Sure Rails is good, but Ruby is way better.  I&#8217;m trying to put some time aside to learn a little bit of Polish.  As a result, I was a frequent visitor to www.dict.pl.  After a couple of days of using this, I&#8217;d [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m more of a fan of Ruby than Rails.  Sure Rails is good, but Ruby is way better.  I&#8217;m trying to put some time aside to learn a little bit of Polish.  As a result, I was a frequent visitor to <a href="http://www.dict.pl">www.dict.pl</a>.  After a couple of days of using this, I&#8217;d had enough.  Too slow.  Too restrictive.  Too crap!  Time to turn this around.</p>
<p>I wrote a simple English-&gt;Polish translator application in Ruby.  It does all the usual stuff such as add new words, search for words in either language, and maintain the words in named bundles.   The challenge I set myself as a novice Ruby programmer was to implement the core set of features knowing that the code would be fat and not very pretty.  I then aggressively sort to refactor the code to reduce its size, whilst <strong><em>increasing</em></strong> the feature set. </p>
<p>The core translation engine started out as 120 lines of code with just the add new word feature.  Since then I&#8217;ve learnt a lot about how to structure Ruby programs and the effective use of closures, iterators, containers and yaml.  In the process, I&#8217;ve added search, display and bi-directional features to the translation engine and reduced the lines of code to 114.</p>
<p>I have a new found respect for Ruby the Language.  It is the most expressive language I played within in a long time.  Also, contrary to what many non-Ruby programmers tell me, Ruby is readable when written well.  Unfortunately, on my travels through the web, I have seen some really awful Ruby code and this stuff is truly poisonous.  Bad Ruby is completely unfathomable.  A ticking time bomb.  However, well-written is Ruby is sublime.  I truly believe that there are no shades of grey here <img src='http://www.clevegibbon.com/wordpress/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.clevegibbon.com/wordpress/2008/04/16/the-beauty-of-ruby/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Heroku!</title>
		<link>http://www.clevegibbon.com/wordpress/2008/02/20/heroku/</link>
		<comments>http://www.clevegibbon.com/wordpress/2008/02/20/heroku/#comments</comments>
		<pubDate>Wed, 20 Feb 2008 22:24:00 +0000</pubDate>
		<dc:creator>Cleve Gibbon</dc:creator>
				<category><![CDATA[development]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://www.clevegibbon.com/wordpress/archives/84</guid>
		<description><![CDATA[I&#8217;ve found Heroku!  
Heroku allows me to build and deploy Rails applications.  It couldn&#8217;t have happened at a better time for me because my current provider doesn&#8217;t give me what I need re. Ruby and Rails.  So I took the following steps:
1) Registered with Heroku
2) When I got my sign-up email, I [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve found <a href="http://heroku.com/">Heroku!</a>  </p>
<p>Heroku allows me to build and deploy Rails applications.  It couldn&#8217;t have happened at a better time for me because my current provider doesn&#8217;t give me what I need re. Ruby and Rails.  So I took the following steps:</p>
<p>1) Registered with Heroku<br />
2) When I got my sign-up email, I zipped up my Rails app (removing the .svn directories, tmp and log folders)<br />
3) Uploaded to Heroku<br />
4) Then run it</p>
<p>The application is a re-write of <a href="http://www.clevegibbon.com">http://www.clevegibbon.com</a> and can be found here <a href="http://clevegibbon.heroku.com">http://clevegibbon.heroku.com</a>.  I&#8217;ll evolve it there.</p>
<p>Heroku is novel. Stunningly simple.  Very expressive. </p>
<p>Sweet!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.clevegibbon.com/wordpress/2008/02/20/heroku/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Bully Boy Ruby&#8230;</title>
		<link>http://www.clevegibbon.com/wordpress/2008/02/19/bully-boy-ruby/</link>
		<comments>http://www.clevegibbon.com/wordpress/2008/02/19/bully-boy-ruby/#comments</comments>
		<pubDate>Tue, 19 Feb 2008 19:17:50 +0000</pubDate>
		<dc:creator>Cleve Gibbon</dc:creator>
				<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://www.clevegibbon.com/wordpress/archives/83</guid>
		<description><![CDATA[I&#8217;ve had an uncomfortable week with Ruby.  I&#8217;ve been reading blogs, articles and excerpts from books.  Scanning irc channels and watching videos on what is ruby and where it is going.  However, there is a distinct bullying undertone from this new kid on the block and Java is clearly the target.  [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve had an uncomfortable week with Ruby.  I&#8217;ve been reading blogs, articles and excerpts from books.  Scanning irc channels and watching videos on what is ruby and where it is going.  However, there is a distinct bullying undertone from this new kid on the block and Java is clearly the target.  I don&#8217;t understand this mentality.</p>
<p>Yes, I find Ruby liberating as programming language.  I find that you can express yourself more succinctly in Ruby than you can in Java.  Also, the speed at which you can accomplish stuff keeps me wanting to learn how I can get the most from Ruby.  However, when you hear Ruby guys bang on about how &#8216;crap&#8217; Java is and/or ex Java programmers that have found Ruby but do not have a good word to say about Java anymore, its a bit much.  Fine, you think Ruby is better Java.  No problem there.  But to bash Java, to promote Ruby&#8230;</p>
<p>Java is still a major player on the server-side.  JRuby is a clear indicator of Ruby standing (not crapping) on the shoulder of giants.  JRuby is a great way of scripting your Java applications. Just imagine if IBM had made the forward looking decision to use/create JRuby instead of Jython for scripting its WebSphere Application Server Platform.  Now there&#8217;s a thought&#8230;</p>
<p>In my mind, Ruby is not enterprise ready for the masses.  In fact, I would also go so far to say that Ruby is not a language that will appeal to the masses in the same way that Java and .NET do today.  Only a few days back, I was playing with Ruby and a Java/.NET programmer sitting next to me blurted out, &#8220;ugh, what is that?&#8221;  That my friend, is Ruby!  And no, it was not that my code.  It is just that Ruby looks obscure to the untrained eye.  When I read my first full page of Ruby code, it was daunting.  But that goes after a while.  Practice and all that. However, I never that feel when I learnt other languages such as Smalltalk, C, Ada, Eiffel, Objective-C, C++, Java or .NET.</p>
<p>Ruby is a sharp tool, for sharp people.  What do you think happens when you put sharp tools in the hands of the masses?  The Ruby community needs to be on-hand with the bandages to nurse the us through our first painful exposures to Ruby the language and its tools/frameworks.  I hope they do this.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.clevegibbon.com/wordpress/2008/02/19/bully-boy-ruby/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>RSpec: automated testing and then manual testing.  It works!</title>
		<link>http://www.clevegibbon.com/wordpress/2008/01/22/rspec-automated-testing-and-then-manual-testing-it-works/</link>
		<comments>http://www.clevegibbon.com/wordpress/2008/01/22/rspec-automated-testing-and-then-manual-testing-it-works/#comments</comments>
		<pubDate>Tue, 22 Jan 2008 15:59:10 +0000</pubDate>
		<dc:creator>cleve</dc:creator>
				<category><![CDATA[development]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[testing]]></category>

		<guid isPermaLink="false">http://www.clevegibbon.com/wordpress/?p=74</guid>
		<description><![CDATA[I think I have caught the Ruby bug (always last to the party cleve, always the last to arrive!) in a big way.  In between my day job, I have been reading (Programming Ruby, Agile Web Development with Rails, Everyday Scripting with Ruby) and writing (currently re-writing clevegibbon.com) Ruby.  However, today I was [...]]]></description>
			<content:encoded><![CDATA[<p>I think I have caught the Ruby bug (always last to the party cleve, always the last to arrive!) in a big way.  In between my day job, I have been reading (<a href="http://www.pragprog.com/titles/ruby">Programming Ruby</a>, <a href="http://www.pragprog.com/titles/rails2">Agile Web Development with Rails</a>, <a href="http://www.pragprog.com/titles/bmsft">Everyday Scripting with Ruby</a>) and writing (currently re-writing <a href="http://www.clevegibbon.com">clevegibbon.com</a>) Ruby.  However, today I was seriously impressed with RSpec.</p>
<p>RSpec has come on some over the last few months.  Armed with RSpec, today was the first time I&#8217;ve completely writing a bunch of new features for a web site, without once using the site directly.  Let me put it another way, I didn&#8217;t fire up my browser once when developing the new features.  It was all done via RSpec and Rails built-in support for functional/integration testing.  And when I was happy that I had spec&#8217;d out the features and all the examples were passing, I fired up the browser, traversed to the site and hey presto, it worked as specified.  I had to really shake myself, because I was preparing myself for a troubleshooting and/or debug session.  I was simply not ready for it working as specified.  So I now have time to write this blog entry&#8230;</p>
<p>Oh, before you go, here is the rspec for my Rails controllers for my new features (there are also some for the models, views and helpers).  You can probably work out what I&#8217;m doing by just reading it.  Nice!</p>
<p>AdminController for authorised users<br />
- should have access to secured pages</p>
<p>AdminController for unauthorised Users<br />
- should be re-directed to the login page</p>
<p>HomeController for all users<br />
- should allow anonymous users access</p>
<p>InprogressController for authorised users<br />
- should have access to secured pages</p>
<p>InprogressController for unauthorised users<br />
- should be re-directed to the login page</p>
<p>LoginController for anonymous users<br />
- should log in a known user and send them to the admin page<br />
- should not permit unknown users to login in</p>
<p>LoginController for authorised users<br />
- should log them out and direct them to the home page<br />
- should log out users who attempt to login with a GET request</p>
<p>RubyController for all users<br />
- should allow anonymous users access</p>
<p>StuffController for all users<br />
- should allow anonymous users access</p>
<p>Finished in 0.260431 seconds</p>
<p>11 examples, 0 failures</p>
]]></content:encoded>
			<wfw:commentRss>http://www.clevegibbon.com/wordpress/2008/01/22/rspec-automated-testing-and-then-manual-testing-it-works/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>New Year Rant on RoR</title>
		<link>http://www.clevegibbon.com/wordpress/2008/01/03/new-year-rant-on-ror/</link>
		<comments>http://www.clevegibbon.com/wordpress/2008/01/03/new-year-rant-on-ror/#comments</comments>
		<pubDate>Thu, 03 Jan 2008 07:32:49 +0000</pubDate>
		<dc:creator>cleve</dc:creator>
				<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://www.clevegibbon.com/wordpress/?p=70</guid>
		<description><![CDATA[It&#8217;s rare that you read a tech rant and LOL, but this one by Zed Shaw on why he thinks Rails is a Ghetto shows no mercy what-so-ever.  Have a read and let me know what you think?  There&#8217;s always a flip side to everything, seth/jedi, ham/pigs, optimus prime/megatron! I just found the [...]]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s rare that you read a tech rant and LOL, but this one by <a href="http://www.zedshaw.com">Zed Shaw </a>on why he thinks <a href="http://www.zedshaw.com/rants/rails_is_a_ghetto.html">Rails is a Ghetto</a> shows no mercy what-so-ever.  Have a read and let me know what you think?  There&#8217;s always a flip side to everything, seth/jedi, ham/pigs, optimus prime/megatron! I just found the timing funny as I am in the midst of picking up Ruby and RoR. </p>
<p>Oh, please turn off your profanity filters, take a pinch of salt and get comfortable&#8230;you&#8217;re in for an adults only ride!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.clevegibbon.com/wordpress/2008/01/03/new-year-rant-on-ror/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>From Ruby to Rails</title>
		<link>http://www.clevegibbon.com/wordpress/2007/12/28/from-ruby-to-rails/</link>
		<comments>http://www.clevegibbon.com/wordpress/2007/12/28/from-ruby-to-rails/#comments</comments>
		<pubDate>Fri, 28 Dec 2007 06:23:47 +0000</pubDate>
		<dc:creator>cleve</dc:creator>
				<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://www.clevegibbon.com/wordpress/?p=69</guid>
		<description><![CDATA[Well I had to dive in and try Rails.  Although Ruby is completely independent of Rails, we live in a web-based world, and as a result you can&#8217;t talk Ruby with hearing about Rails.  
First impressions, pretty cool.  To learn it, you need a damned fine book.  I wouldn&#8217;t recommend poking [...]]]></description>
			<content:encoded><![CDATA[<p>Well I had to dive in and try Rails.  Although Ruby is completely independent of Rails, we live in a web-based world, and as a result you can&#8217;t talk Ruby with hearing about Rails.  </p>
<p>First impressions, pretty cool.  To learn it, you need a damned fine book.  I wouldn&#8217;t recommend poking around on the web and reading <em>Introduction to Rails</em> types of tutorials.  I did this and found it to be too time consuming to find out what I needed.  Rails is deep and you need to commit the time it takes to read a book to get a rudimentary understanding of what it is all about.  Tutorials can&#8217;t do this.  </p>
<p>Just like in the Java world, if you wanted to learn about servlets, there was one book you just had to read, <a href="http://www.oreilly.com/catalog/jservlet2/">Java Servlet Programming</a> by Jason Hunter with Will Crawford.  For Rails, it&#8217;s <a href="http://www.pragprog.com/titles/rails2">Agile Web Development with Rails</a> by Dave Thomas and David Heinemeier Hansson, et al.  I&#8217;m taking my time with this and flicking between the <a href="http://www.pragprog.com/titles/ruby3">PickAxe</a> book (now in the 3rd edition, ahhh just bought the 2nd). </p>
<p>There&#8217;s a lot to learn.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.clevegibbon.com/wordpress/2007/12/28/from-ruby-to-rails/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Is Ruby too clever?</title>
		<link>http://www.clevegibbon.com/wordpress/2007/12/19/is-ruby-too-clever/</link>
		<comments>http://www.clevegibbon.com/wordpress/2007/12/19/is-ruby-too-clever/#comments</comments>
		<pubDate>Wed, 19 Dec 2007 08:54:47 +0000</pubDate>
		<dc:creator>cleve</dc:creator>
				<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://www.clevegibbon.com/wordpress/?p=68</guid>
		<description><![CDATA[Before we go there, personally, I think that Perl is clever language.  Damned clever! The magical tricks you can do in Perl&#8217;s land of plenty is unreal.  As such, Perl tends to attract clever people that wrestle with this huge bunking behemoth of a language in a vain attempt to wrestle it under [...]]]></description>
			<content:encoded><![CDATA[<p>Before we go there, personally, I think that <a href="http://www.perl.com/">Perl</a> is clever language.  Damned clever! The magical tricks you can do in Perl&#8217;s land of plenty is <em>unreal</em>.  As such, Perl tends to attract clever people that wrestle with this huge bunking behemoth of a language in a vain attempt to wrestle it under their <em>total</em> control.  Many fail, c&#8217;est la vie!  However, those that succeed never really let go for fear of being trampled underfoot.  Just take a look at the poor fella below.  That&#8217;s gotta hurt!</p>
<p><img src="http://www.clevegibbon.com/images/bullfighting.jpg" align="left" width="300" height="200" border="0" style="margin: 15px" /><br />
Up until about a few years ago I used to accept my fate and jump back into the Perl saddle only to be battered senseless until I got what I needed from it.  Then, a broken man, I ran like hell, never looking back, for fear that would Perl would find me!  More importantly, everything I learnt whilst in the saddle, stayed in the saddle.  As is always the case with my battles with Perl, I took away very little from each encounter.  Nowadays, there are alternatives to Perl, so I don&#8217;t need to seek it out any more.  Why would I?  It hurts!  In fact, I haven&#8217;t touched Perl for nearly 12 months now and I feel whole again.</p>
<p>So if Perl is a clever language, used by clever (or stronger) people,  then is the resulting software clever?  I hope not.  Why?  Because clever software requires clever people to evolve/maintain it.  And as you probably know, there is a distinct lack of clever people in the software industry, so why on earth would I want to go there?</p>
<p>I want a language that is fit for the masses.  I don&#8217;t think that this is Perl.  Java and C# are for the masses, whereas as Visual Basic, what can is say, it&#8217;s all Dim, Dim, Dim!</p>
<p>So what about Ruby?  I think Ruby is a little bit too clever at the moment.  There are just too many ways to do the same thing.  Too many Perl-isms in the language.  Too many shortcuts (SGML vs XML again).  I haven&#8217;t looked but I&#8217;m sure there must be a set of standards and/or conventions for how best to the use the language.  What you should/shouldn&#8217;t do? The infamous gotcha list that many C++ programming masters continually beat the <em>not-so-clever</em> masses across the head with.  We need a best practice for using Ruby language constructs.  Even when reading through the PickAxe Programming Ruby book by Dave Thomas and Co, Second Edition (a great read), it&#8217;s littered with these types of comments and caveats.</p>
<p>Now I ain&#8217;t no language designer, but I can just imagine the forums are packed with<strong><em> I(H?)MO Ruby should</em></strong>.  It&#8217;s so much harder to take things out than put things in (unless you&#8217;re talking about a box of chocolates or a jam-packed cake tin that is <img src='http://www.clevegibbon.com/wordpress/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' />  ).  I don&#8217;t know where Matz is with Ruby 2.0, but things are not going to change that much to simplify the language.  Now I don&#8217;t want to dumb down the language, but more just remove noise.  Ruby is rightly expressive to arm us with the weapons to fight damned hard problems.  But we need to keep tools like Ruby sharp, clean but free from crap and distractions.</p>
<p>What I&#8217;m looking for is more a RubyLite that standardises of best of breed language use, code style and syntax.  I think our company&#8217;s RubyLite will be comprised of a living document and/or supporting examples that developers can lookup and reference as they learn the language.  These developer aids will contain gotchas, common idioms, scary features, and so on.  The more the language designers can do to remove crap and distractions from the language, and there&#8217;s not too much to do here, the smaller and more manageable these supporting documents/examples will be.</p>
<p>What do you think?  </p>
<p>PS: I don&#8217;t hate Perl and I love Ruby.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.clevegibbon.com/wordpress/2007/12/19/is-ruby-too-clever/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Off the Rails&#8230;</title>
		<link>http://www.clevegibbon.com/wordpress/2007/12/03/off-the-rails/</link>
		<comments>http://www.clevegibbon.com/wordpress/2007/12/03/off-the-rails/#comments</comments>
		<pubDate>Mon, 03 Dec 2007 16:59:32 +0000</pubDate>
		<dc:creator>cleve</dc:creator>
				<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://www.clevegibbon.com/wordpress/?p=67</guid>
		<description><![CDATA[Well that was strange!  
After following some rather smashing guides for configuring your Mac for Rails, I needed a good tutorials for writing your first Rails web application.  The funny thing is that if you haven&#8217;t got a web site that is database backed, most of the Hello World Rails Tutorials are pretty [...]]]></description>
			<content:encoded><![CDATA[<p>Well that was strange!  </p>
<p>After following some rather smashing guides for configuring your <a href="http://developer.apple.com/tools/rubyonrails.html">Mac for Rails</a>, I needed a good tutorials for writing your first Rails web application.  The funny thing is that if you haven&#8217;t got a web site that is database backed, most of the Hello World Rails Tutorials are pretty much no help what so ever.  After the 17th Rails for Newbies tutorial, I felt like I was walking through treacle.  </p>
<p>But then, I happened across this article, <a href="http://www.onlamp.com/lpt/a/5546">Rolling with Ruby on Rails</a> that explained things from an HTTP request based principal, and then the database.  Heaven!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.clevegibbon.com/wordpress/2007/12/03/off-the-rails/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Meta Programming in Ruby &#8211; Part One</title>
		<link>http://www.clevegibbon.com/wordpress/2007/09/10/meta-programming-in-ruby-part-one/</link>
		<comments>http://www.clevegibbon.com/wordpress/2007/09/10/meta-programming-in-ruby-part-one/#comments</comments>
		<pubDate>Mon, 10 Sep 2007 20:32:57 +0000</pubDate>
		<dc:creator>cleve</dc:creator>
				<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://www.clevegibbon.com/wordpress/?p=58</guid>
		<description><![CDATA[def warning
This is written by a Java programmer currently learning Ruby.&#160; It&#8217;s really a note to myself.&#160; I&#8217;ve found the best way learn something, is to write about it.&#160; Please, those in the know, I would appreciate comments on glaring errors and/or omissions&#8230;

end
&#160;
So, there I was happily stepping through the on-line version of&#160;Programming Ruby (currently [...]]]></description>
			<content:encoded><![CDATA[<p><strong>def</strong> warning</p>
<blockquote><p>This is written by a Java programmer currently learning Ruby.&nbsp; It&#8217;s really a note to myself.&nbsp; I&#8217;ve found the best way learn something, is to write about it.&nbsp; Please, those in the know, I would appreciate comments on glaring errors and/or omissions&#8230;</p>
</blockquote>
<p><strong>end</strong></p>
<p>&nbsp;</p>
<p>So, there I was happily stepping through the on-line version of&nbsp;<a href="http://www.rubycentral.com/pickaxe/">Programming Ruby</a> (currently figuring out Ranges in the chapter on <a href="http://www.rubycentral.com/pickaxe/tut_stdtypes.html">Standard Types</a>).&nbsp; I &#8216;m in no particular hurry whatsoever when I come across this article:</p>
<blockquote><p><a href="http://whytheluckystiff.net/articles/seeingMetaclassesClearly.html">Seeing Metaclasses Clearly</a> </p>
</blockquote>
<p>This article changed my thinking dramatically on Ruby and upped the ante on the language capabilities.&nbsp; I simply couldn&#8217;t ignore it.&nbsp; I recommend you read this article, then read it again, and only then step through it within your favourite Ruby development enviornment.&nbsp; This is what a novice picked up from the article:</p>
<p>&nbsp;</p>
<p><strong>class Object&nbsp; </strong># you can open up any class and add stuff to it</p>
<p>&nbsp; # use semi-colons to squash things onto on line<br />&nbsp; def metaclass; class &lt;&lt; self; self; end; end</p>
<p><strong>end</strong></p>
<p><strong></strong>&nbsp;</p>
<p>Semi-colons&nbsp;do not scan well with me.&nbsp; I&#8217;m trying to break thing down into blocks So lets re-write this to make it a little more readable first:</p>
<p><strong>class Object&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</strong>#&nbsp;open up the Object class<br />&nbsp; def metaclass&nbsp;&nbsp; # add a method called &#8216;metaclass&#8217;&nbsp;<br />&nbsp;&nbsp;&nbsp; <strong>class &lt;&lt; self&nbsp;&nbsp;&nbsp;</strong>#&nbsp;get access to the metaclass for this object instance<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; self&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; # and then return it to the&nbsp;caller<br />&nbsp;&nbsp;&nbsp; end<br /><strong>end</strong></p>
<p><strong></strong>&nbsp;</p>
<p>With this code&nbsp; all you need to do to get access to an object&#8217;s metaclass is call that method.&nbsp; Consider the following example:</p>
<blockquote><p>class MyShape<br />&nbsp; attr_accessor :sides, :colour<br />&nbsp; def initialize(sides,colour)<br />&nbsp;&nbsp;&nbsp; @sides, @colour = sides,colour<br />&nbsp; end<br />end
<p>
<p>s1 = MyShape.new(4,&#8217;red&#8217;);<br />s2 = MyShape.new(3, &#8216;yellow&#8217;);
<p>print &#8220;\nShape1 Class: &#8220;, s1.class<br />print &#8220;\nShape2 Class: &#8220;, s2.class<br />print &#8220;\nShape1 SuperClass: &#8220;, s1.class.superclass<br />print &#8220;\nShape2 SuperClass: &#8220;, s2.class.superclass<br />print &#8220;\nShape1 MetaClass: &#8220;, s1.metaclass<br />print &#8220;\nShape2 MetaClass: &#8220;, s2.metaclass<br />print &#8220;\nShape1 MetaClass: &#8220;, s1.metaclass.class<br />print &#8220;\nShape2 MetaClass: &#8220;, s2.metaclass.class<br />print &#8220;\nShape1 MetaClass Superclass: &#8220;, s1.metaclass.superclass<br />print &#8220;\nShape2 MetaClass Superclass: &#8220;, s2.metaclass.superclass</p>
</blockquote>
<p>The&nbsp;output from this&nbsp;code is as follows:</p>
<blockquote><p>Shape1 Class: MyShape<br />Shape2 Class: MyShape<br />Shape1 SuperClass: Object<br />Shape2 SuperClass: Object<br />Shape1 MetaClass: #&lt;Class:#&lt;MyShape:0&#215;2b75398&gt;&gt;<br />Shape2 MetaClass: #&lt;Class:#&lt;MyShape:0&#215;2b7535c&gt;&gt;<br />Shape1 MetaClass: Class<br />Shape2 MetaClass: Class<br />Shape1 MetaClass Superclass: #&lt;Class:MyShape&gt;<br />Shape2 MetaClass Superclass: #&lt;Class:MyShape&gt;</p>
</blockquote>
<p>Both s1 and s2 are of type <strong>MyShape</strong>, where MyShape inherits from <strong>Object</strong>.&nbsp; No surprises there.&nbsp; </p>
<p>&nbsp;</p>
<p>Now see that the metaclasses are instances themselves, or virtual classes in Ruby talk, that are <strong><em>attached</em></strong> to the MyShape object instances s1 and s2.&nbsp; </p>
<blockquote><p># the metaclass instances are difference<br />puts s1.metaclass.object_id&nbsp;&nbsp; # 22784300<br />puts s2.metaclass.object_id&nbsp;&nbsp; # 22784250</p>
</blockquote>
<p>All metaclasses are of type <strong>Class</strong>.&nbsp; Moreover, for MyShape instances, all metaclasses derive from Class:MyShape.&nbsp; This is where things get interesting.</p>
<p>&nbsp;</p>
<p>In&nbsp;<a href="http://whytheluckystiff.net/articles/seeingMetaclassesClearly.html">Seeing Metaclasses Clearly</a>, the author defines metaclasses as:</p>
<blockquote><p>&#8220;a class which an object uses to redefine itself&#8221;</p>
</blockquote>
<p>So how does an object re-define itself?&nbsp; Well,&nbsp;it behaves differently.&nbsp; How do you get an object to behave differently? You add/change the methods that the object in question can&nbsp;respond to.&nbsp;&nbsp;So how do metaclasses enable you to change the methods that an&nbsp;object can respond to?&nbsp; Check this out:</p>
<blockquote><p>class &lt;&lt; s1<br />&nbsp; def only_available_to_s1<br />&nbsp;&nbsp;&nbsp; puts &#8216;this blew me away&#8217;<br />&nbsp; end<br />end</p>
</blockquote>
<p>Now let&#8217;s run the following code:</p>
<blockquote><p>s1.only_available_to_s1 # outputs &#8212; this blew me away<br />s2.only_available_to_s1 # error, no method not _available_to_s1</p>
</blockquote>
<p>Some people think that the <strong>class &lt;&lt;&nbsp;s1</strong> thing is too verbose, so here is another way of doing the same thing:</p>
<blockquote><p>def s1.only_available_to_s1<br />&nbsp; puts &#8216;this blew me away&#8217;<br />end</p>
<p>&nbsp;</p>
</blockquote>
<p>So what&#8217;s going on here.&nbsp; Well we have opened up the metaclass for the s1 object instance and added the method <em>only_available_to_s1 </em>to it.&nbsp; Yes, you read it correctly.&nbsp; Remember object instances store data.&nbsp; Classes store methods for object instances.&nbsp; Metaclasses are the ideal place to store methods on a per object instance basis.&nbsp; That is so cool.</p>
<p>&nbsp;</p>
<p>In&nbsp;Ruby there is&nbsp;name for methods that an object finds within an attached metaclass.&nbsp; These are called singleton methods.&nbsp; Why?&nbsp; Because only a single metaclass can be attached to an object.&nbsp;&nbsp;Executing the following block of code:</p>
<blockquote><p>puts s1.singleton_methods</p>
</blockquote>
<p>prints out the following:</p>
<blockquote><p>only_available_to_s1&nbsp;&nbsp; </p>
</blockquote>
<p>This is the only singleton method available to the s1 object instance.&nbsp; This method is stored within its attached metaclass.</p>
<p>&nbsp;</p>
<p>You can of course go meta meta, but at that put I thought things where getting a little crazy so I stopped.&nbsp; The article goes into more details, but they too thought that you are probably going a little too far as well if you need to&nbsp;go meta meta.&nbsp;</p>
<p>&nbsp;</p>
<p>I&#8217;m going to stop now and pick up again later on relationship between metaclasses and the inheritance tree.&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.clevegibbon.com/wordpress/2007/09/10/meta-programming-in-ruby-part-one/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
