From: MRH Date: 2008-05-29T21:15:03+09:00 Subject: Re: Should I Learn Ruby as a First Language? Hi Mike, Thank you for this post. > I usually lump beginner programmers into one of two categories, (i) those > who want to become expert programmers for purposes of education, > profession, or hobby, and (ii) those who are interested in learning how to > program sufficiently enough to make work in their primary careers easier, > but don't necessarilly have a specific interest in programming itself. I am a category (i) ;) > If you're of the former category, I would say it doesn't really matter what > lanaguage you learn first since you will inevitably learn multiple > languages anyways. Yes, please see prior post. :) > Remember that a master programmer is not someone who > expertly understands the minutiae of any single language, but rather is > someone who is proficient in many languages. A-ha! I had assumed the contrary - this is great to know, and it makes sense. > That said, there are a lot of languages out there that are complicated or > even cumbersome because they attempt to be sufficiently general as to allow > any "style" of programming without enforcing too strict of rules as to what > code should look like. Perhaps the best example of this phenomenon is C++, > and to a lesser extent Perl. I express caution in learning these languages > as first languages, since, as a novice programmer you don't really have an > intuition for what code should look like, and the language doesn't really > help guide you in learning either. I see > Ruby is guilty of a similar phenomenon which, in this context, goes by the > name of "expressiveness". While Ruby is certainly my favorite language, I > know that part of my appreciation for this expressiveness comes from over a > decade of experience in other languages and being able to place Ruby in > the context of this experience. > > In other words, I'm not really sure if Ruby is the best, or even a good > language for beginners because I'm not sure how difficult it is to learn > without the benefit of experience. On the other hand, plenty of people > have learned Ruby as their first language and have gone on to recommend it > to others, so it's certainly possible, and probably not a bad choice > either. I will consider this. > That said, keep in mind that Ruby is a bit unique compared to other popular > languages. For example, the idiom of using internal iterators and blocks > as looping constructions (e.g., Enumerable#each) is unlike the usual > approach of using a for loop and/or external iterator as you would use in > C, C++, Java, or Python. While I think Ruby's approach is better, it is > not the norm in other languages. Another example is Ruby's idiom of > automatic allocation and deallocation of resources by passing them to code > blocks (e.g., File#open). In other languages, one typically has to > explicitly deallocate the resource (close the file) and the code for > writing this safely is not intuitive. I get the gist of what you are saying. Will remember. > This brings up another advantage/disadvantage of learning Ruby first: code > safetyness. One example of this is the resource allocation/deallocation > idiom I mentioned above that ensures that resources are always properly > cleaned up when the program is finished with their use. Another is that > most methods raise an exception upon encountering an error, forcing a > program to abort is an unexpected error happens. > > Exceptions are good, and they're prominent in other languages (Java and > Python) and behave, more or less in the same way. Unfortunately some > popular languages implement exceptions (C++ and Perl) but don't use them > universally in library functions, and other languages (C) don't implement > them at all. In these languages, you must (or at least should) check > return values of any function you call to make sure that the desired action > performed successfully. Often times people forget to do this, and the > result is code that continues on ignoring error conditions, usually blowing > up somewhere else where it's difficult to debug. > > So, while I regard these features as advantages of Ruby, they are, in some > sense a disadvantage when you attempt to learn a different language that > doesn't take care of these issues for you, as you must be diligent in > taking care of them yourself and it's not something you're used to. This resonates with my earlier research as well. Will also remember this. > Anyways, the crux of my advice is this: Any language that you're > enthralled by, and can't get enough of, is a good (first) language to > learn. On the other hand, any language that you find bewildering, > confusing, or just plain unfun to learn is probably not a good first > language candidate. If you find youself becoming disinterested after > spending a week or two learning whatever language you choose, skip it and > move on to something else. It may take a while to find the language that > fits, but trial and error is better than giving up on programming > entirely--especially when the language that clicks with you is right around > the corner. Will do. Regards, Maurice