Skip to content
Find file
Fetching contributors…
Cannot retrieve contributors at this time
98 lines (60 sloc) 12.9 KB
<p><img width="320px" height="240px" align="left" style="margin-right:15px" src="http://hectorcorrea.com/images/mac_macair.jpg" alt="MacAir" />
A little more than a month ago I got myself a MacAir. Even though I’ve own computers since the mid 80s this is the first time that I buy a Machintosh. The reason I bough a Mac rather than a PC is because I wanted to <b>start experimenting with the web development tools that exist for non-Windows environments</b>. Although I’ve been a software developer for more than 15 years all my experience is with Microsoft Windows and I thought is about time I start experimenting with the tools that “the “other half of the world” is using.</p>
<p>Since I got a Mac most people would probably thing that I want to start writing applications for the iPhone or the Mac but in reality I want to experiment with the development tools for web applications. I will probably write an app or two for the iPhone or the Mac just to see what it’s like but my real motivation is web development using non-Windows tools.</p>
<p>This is not to say that I am abandoning development with Microsoft’s tools (or the Windows ecosystem) but rather I want to experience what else is out there. There are plenty of successful web sites (e.g. Google and Facebook) that are developed using non-Windows tools and I want to see what the development experience on those tools is like.</p>
<p><b>The programming language that I decided to learn first is Ruby along with the popular web development framework Ruby on Rails</b>. Over the following months I will be posting my experiences developing applications on the Mac OS X using Ruby and Ruby on Rails from the perspective of somebody that is very familiar and comfortable with Microsoft/Windows development.</p>
<h2>Why Ruby?</h2>
<p><img width="240px" height="180px" align="left" style="margin-right:15px" src="http://hectorcorrea.com/images/ruby.jpg" alt="MacAir" />
When I decided to learn a new language I wasn’t too thrilled to learn Perl, PHP, or Phyton. I don’t really know why, the thought of learning any of those languages just didn’t excite me despite the fact that they are the ones used some of the most successful sites including Google and Facebook. </p>
<p>But <a href="http://www.ruby-lang.org" target="_blank">Ruby</a> gave me a different vibe, people seem to be very passionate and excited about Ruby and Ruby on Rails. Both of them seem to be quite popular to build web applications which is what I am most interested in. In addition a lot of the ideas for Microsoft’s ASP.NET MVC (which is my main development platform these days) were taken from Rails which made me think that there is definitively a lot to be gained from learning both Ruby and Rails.</p>
<p>In his presentation <a href="http://onestepback.org/articles/10things/index.html" target="_blank">10 Things Every Java Programmer Should Know About Ruby</a> Jim Weirich has this great quote:</p>
<p style="margin-left:40px">“A language that doesn’t affect the way you think about programming is not worth knowing — Alan Perlis”</p>
<h2>So What Does Ruby Offer? (or How I Learned to Stop Worrying and Love the Bomb)</h2>
<p>The Ruby programming language is introduced like this in the <a href="http://ruby-lang.org" target="_blank">ruby-lang.org</a> web site:</p>
<p style="margin-left:40px">“A dynamic, open source programming language with a focus on simplicity and productivity. It has an elegant syntax that is natural to read and easy to write.”</p>
<p>In digging deeper I found that Ruby is object oriented, provides garbage collection, borrows some interesting features from functional languages (which is something I’ve been meaning to look into), and it has indeed a clean syntax.</p>
<p>However, there were also a few things in Ruby that I wasn’t too excited about. In particular the fact that Ruby is an interpreted language and that it is not statically typed (although it is strongly typed.) After writing code in C# for so many years I had a hard time imaging myself using a programming language that didn't offer these features.</p>
<p>With my background in C# I found the slides for <a href="http://onestepback.org/articles/10things/index.html" target="_blank">10 Things Every Java Programmer Should Know About Ruby</a> by Jim Weirich and <a href="http://www.softwaresummit.com/2006/speakers/BowlerRubyForJavaProgrammers.pdf" target="_blank">Ruby for Java Programmers</a> by Mike Bowler very interesting. Both of these presentations are packed with a lot information on what makes the Ruby language different from Java/C# and highlight its strengths. Some of the topics that they cover include:</p>
<ul>
<li>The Dynamic nature of Ruby makes factories and mock objects trivial</li>
<li>Reflection is also taken to a new level (compared with what you can do in a statically typed language like Java or C#)</li>
<li>Nil is an object which means you never get a null pointer</li>
<li>Closures: an object that is a block of code</li>
</ul>
<p>Jim’s slides also address my biggest concern (namely that Ruby is not statically typed) with a great quote from Bob Martin in which he mentions how the safety net provided by static typed languages is not as important when your code is covered with unit tests as those test would catch type errors for you. I am not sure I agree with this statement 100%. It is certainly an interesting point, though.</p>
<p>You can find these and other interesting articles at the <a href="http://ruby-doc.org/whyruby/" target="_blank">ruby-doc.org</a> web site.</p>
<h2>Ruby on the Mac OS X</h2>
<p>One of the nice things about OS X is that out of the box it comes with the runtime libraries for several programming languages including Perl, PHP, and Ruby.</p>
<p>This is really nice feature for me since that means I can start playing with Ruby without having too worry too much about where to get the binaries or how to compile the source code. In my case my Mac came with Ruby 1.8.7.</p>
<p style="text-align:center"><img src="http://hectorcorrea.com/images/rubyversion.png" alt="Ruby Version"/></p>
<h2>Beginning Ruby</h2>
<p><img align="left" src="http://hectorcorrea.com/images/beginningrubybook.jpg" alt="Beginning Ruby Book" />
I have found the book <a href="http://www.amazon.com/Beginning-Ruby-Professional-Peter-Cooper/dp/1430223634/“ target="_blank">Beginning Ruby: From Novice to Professional</a> by Peter Cooper a great resource to learn how to program in Ruby and get going.</p>
<p>Peter does a great job of covering everything from how to make sure Ruby is installed on your machine, how to install Ruby, very basic programming topics (e.g. what is a class) to more advanced topics like exception handling, database access, web development or Ruby-specific techniques like how to implement enumerators and the yield operator, mix-ins, and code blocks, development frameworks for Ruby like Rails and Sinatra.</p>
<p>I highly recommend this book to anyone starting with Ruby. </p>
<h2>Development Tools for Ruby</h2>
<p>The fact that the Ruby interpreter comes built in with the Mac OS X is great, but what about editors, debuggers, IDE, source control, and other development tools. For somebody like me used to a great IDE like Microsoft’s Visual Studio I was shocked to find that there is no “standard IDE” for Ruby on the Mac or any other operating system.</p>
<p>From what I’ve been able to gather, most Ruby developers are comfortable editing their code in a variety of text editors that provide color syntax, basic statement completion, and indentation but not much more. There does not seem to be a “visual debugger” like what Visual Studio provides for C#, there isn’t the concept of IntelliSense either. Despite this Ruby developers seem to be able to crank up code pretty fast.</p>
<h3>Editors</h3>
<p>You can download for free the Mac OS X development tool (called <a href="http://developer.apple.com/technologies/tools/xcode.html" target="_blank">XCode</a>) that is a full blown IDE and supports color syntax for Ruby but not visual debugger or much more integration.</p>
<p>I’ve found two text editors that seem to be both popular and powerful for Ruby development:</p>
<ul>
<li><a href="http://macromates.com/" target="_blank">TextMate</a> seems to be one of the favorite editors for Ruby (and Rails) development on the Mac as it provides really nice keyboard shortcuts for code completion, running unit tests, integration with source control (both SubVersion and Git) and other goodies. <strike>This has been my favorite editor so far. It is not free but I will probably end up buying a license in the next few days.</strike> <b>Update: </b>As I indicated in my <a href="http://hectorcorrea.com/Blog/Web-Development-on-the-Mac-OS-X-part-II">follow up post</a> I ended up going for Sublime Text 2.</li>
<li><a href="http://www.barebones.com/products/textwrangler/" target="_blank">TextWrangler</a> is a free text editor and supports color syntax for Ruby. Somehow I found the workflow for Ruby development not as good with this editor as with TextMate but you cannot beat the price.</li>
</ul>
<p>Here is an screenshot of TextMate</p>
<p style="text-align:center"><img src="http://hectorcorrea.com/images/mac_textmate.jpg" alt="TextMate"/></p>
<p>There are plenty of other editors that people use on the OS X to edit Ruby code that are common among *nix users including Vim and Emacs. Yet, for somebody like me, with a Windows background, those editors look and feel like something from the stone age. They can be very powerful once you learn them but the learning curve might be very steep.</p>
<h3>Visual Debugger</h3>
<p>There is not a visual debugger like the one in Microsoft Visual Studio for Ruby on the OS X or other *nix environments. This has been one of the biggest shocks to me as I’ve gotten used to have one and still miss it. </p>
<p>One can make the argument that if your code is testable and properly structured (small methods, classes with single responsibility) the need for an advanced debugger is less critical. That might be true but I am still dumbfounded by the lack of one. I really hope that Ted Neward’s <a href="http://blogs.tedneward.com/2011/01/01/Tech+Predictions+2011+Edition.aspx" target="_blank">prediction for 2011</a> that “Apple starts feeling the pressure to deliver a developer experience that isn’t mired in mid-90’s metaphor” comes true.</p>
<p>I should clarify that <i>there is a debugger in Ruby</i> that allows you to step through your code but it is nothing like what I was used to in Visual Studio.</p>
<h3>Source Control</h3>
<p>Although more than two years old the article <a href="http://www.smashingmagazine.com/2008/09/18/the-top-7-open-source-version-control-systems/" target="_blank">7 Version Control Systems Reviewed</a> in Smashing Magazine is a great resource to get an idea of what’s available and popular on the Mac OS X.</p>
<p>Of the source control systems mentioned in the article so far I have only experimented with Git and I am very pleased with it. As with the text editors I was a shocked with the lack of visual tools to do basic operations like check in and check out but this probably due in part to the lack of a standard IDE for Ruby development.</p>
<p>However, Git’s installation process on the OS X was incredible painless. I was pleasantly surprised on how well documented the process to <a href="http://help.github.com/mac-git-installation/" target="_blank">install it</a> and get <a href="http://www.kernel.org/pub/software/scm/git/docs/gittutorial.html" target="_blank">started</a> are. I did notice that Git seems very light-weight compared to a traditional source control system in Windows (e.g. Team Foundation or SourceSafe.)
<p>It has taken me a bit to get used to depend on command line tools to check in and check out my code but at the same time I am amazed how simple it becomes after a few days of using it. I am even using GitHub to push my code “to the cloud” and keep a copy of it outside my machine. </p>
<h2>In Summary</h2>
<p>So after little bit more than a month of playing with Ruby on the OS X on my spare time, I am starting to get familiar with the language and the development tools. All of a sudden I find myself writing code without looking at my book (or the web), running my unit tests, making changes, and checking my changes to my local and remote source control repositories. I am not nearly as proficient with Ruby or the development tools on OS X as I am with C# or Visual Studio but I am starting to get to the point where I feel comfortable.</p>
<p>I am sure it will be a fun and interesting ride. I’ll keep blogging about my experiences of learning Ruby (and eventually Rails) and the development tools for OS X as I learn more.</p>
<p><b>Update: </b>Check out <a href="http://hectorcorrea.com/Blog/Web-Development-on-the-Mac-OS-X-part-II">Web Development on the Mac OS X</a> for an update on my experience 18 months later.</p>
Something went wrong with that request. Please try again.