<?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 Cafes &#187; Ruby</title>
	<atom:link href="http://cafe.elharo.com/category/ruby/feed/" rel="self" type="application/rss+xml" />
	<link>http://cafe.elharo.com</link>
	<description>Longer than a blog; shorter than a book</description>
	<lastBuildDate>Sat, 30 Mar 2013 11:51:03 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
		<item>
		<title>10 Things I Hate About Ruby</title>
		<link>http://cafe.elharo.com/ruby/10-things-i-hate-about-ruby/</link>
		<comments>http://cafe.elharo.com/ruby/10-things-i-hate-about-ruby/#comments</comments>
		<pubDate>Mon, 03 Jul 2006 14:04:52 +0000</pubDate>
		<dc:creator>Elliotte Rusty Harold</dc:creator>
				<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://cafe.elharo.com/ruby/10-things-i-hate-about-ruby/</guid>
		<description><![CDATA[1. initialize To create a new object in Ruby you invoke the new class method like so: c = Car.new("Toyota") Naturally you think the constructor would be defined in a method called new, right? Or just maybe a method called Car like in Java? But no, instead it has to be called initialize like this: [...]]]></description>
				<content:encoded><![CDATA[<h2>1. <code>initialize</code></h2>
<p><span id="more-97"></span></p>
<p>To create a new object in Ruby you invoke the <code>new</code> class method like so:</p>
<p><code>c = Car.new("Toyota")</code></p>
<p>Naturally you think the constructor would be defined in a method called <code>new</code>, right? Or just maybe a method called <code>Car</code> like in Java? But no, instead it has to be called <code>initialize</code> like this:</p>
<pre><code>class Car
  def initialize(make)
    @make = make
  end
end</code></pre>
<p>Would this have been so hard?</p>
<pre><code>class Car
  def new(make)
    @make = make
  end
end</code></pre>
<h2>2. Weak typing</h2>
<p>As a library vendor, it scares the bejeezus out of me that anyone can pass anything to my methods and I&#8217;m expected to handle it. It&#8217;s like walking into McDonalds and ordering a Big Mac, and instead getting a Tofu burger; not very appetizing. Ruby&#8217;s thrown out the one piece of precondition checking most languages give you for free.</p>
<h2>3. Automatic returns</h2>
<p>Didn&#8217;t C teach us that unexpected results were confusing? This is Ruby&#8217;s equivalent of C&#8217;s <code>a = b + a = c;</code>. Returns should be explicit. An explicit return is not hard to write, and it&#8217;s a lot easier to read and understand. Reducing finger typing and at the expense of increasing brain confusion is not a wise tradeoff. Languages should be concise only in so far as that improves clarity. When compactness comes at the expense of clarity, it&#8217;s a bad thing.</p>
<h2>4. Global variables</h2>
<p>Didn&#8217;t somebody tell me Ruby was an object-oriented language? </p>
<h2>5. puts</h2>
<p>Do we have to copy C&#8217;s most ungrammatical, pointless method names?</p>
<h2>6. Zero-based arrays</h2>
<p>C arrays began at zero to match memory addressing. In a weakly typed scripting language, there&#8217;s exactly no reason to do this. There hasn&#8217;t been for decades. Can&#8217;t we please start the arrays at 1 where God intended? Hasn&#8217;t anyone read <a href="http://www.amazon.com/exec/obidos/ISBN=0521431085/ref=nosim/cafeaulaitA/">Numerical Recipes</a>? Aren&#8217;t we tired of fencepost errors yet?</p>
<h2>7. elsif</h2>
<p>Sorry. &#8220;elsif&#8221; is not a word in the English language, and it shouldn&#8217;t have been one in Ruby. Would typing one extra letter have been so onerous? </p>
<h2>8. $_</h2>
<p>Global variables suck. Did I say that already? Global variables you didn&#8217;t actually create and that pop up out of nowhere suck even worse. And global variables whose names are indistinguishable from line noise suck still more. Java&#8217;s verbose, but that verbosity is in the service of legibility. Ruby&#8217;s compactness all too often serves only to obfuscate. </p>
<h2>9. Methods are public by default</h2>
<p>Minimal interfaces to classes are important. The less a class promises, the easier it is to change, optimize, fix, and otherwise improve. Furthermore, the easier it is to learn and understand. Everything that can be private should be private. </p>
<p>Now of course you do need public methods. Not everything can be private. However this shouldn&#8217;t be the default. Marking a method public decreases the flexibility and increases the learning curve of the class. It should require an explicit decision from the programmer to do this. Ruby gets this exactly backwards. A programmer just banging out Ruby code is likely to create a class with nothing-but-public-members, without even thinking about it. That&#8217;s a bad thing.</p>
<h2>10. No package access or friend functions.</h2>
<p>There&#8217;s no access in-between public and private. All too often different classes in the same library/application/codebase need more detailed access to their other parts than the general public should have. Ruby provides no way to manage this.</p>
<h2>In conclusion</h2>
<p>I could go on (and I probably will) but that&#8217;s a nice round number of hates for now. I&#8217;m also keeping a list of things I love about Ruby as I learn the language. However, the things I hate hit 10 before the things I love. That&#8217;s not a good sign. </p>
]]></content:encoded>
			<wfw:commentRss>http://cafe.elharo.com/ruby/10-things-i-hate-about-ruby/feed/</wfw:commentRss>
		<slash:comments>89</slash:comments>
		</item>
	</channel>
</rss>
