11 ms·
This is a perfectly cromulent article, but as someone relatively new to Ruby, I don't see the beauty. Perhaps I've spent too much time with the airless ascetic
by jfb 16y ago
This is a perfectly cromulent article, but as someone relatively new to Ruby, I don't see the beauty. Perhaps I've spent too much time with the airless asceticism of, say, Scheme, but Ruby just reads a mess to me. Too many synonyms, too much implicit behavior. There's too much language for my taste. Of course, beauty is in the eye of the beholder &c., &c., &c., and I wouldn't deny that there is a certain pragmatic attraction (even I like to get shit working). But beauty?
- steveklabnik 16y agoI think you've answered your own question: beauty is in the eye of the beholder. That said, I think Ruby is beautiful for a few reasons, but they mostly stem from the fact that Ruby strikes the perfect balance between Lisp and Other Languages: it's taken just enough of the good parts of Lisp and grafted them onto a more 'usual' language. Maybe 'grafted' is too harsh, it's Lisp _from the perspective of the rest of the world_. It's taking Lisp's ideas through a slightly different lens. Whatever, I'm almost rambling. You get the idea. Some people think Java is beautiful, too...
- masklinn 16y agoIt's mostly taking Smalltalk's ideas, not Lisp's, and it's crashing those ideas from orbit into Perl, of all things. Ruby doesn't have Lisp-style lambdas, or macros, or conses, it has blocks and messages (it tries to anyway) and classes. That's the Smalltalk recipe book. Ruby uses `select` and `reject`, `collect` and `inject`. Those come from Smalltalk's collections.
- steveklabnik 16y agoBroad generalizations are always false. Smalltalk's influence on Ruby is undeniable, but matz has specifically said Lisp influenced him, as well. You're speaking of Lisp's _features_, I'm talking about Lisp's _ideas_. It may not have 'Lisp macros,' but it does embrace metaprogramming, for example.
- masklinn 16y ago> Broad generalizations are always false Are you reminding yourself of that issue? > but matz has specifically said Lisp influenced him, as well. He might have said that, but I don't see it. Then again, considering what he did to Smalltalk it might be very, very well hidden. And in a pretty sad shape. > You're speaking of Lisp's _features_, I'm talking about Lisp's _ideas_ They're in the same state. > It may not have 'Lisp macros,' but it does embrace metaprogramming, for example. Lisp metaprogramming is macro-based, unless you're getting into CLOS. Smalltalk's metaprogramming is based on metaclasses and "unhandled message" forwarding. Guess which one Ruby has?
- steveklabnik 16y ago> Are you reminding yourself of that issue? Both of us, yes. My original comment was painting with a broad brush, and your follow-up is too. > Guess which one Ruby has? You're still speaking around me. The implementation of Ruby's metaprogramming is irrelevant, it's the place of prominence it's been given in the design and culture.
- spacemanaki 16y agoFrom Scheme (or even Common Lisp), I would agree with you, Ruby isn't exactly beautiful. But from Java (which the article compares it to), it's glorious.
- dasil003 16y agoI find the beauty of Ruby to be in its object orientation model. The underlying simplicity of Ruby's Modules, Classes and Eigenclasses, and the richness of the architectures they enable is quite elegant and inspired. The rest of the language is definitely more about pragmatism. How could it not be with the Perl legacy?
- ashleyw 16y agoI really didn't like some of his examples (especially the part containing 'longer_than_5', that was hideous IMO!) He tried explaining Ruby's simplicity…by using some of the most confusing idioms. For example: array.select &:even? Is really just: array.select{|n| n.even?} I generally always use the latter. It's just cleaner. I hate overly clever code.
- jpr 16y agoOverly clever or confusing to you, idiomatic to others (and vice versa).
- axod 16y agoThe former isn't guessable unless you know special modifier characters. It's also error prone if you typo a single character. The latter is readable.
- djacobs 16y agoThat's true, but the modifier character* (not more than one) is consistent: & says "take the named method, call to_proc on it, and pass it in as a block". Since many methods allow blocks to be passed to them, this kind of code is useful and well-understood, I think. I want to note that the &:even? idiom is only used in the simplest cases.
- chc 16y agoYou're contrasting "not guessable" with "readable." The behavior of Ruby's `||` is not guessable for a lot of people but it's still quite readable if you know the language.
- ionfish 16y agoWhich of these Haskell examples do you prefer, then? filter even xs filter (\x -> even x) xs
- masklinn 16y ago> This is a perfectly cromulent article, but as someone relatively new to Ruby, I don't see the beauty. Perhaps I've spent too much time with the airless asceticism of, say, Scheme Yes. Ruby is beautiful when you come from PHP or Java or C++. If you come from Python it's meh because it's a very similar language (though the community is different and a number of recipes/best practices are very different) at the syntactic and at the semantic levels, and if you come from Lisps, from Smalltalk, from ML or Haskell, etc… then it's not "meh" it's "ugh", because the language is far more complex less orthogonal and far more full of weird corner-cases than what you come from. TFAA came to Ruby from Java, so Ruby was like seeing the Sistine Chapel for the first time.
- rue 16y agoI have a strong dislike for the now-nearly-meaningless terms "beautiful", "eloquent", "elegant" &c. but for me the deciding factor between Ruby and Python for a project (assuming no constraints from libraries required and such) is Ruby's internal consistency. Python is a bit more haphazard; the infamous `len(str)`, to wit.
- masklinn 16y ago> Python is a bit more haphazard; the infamous `len(str)`, to wit. There is nothing infamous about it. It's a multimethod, the designers of Python decided that mandating the same function for everything (via a common protocol under the covers) was better than risking people implementing a thousand different method names. They did the same with the iterator protocol.
- rue 16y agoI think that is a poor argument since the same is not true of every function. Therefore, it feels inconsistent to me, which is the only basis I can make judgments on.
- masklinn 16y ago> I think that is a poor argument since the same is not true of every function What is not true of every function?