4 ms·
Background/disclaimer: I learned Ruby first (largely thanks to _why's guide), but have been using Python at my job and in my personal projects for about a year
by jrheard 16y ago
Background/disclaimer: I learned Ruby first (largely thanks to _why's guide), but have been using Python at my job and in my personal projects for about a year and a half now, and have grown to prefer Python.
The main gripe that I have with using Ruby as a teaching language is that the whole magic thing. You address this really well, and I really like your passage on abstractions, but I don't agree that the magic is just limited to advanced usage of the language.
Here's my gripe in its most pure form: in Python, in order to figure out all of my capabilities right now (short of what things I can import), I can use dir(object_i_want_to_know_about) and see everything that object can do. I've got a friend who's learning Ruby, and we wanted to find a built-in String method to see if a string starts with a prefix. We found it after Googling, but I wanted to find out about it in the context of the REPL. I figured that Ruby must have similar functionality to Python's dir(), but as far as I can tell, the only way to achieve that is to hack the REPL in a very minor way (you can add a few lines to your .irbc that will achieve this). There doesn't seem to be anything like dir() built into the language, and so it's a lot harder to figure out what you can do at any given point in time without Googling.
I think that this difference speaks volumes about the difference in philosophies between the two languages, and is in large part why when I introduce friends to programming these days, I tend to do it via Python, in particular via Zed's book.
I haven't used Ruby much in the past year or two, though, so if I'm completely mistaken about my assertions here, I'd love to find out about ways in which I can reason about the options available to me when I'm hacking around in irb.
PS: I really liked the code example near the end of the article.
- gmac 16y agoI figured that Ruby must have similar functionality to Python's dir() Sounds like you wanted 'x'.methods => [:<=>, :==, :===, :eql?, :hash, :casecmp, ... ] or the more focused 'x'.methods - Object.methods => [:casecmp, :+, :*, :%, :[], ... ] ?