Every now and then someone comes to me for advice because they (or someone they know) wants to learn to code and has no idea where to start. Usually, the first thing I do is send them to tryruby.org, the awesome web-based REPL and tutorial the Code School folks put together, based on _why’s (poignant) guide to ruby.
Lately, I’ve been wondering if that’s the best advice. Only because I constantly re-evaluate everything on the chance that it might be sub-optimal. Ruby is pretty easy to learn, but it’s also easy to learn terrible, terrible habits. Maybe a more constraining language would be more suitable?
I have to admit, as much as I generally dislike Python, it probably is the easiest language to learn, and it rarely gives you enough rope to hang yourself. So am I just letting my own prejudices guide my recommendations to other people?
Upon reflection, the language matters a lot less than the person. My egalitarian sensibilities make the idea that any reasonably intelligent person can learn to code, given the desire and determination, quite attractive. But alas, we must be wary of cognitive bias. It’s become increasingly clear that programming isn’t for everyone. So as much as I like the idea that everyone should know how to code, I have to admit that whatever innate ability it is that makes for a Real Programmer, not everyone has it. Not even all of us working as software developers.
I recently came across this question asking for “Criteria for selecting language for first programming course” on the CS StackExchange forum. Answering that question (here) helped me to clarify some of the reasons I usually recommend Ruby.
Ruby is incredibly simple to pick up. Now, like anything, Ruby is hard to do well, but it is fairly straightforward to learn. My first language was BASIC on a Texas Instruments 99/4A. It was hard, but rewarding. I wrote stupid little games, and it was entertaining. Of course, I was 5 or 6 at the time…
The point here is that you want two things for people who have never coded before: immediate positive reinforcement (it’s fairly straightforward to make something that runs successfully), and a syntax that’s easy get your mind around. Ruby fulfills those goals quite nicely.
Once you get past “Hello, World!” there’s an almost infinite range of possibilities. Ruby does a very, very good job of providing a massive collection of libraries, and a flexible language that makes creating damn near anything not only possible, but at some point intuitive.
Pretty much everyone starts with procedural code. That’s okay, it’s a start. But object-oriented and functional paradigms have many, many advantages. Ruby’s pure-OO nature makes it very easy to transition into writing object-oriented code. It borrows enough concepts from Lisp that you can get a feel for functional styles as well. Contrast this to C++ or Python, where the object-orientation is tacked-on, and the bolts are definitely showing.
Se habla Ruby
Finally, I like introducing people to Ruby because it’s a language optimized for programmer happiness.
For me the purpose of life is partly to have joy. Programmers often feel joy when they can concentrate on the creative side of programming, So Ruby is designed to make programmers happy.
My hope, when someone shows an interest in creating software (or at least, learning what goes in to creating software), is that they’ll fall in love with it like I did. I was bitten by the software bug when I was a little kid; it’s been a hobby ever since. But it really wasn’t until Ruby came along that I was certain I wanted to spend damn near every waking hour on this stuff.
Why should I subject others to something less wonderful and joy-inducing than what I use every day?