A little while ago I blogged about my experiences with the Ruby programming language. I got an email, which I believe raises some valid points (and of course adds a couple more points why you should learn Ruby, which obviously is a Good Thing TM). But before we start, please take a look at the following Paul Graham articles, as he expresses some of my points in a much much more eloquent way.

The Python Paradox

Beating the Averages

Without further ado, let’s see what the reader cared to comment:

One of the reasons people should learn less mainstream languages, such as SmallTalk, Lisp, Haskell and so on is so that they can recognize limitations and capabilities of current mainstream languages. There’s not that much new in Ruby, nor in C#.

I wholeheartedly agree. Although the Amiga Persecution Complex can be quite prevalent (as in “Why we are not programming in Objective-C, after all John Carmack (who shares the same initials as Jesus Christ and when it comes to programming he is probably more important ;) stated that it was his favourite programming language)”?), spending some time and doing some archeology can pay off significant dividends, especially from the fields of functional programming and whatnot, areas that are usually associated with academia and all the false connotations that come with it. So dust-off that Ocaml book today.
Because they never took the time to learn other languages besides mainstream ones, they don’t understand what the fuss is about and dismiss it as open source zealotry.

Here is a point that I wholeheartedly agree. It is quite funny seeing languages such as C# trying to incorporate features (or to put it more colloquially “tack-on”) that have been doing the rounds for years in some not-so-leftfield languages. So, more often than not, a couple of language revisions down the road, they end up using features that were chastising in the first place. Additionally, a pattern that is often observed is that due to lack of exposure to different technologies, they can be sitting at a gold mine and not realizing that ;).

They also don’t understand the power of an open community working around programming tools because they have never experienced it… I like my languages to come with code, a real community and to run everywhere, thank you!

Amen and write back soon! :)

Before we start, download and install Ruby. This blog post will offer some newly found insights about the programming language and more specifically, the reasons that I enjoy programming in this language more than others. I will not however fall into the trap of promoting Ruby as the solution for every problem or how is the best programming language ever. Rails will not be discussed, even though some view it as the main driving force behind Ruby’s popularity.

After spending some quality time with the language and a few good books, I found myself to be insanely more productive. Once you get your bearings with the language, you find yourself spending more time actually expressing your ideas than fiddling with the language itself. Yukihiro “Matz” Matsumoto set this as an explicit design goal and he succeeded. The syntax is quite freeform and coding in it appears fluid. The price you pay for this fluency is that since there is a variety of ways to achieve the same objectives, so making reading other’s people code difficult if you do not understand all the concepts (however, while the language borrows quite a lot from Perl, it is not write-only code :) ). A good standard library  takes cares of most of the coder’s needs and there is a substantial amount of free to use code in the form of gems. If you are unlucky enough to be using Windows, the one-click installer comes with a bucketload of goodies that tie-in nicely with the operating system. However, maybe it is a bit retro, but my preferred way of developing in Ruby is under a terminal using vim in any Unix-like operating system :)

The reflection and meta-programming capabilities of this language are incredible. The price for this is the reportedly slow runtime. I will not attempt to refute this, Perl and Python have faster runtimes, but Ruby was fast enough for my, admiteddly limited, needs. Reflection is an integral part of the language. I realized how advanced Ruby is in this sector, when I had to program in C# and spent some stolen time writing toy reflective programs. On an anecnodal note, having to write a lot of similar C# code, I seriously considered to write a Ruby 20-liner to generate all this code for me (and not doing so given the fact that I had only 3 more classes to go and really wanted to end my part soon). Given the fact that a few years back I had to work with the monstrosity of EJB 2.1, I think you will spare me for not messing around with Java. Reflection, combined with duck typing solve a lot of your problems and appear to have been genuinely thought in the design and not tacked on as an afterthought. The language carries quite a big back of tricks but you can read about them in far greater detail elsewhere.

Ruby’s biggest advantage for me is that is extremely freeform. You want to write a quick-n-dirty #!/usr/bin/ruby script? Go right ahead. Want to create something a bit more complex? The abstractional capabilities are there. If you are willing to sacrifice idiom and the most advanced features, you can write strictly procedural-like code. However, by doing so you will miss the extremely flexible nature of the language. When the more oneself is becomes familiar with the more advanced features, he starts to see the overall elegance of the idiom and the crudeness that one has to bear for the name of CPU efficiency.

It is not that Ruby does not has flaws, like the slow runtime mentioned above, and that you have to be careful with the implementation you are using, as it might introduce some subtle bugs with Threads. And let’s not forget some of the syntax is an acquired taste. However, the biggest drawback is that perhaps is not a begginer’s language both in the way that you have to know at least some of your programming stuff to start appreciating the language and that if this is the first language that you will learn, will have quite a hard time adapting to different (stricter?) paradigms.

Having said all that, I still like Python, another great programming language that should definetely give a shot if for some reason Ruby does not tickle your fancy :)

Book Cover

This book is aimed towards the neophyte Ruby On Rails developer. The majority of books out there either are focused towards Ruby as a language or assume that the reader is familiar (if not downright proficient) with the language and proceed to explain the framework. As you can tell, there is a lot of middle ground between these two categories and this book comes to fill the void. The first couple of chapters are a short introduction to Ruby as a language and Ruby On Rails as a framework. The “meat” starts from chapter three and afterwards. The writing style is excellent, not dry but does not makes quick jabs at humour. The author really seems to understand his material and (at least for myself), there is an abundance of “I should have guessed that/This is an excellent new idea!” moments that tend to shed some light into the more quirky aspects of RoR. The sequencing of material is great, it follows a quite logical progression and before you know it you will be dealing with the more esoteric features of both the language and the framework. Having said all these great things, the main criticism is this: in order to make full use of the book you need some external reference material. My suggestions are “Agile Web Programming with Rails” as an external Rails reference and “Programming Ruby” (AKA “the pickaxe book”) as a Ruby reference. But as my second RoR book, it really shines and I cannot but highly recommend it to persons in a similar situation with me. A more formal review will follow when I will have reread the book.

Ruby On Rails real strength

October 16, 2007

  • Faster in development time than J2EE (the claim that a small RoR application can be the size of all XML documents required to work with J2EE is correct)
  • Better than PHP (forces you to avoid bad development practices, a case that is seen all too many times)
  • YAML :)
  • Cool kid on the block

Other than that, if you are outside DHH’s frame of mind, good luck :-)

Since this is the first Ruby On Rails book I have read in its entirety (for reasons too lame to explain here), I decided to write a short review. The book is a really light one and is aimed towards the person that has no Ruby on Rails experience whatsoever (it is stated in the very first paragraph).

After the usual prologue stuff, we get some installation instruction for MacOS X and Win32 but NO LINUX?!? Getting rails on a linux box borders on trivial but still some installation instructions would be much appreciate, at least for the sake of completeness. The main pedagogical model of the book is learn through developing (an approach that worked superbly in the “Heads First” series of books) so throughout the book you will be developing a web application for a classified ad system. The application itself is not that bad but the first criticism arises when trying to punch in the code. Lots of typos! A user review in amazon.com also states that the code in the book’s homepage has the same errors. As a somewhat experienced programmer with an internet connection I was able to figure and solve them put perhaps this is not a task for everyone and what was the editor doing?

Ruby on Rails has gone a few revisions. This one is aimed for the v1.0 crowd so if you run some of the code with the -w switch or if you bother to check the API documentation you can see that some of the stuff included in the book is deprecated or on its way out. Still, the code (assuming the above typos are fixed) still works.
Which brings us to the second criticism of the book. There is little explanation. I am all for learn by example but not even basic syntax is discussed. The author gives the general idea of what is about to do and why but does not provide alternatives. So it is up to the reader to work out the details for himself.

Some of the good points of the book is that it gives a brief treatment of AJAX (still sorely lacking in details so you have to figure out on your own how to extend the examples) and how it is integrated within Rails (once again not something mind blowing but you do get to see it in action) and a novel idea: Microformats! While I have read about them in a issue of Linux Format, it was nice to see them referenced and applied in a real project.

Having reached the application in a pretty usable state (the cop-out line “this goes beyond the scope of this book” can be seen quite a few times but this is understandable due to the nature of the book), the authors take a U-turn and presents us with scaffolding. I really am in favor of this argument that scaffolding should be introduced after one is familiar with the basics but at least he could give us a bit more analytical overview of scaffolding and contrast the two approaches.

The book closes with a treatise of Testing. Testing is very important and one of the fundamentals of Rails is to facilitate testing. This is not accentuated nowhere in the book and the whole appendix looks like “we put it there because it had to be there”.

Overall, this book is a fire and forget effort.If you had no exposure with Ruby On Rails you can pick up the pace by reading it once. The language of the author is quite clear and for the most part, the visual design of the book helps (although a bit MacOS X oriented). But do not expect to be rereading this. I have not read O’Reilly’s offering towards the newbie RoR crowd so I cannot contrast the two but this one will be gathering dust. Perhaps a more appropriate title could be “Ruby On Rails - a use once and forget” book.

Ruby On Rails

August 29, 2007

Undisclosed Ruby On Rails project:
So far so good…
Or better
so far so good so rocking :-)

MVC, MVC, MVC

One of the most abused compound design patterns with many heinous crimes committed to its name. I will not compare RoR vs your_favorite_web_app_technology here, I am not a master of everything and I am pretty new to this RoR game so…

Strict and efficient separation between the eM-Vee-Cee. Good thing.
A ton of work is taken care by the framework. I had it connecting to 2 different databases in no time (I am assuming that the default stuff is sane, as I did not had the time to to investigate it).

Syntax: like a one night stand with a so and so girl, a bit ugly but fast.

I will be investigating security aspects of it a bit later.