<?xml version="1.0"?>
<rss version="2.0">
<channel>
  <title>Weiqi Gao&#039;s Observations - ruby tag</title>
  <link>http://www.weiqigao.com/blog/tags/ruby/</link>
  <description>Sharing My Experience...</description>
  <language>en</language>
  <copyright>Weiqi Gao</copyright>
  <lastBuildDate>Fri, 11 May 2012 12:48:36 GMT</lastBuildDate>
  <generator>Pebble (http://pebble.sourceforge.net)</generator>
  <docs>http://backend.userland.com/rss</docs>
  
  <image>
    <url>http://pebble.sourceforge.net/common/images/powered-by-pebble.gif</url>
    <title>Weiqi Gao&#039;s Observations</title>
    <link>http://www.weiqigao.com/blog/</link>
  </image>
  
  
  <item>
    <title>The Next Big Thing: An Opinionated Google Search</title>
    <link>http://www.weiqigao.com/blog/2008/10/16/the_next_big_thing_an_opinionated_google_search.html</link>
    
      
        <description>
          &lt;p&gt;&lt;em&gt;(Tangential thoughts triggered by &lt;a href= &#034;http://almaer.com/blog/the-next-big-language-theory-practice-and-the-killer-app&#034; &gt;techno.blog(&#034;Dion&#034;)&lt;/a&gt;.)&lt;/em&gt;
&lt;/p&gt;

&lt;p&gt;In no particular order:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;The JVM has become the playground of the programming language researchers.  This is a good thing for the Java community, even for those of us who mainly uses the Java language on a day-to-day basis.  It&#039;s nice to know that the language that I write CRUD applications is also capable of being so creatively used.&lt;/li&gt;

&lt;li&gt;I like object-oriented programming.  I also like functional programming.  I&#039;m not allergic to LISP&#039;s nested parenthesis.  I&#039;ve been looking at &lt;a href= &#034;http://clojure.org/&#034; &gt;Clojure&lt;/a&gt; for the last year, and believe it has the potential to becoming the next big language.&lt;/li&gt;

&lt;li&gt;Functional programming survived all these years because of one thing and one thing alone: It&#039;s mathematical&amp;mdash;Its fundation can be presented as axioms, definitions and theorems.  Object-orientation, on the other hand, feels &lt;i&gt;ad hoc&lt;/i&gt;.  It may map well to how some people view (the object/attribute/governing-rules view in the Aristotle tradition) the world.  But psychological studies has shown that not all people (the community/relationship/harmony view in the Confucian tradition, for example) perceive the world that way.&lt;/li&gt;

&lt;li&gt;Although I&#039;m not certain about what the next big language is, I know what the next big thing is.  It has to be something for the Internet.  It has to be something that beats Google at searching results.  Google is good at relatively simple and static things, like &#034;From which direction does the Sun rise?&#034;, but terrible at dynamically changing things, like &#034;Where is the Social Security Office at Creve Coeur, MO?&#034;  (They used to be on the first floor in the building OCI is in.  They moved a couple of years ago.  But we still see people coming to the building to inquire.)  I know it&#039;s not going to be easy, but what if Google start to get some opinions and display a &#034;We think this is good&#034; or &#034;We think this is wrong&#034; marker alongside every search result.  Sort of like fact checking for every web page.&lt;/li&gt;

&lt;li&gt;JavaScript is the lousiest language ever invented.  It is unfortunate that we are stuck with it for now (the web-era).  It needs to grow.  Some people want to make the browser a platform, fine.  That platform needs to grow.  In growth, it will see fragmentation (&#034;which JavaScript framework library are you using today?&#034;), consolidation and evolution.  At the end (we are talking about five to ten years out) it will be just like one of the other platforms that we use: Windows, Mac, Linux, etc.&lt;/li&gt;

&lt;li&gt;Ruby and Scala are both languages with weird syntaxes, just like Clojure is.  But the mark of a truly useful language is that people will learn it in order to get things done.  People seems to forget how hard object-orientation is when they first learned it.  The same thing can be said of JavaScript.&lt;/li&gt;

&lt;li&gt;Tomorrow&#039;s big language is today&#039;s obscure or nonexistent language that someone finds powerful enough, innovative enough and pleasant enough to do interesting things with.  Have you solved a real problem lately?  Have you enjoyed your programming work lately?&lt;/li&gt;

&lt;/ul&gt;
        </description>
      
      
    
    
    
    <comments>http://www.weiqigao.com/blog/2008/10/16/the_next_big_thing_an_opinionated_google_search.html#comments</comments>
    <guid isPermaLink="true">http://www.weiqigao.com/blog/2008/10/16/the_next_big_thing_an_opinionated_google_search.html</guid>
    <pubDate>Thu, 16 Oct 2008 18:56:29 GMT</pubDate>
  </item>
  
  <item>
    <title>Unit Tests Are Not Enough</title>
    <link>http://www.weiqigao.com/blog/2007/09/26/unit_tests_are_not_enough.html</link>
    
      
        <description>
          &lt;p&gt;The new and improved &lt;a href= &#034;http://stuffthathappens.com/blog/&#034; &gt;It&#039;s Just a Bunch of Stuff That Happens&lt;/a&gt;&amp;mdash;which went off the air briefly, as I noted &lt;a href= &#034;http://www.weiqigao.com/blog/2007/08/20/my_shrinking_blogroll.html&#034; &gt;37 days ago&lt;/a&gt;&amp;mdash;is back with renewed, focused energy and is as penetratingly insightful as ever.&lt;/p&gt;

&lt;p&gt;In a &lt;a href= &#034;http://stuffthathappens.com/blog/2007/09/25/paying-my-taxes/&#034; &gt;post yesterday&lt;/a&gt;, Eric gave a concrete example of the drawback of lack of static typing in Ruby:&lt;/p&gt;

&lt;blockquote&gt;&lt;p&gt;The second bug took me far longer to understand and was more insidious. In Ruby you don’t even have to say “return” at the end of a method. Instead, the result of whatever expression happened last is automatically returned. Invisible magic is the quintessential example of a feature that saves the original coder a few extra keystrokes but makes every downstream programmer pay the continuous tax for years to come.&lt;/p&gt;

&lt;p&gt;I made the problem worse by adding a simple “if” statement to the end of the method, thinking I could explicitly change a bogus error message to nil. But now the method didn’t even return a string any more…I inadvertently changed the return type from a string to a boolean.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;To which I commented without too much thinking:&lt;/p&gt;

&lt;blockquote&gt;Had you made a similar return-type-altering change in Java, the compiler would have caught it as an error.  In that regard, the static typing works just like unit tests&amp;mdash;it prevents you from breaking your code.&lt;/blockquote&gt;

&lt;p&gt;This post became the topic of discussion at OCI North this morning.  Brian mentioned that he has been bitten by the same problem in a Ruby script he wrote recently.  He also pointed out that no amount of unit tests will guarantee that a function will return data of a specific type.&lt;/p&gt;

&lt;p&gt;Suppose you want to write a function that takes a string and return a boolean in a dynamically typed language, and you want the function to return &lt;tt&gt;true&lt;/tt&gt; for inputs like &lt;tt&gt;&#034;yes&#034;&lt;/tt&gt;, &lt;tt&gt;&#034;true&#034;&lt;/tt&gt; and &lt;false&lt;/tt&gt; for inputs like &lt;tt&gt;&#034;no&#034;&lt;/tt&gt;, &lt;tt&gt;&#034;false&#034;&lt;/tt&gt;.  So you write your unit tests stating these requirements.   And you may choose to implement this function like this (in pseudo-code):&lt;/p&gt;

&lt;pre style=&#034;margin-left:3em&#034;&gt;def foo(input) {
  if input is &#034;yes&#034; return true
  if input is &#034;true&#034; return true
  if input is &#034;no&#034; return false
  if input is &#034;false&#034; return false
}&lt;/pre&gt;

&lt;p&gt;However, you cannot write a unit test that will make sure this function always returns a boolean.  You can write a specific test that prevents the following code from spoiling the function:&lt;/p&gt;

&lt;pre style=&#034;margin-left:3em&#034;&gt;  if input is &#034;weiqi&#034; return &#034;gao&#034;&lt;/pre&gt;

&lt;p&gt;But that test cannot prevent the next spoiler, and the next, and the next, ...&lt;/p&gt;

&lt;p&gt;In this sense, a statically declared return type of boolean for the function can be thought of as the equivalent of an infinitely many unit tests.&lt;/p&gt;

&lt;p&gt;The conclusion:&lt;/p&gt;

&lt;center&gt;&lt;span style=&#034;color:red;font-size:Large&#034;&gt;If unit tests are good, static typing is better!&lt;/span&gt;&lt;/center&gt;
        </description>
      
      
    
    
    
    <comments>http://www.weiqigao.com/blog/2007/09/26/unit_tests_are_not_enough.html#comments</comments>
    <guid isPermaLink="true">http://www.weiqigao.com/blog/2007/09/26/unit_tests_are_not_enough.html</guid>
    <pubDate>Thu, 27 Sep 2007 04:20:16 GMT</pubDate>
  </item>
  
  <item>
    <title>The End Of The Ruby Hype (Re: Top 10 Reasons Java Sucks)</title>
    <link>http://www.weiqigao.com/blog/2007/09/20/the_end_of_the_ruby_hype_re_top_10_reasons_java_sucks.html</link>
    
      
        <description>
          &lt;blockquote&gt;
&lt;p&gt;&lt;a href= &#034;http://www.jroller.com/obie/entry/top_10_reasons_why_java&#034; &gt;Obie Fernandez&lt;/a&gt;: I&#039;m not really much into evangelizing Ruby and Rails much nowadays. You know, since we won, I have to admit that it became boring and besides the point. However, &lt;a href= &#034;http://in.relation.to/Bloggers/MoreXMLThanCode&#034; &gt;this FUDdy discussion on the Hibernate blog got me riled up&lt;/a&gt; and I&#039;m in a playful mood tonight. Therefore, mostly for old time&#039;s sake, here is a list of the top 10 reasons that anything (and probably everything) related to Java sucks ass in comparison to Ruby and Rails.&lt;/p&gt;

&lt;p&gt;... Fuck compilers ... Java Programmers are Morons ... they all suck ass ... Jimmy Gosling? Hahahahahahahaha...&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Let me just remind everybody that it&#039;s exactly three years ago this month when the Ruby on Rails hype started.  With a post like this, the Ruby on Rails hype shall end.&lt;/p&gt;

&lt;p&gt;It started with a claim of a ten to fifteen-fold productivity gain, and ended with nothing but name-calling. They have lost it.&lt;/p&gt;

&lt;p&gt;All I have to say is that I&#039;m glad I did not jump on that bandwagon.&lt;/p&gt;

&lt;p&gt;Have a nice day.&lt;/p&gt;
        </description>
      
      
    
    
    
    <comments>http://www.weiqigao.com/blog/2007/09/20/the_end_of_the_ruby_hype_re_top_10_reasons_java_sucks.html#comments</comments>
    <guid isPermaLink="true">http://www.weiqigao.com/blog/2007/09/20/the_end_of_the_ruby_hype_re_top_10_reasons_java_sucks.html</guid>
    <pubDate>Thu, 20 Sep 2007 12:33:57 GMT</pubDate>
  </item>
  
  </channel>
</rss>

