6 ms·
A criticism of Ruby (2013)
- Exuma 9y agoYawn. If you don't like it, don't use it. I don't understand peoples obsession with writing huge thought pieces on why they don't like something.
- danharaj 9y agoWhy write anything?
- falsedan 9y agoTo impress potential partners.
- philwelch 9y agoI learned a lot by reading this article, and found it rather interesting. I don't understand people's obsession with writing dismissive comments about HN articles they don't want to read.
- posterboy 9y agoif they had to use it for one reason or another the criticism would be justified, eventually.
- ChrisSD 9y agoI think that's short sighted. It worth it to criticise anythong, even the language of the day. So long as those criticisms are instructive.
- codinghorror 9y agoHas any of this been addressed in recent Ruby releases? The velocity of the project has improved since 2013.
- sundarurfriend 9y agoI haven't yet finished reading the article, but it's a lot more educational and interesting than I expected. As a casual Ruby user, I expected maybe a bunch of bullet points about minor annoyances and issues of taste, but this is a thoughtful, enlightening piece.
- andrevan 9y ago"The criticisms above are not matters of taste" Actually, yes they are.
- hacknat 9y agoOkay. He spent more time on his argument than you did countering it. Care to elaborate? It’s not self-evident to me that you’re right.
- DannyBee 9y agoTo be able to say something is an error in the sense the author uses requires the ability to determine objective, rather than subjective, correctness. The author asserts, incorrectly, that there is some objective correctness in choice of interacting language features and their interactions. No such thing usually exists. It is all subjective at some level. It is not more or less wrong to choose one spec for a language feature over another. It is just taste. The closest you can come to objective correctness or incorrectness is incorrectness of an implementation in implementing a language specification or inability of a specification to correctly describe behavior. Ie given a precise definition of how a language feature should operate, does it operate that way. Most criticisms of programming languages, including this one, try to take the fairly abstract goals of most language features and pretend that they can show, objectively, that the feature does not meet the goals. The problem, as mentioned, is that most of these goals are very subjective. So are the criticisms. They are not saying "Ruby claims to have the following algebraic specification for modules, but I prove that is impossible" they are saying "here is my subjective interpretation of the following be goal Ruby has. I can objectively show it does not meet that goal" Such a thing is still a subjective criticism, not an objective error.
- philwelch 9y agoI can see your point, but, to pick a couple specific points—it is strictly better to have thorough documentation than not to, and it is also strictly better to have a language with a defined grammar to support linters and the like than not to. These aren’t trade-offs, or else, I don’t see anything that Ruby has that wouldn’t be possible without the drawbacks the author notes. Perhaps you know of some features or strengths that Ruby has that wouldn’t be possible without these drawbacks?
- rajangdavis 9y agoI read through this article twice and I don't get it. I feel as though I don't have enough background to understand the arguments presented. I use Ruby all the time and love it; can someone simplify the main points of this article? My impression is that what the author wants and what I want from a programming language are different, but I don't want to write off his arguments because of my lack of understanding.
- lloeki 9y agoI have a similar set of unpublished notes, ramblings and draft articles on similar subjects and endlessly delay to push them out. My personal conclusion is that Ruby is an appealing language but numerous problematic areas pervasive to the core, the code, and the community can (not automatically) add real, damaging weight to a project. Those notes aren't just rants, as I'm quite the constructive person and been set to research them and address some, here's an example: https://github.com/lloeki/pak/blob/master/README.md https://github.com/lloeki/pak/blob/master/README.md Unfortunately there is no chance most of the issues will ever see any fix, which makes me wary to use or recommend Ruby for new projects (but I do use it still, only cautiously so and well aware of its limitations)
- zkomp 9y agoI don't get it either. Neither see the supposed (objective) "errors" in the language design. Why not have both raise/rescue and throw/catch when the used are different. And why not have both methods, functions and closures? It is for different things... Why read docs when you have irb and can pretty much inspect everything you need. All the comparisons with java... I hate it, much rather use ruby style OO than the horrible boilerplate hell that I remember from java. Problem with ruby is not that it is not java, it is imho sometimes it is too easy and forgiving - letting you do crazy things like unintentional meta programming, and not catching errors until runtime. Other problems with ruby is complexity and the lack of clear spec (lookup what happened to the rubinius ruby spec project).
- zbentley 9y agoDebuggers/inspectors are great, but they absolutely do not serve the same need as documentation, and any language/community that recommends the former in place of the latter should be considered suspect as to the quality, reusability, and extensibility of its creations. > Why read docs when you have irb and can pretty much inspect everything you need? Because irb is another tool I have to learn how to use if I'm new to a language. Even if I already know the tool, I have to learn how to get the inspector to my code in order to inspect it in irb. That can be quite hard if I want to inspect an object that gets described and constructed during the runtime of a big "harness" I don't control. How do I get the inspector to run precisely where I need it to? In most situations like this, the code I want to inspect is itself running in a new process, or on a different server, so "just drop a breakpoint in", while possible, is far from easy advice to follow. And all that is assuming that the inspector's output, when I get it, will be at all useful! What if the code I want to inspect is highly dynamic, and has different object "shapes" at runtime depending on subtle differences in inputs? That kind of code isn't obscure in ruby land--I've seen common situations where inspection is at best a waste of time and at worst actively deceptive in Puppet, ActiveRecord, and various RSpec-ish frameworks. That's not to say their code is bad; just that it's a really bad idea to assume that a inspector can double as a documentation authority. The alternative--textual documentation--is absolutely essential and cannot be replaced with a debugger/inspector. I already know how to read English (or doc-language-of-choice). To read documentation, I don't need to learn a new tool (designed for prototype testing and debugging; probably not the first concerns on my mind if I'm at the "check the documentation/API reference" phase of development), carefully construct a contrived runtime context to reach my code, extrapolate the output as intended for the runtime back into something human-intelligible, and then pray that what I found is the right output, or is in any way representative of what my code is going to actually encounter when it runs.
- woodruffw 9y agoI disagree substantively with this paragraph: > Ruby has no well defined grammar. All the Ruby implementations today reuse Matz's original parsing code. There are various BNF grammars people have written for the language, but they may or may not match the actual implementation. Nor does Ruby provide a mechanism to turn code into an abstract syntax tree for you as Python and Lisp do. Anyone writing tools beyond a unit testing library must solve this problem first, before ever doing any real work. Ruby's grammar is well-defined, it's just implementation defined rather than specification defined. That alone is a problem, but I think the author makes a mistake in associating an external specification with the state of being well-defined[1]. Being able to turn your code into an AST can be useful, but I think the author overstates its value. Personally, I've never wanted or needed to inspect Ruby's AST in a practical application. When I'm fiddling around, I use whitequark's parser[2][3], which has always worked well. [1]: It's also worth noting that Ruby does have a formal ISO specification (https://www.iso.org/standard/59579.html https://www.iso.org/standard/59579.html), albeit for 1.9.x syntax (IIRC). [2]: https://github.com/whitequark/parser https://github.com/whitequark/parser [3]: Which, notably, just takes Ruby's `rubyNN.y` and exposes the AST as Ruby objects.
- mistercow 9y agoLinters typically operate on the AST for your code, though, and differences between your linter's grammar and the real grammar can cause headaches. More ambitiously, I think there's a huge amount we could be doing with ASTs, where right now we're mostly kludging along with line-based tools. Merging/diffing is one example. I've run up against some truly gnarly merge situations, in particular with indentation based languages, where automatic merging did what could best be described as "stirring" the code, and manual merging was like pulling teeth. It's bizarre to me that in 2017, we're still using tools that act like our source code files are made of unstructured lines of text, instead of exploiting the precise structure that the language imposes. I don't know of any remotely mature tools that try to solve this problem, although I've seen some more research-like projects. The potential gains seem huge. For example, imagine renaming a method throughout your project, and having no merge conflicts with your teammates, even when they change the same lines where that method is called. (Or at least, imagine having a merge tool that proposes the correct merge for your approval.) But if we're going to move toward tools like that, languages without formal specifications are an obstacle.
- norswap 9y agoI concur. Shameless self plug about something I wrote about the first issue (documentation): http://norswap.com/ruby-specification-problem/ http://norswap.com/ruby-specification-problem/
- mattmcknight 9y agoThis is an annoying document. He goes into long, wrong explanations of different concepts, and then provides very minimal examples of how Ruby doesn't work like Java or some other imagined ideal language does in his conception of the world. A person that has a particular way of programming often will struggle trying to impose that way on another language. Documentation: One criticism is that the documentation is somehow incomplete. I think https://www.ruby-lang.org/en/documentation/ https://www.ruby-lang.org/en/documentation/ and http://ruby-doc.org/ http://ruby-doc.org/ neatly dissolve that. The other criticisms appear to be things that would largely apply if one were trying to implement a Ruby interpreter, which is not the normal task of a Ruby programmer and are irrelevant, but also largely wrong. Most Ruby developers are not consulting the source code of the interpreter to determine what functions do on a regular basis. Interfaces: This is largely a meaningless complaint about the lack of specific thing called an interface in Ruby, when it is largely not needed as they are a mechanism to work around strict typing. The long example of streams is something that is easy to do in Ruby. The examples are then one case where the OpenSSL library has a different name for a method than the standard library for sockets, that the rexml SAX2 parser and Nokogiri are slightly different, and then some odd complaint about streams again. This is a ridiculous complaint about different libraries doing things differently, not related to interfaces at all, and Ruby would let you easily work around this situation if you ever needed to. Namespaces, compilation units, and modules: The explanation for this is tortured and simplistic. You can see confusion shining through when he calls a Ruby file a compilation unit. It just doesn't work that way. Multiple files can contribute to a Module or a Class. The supposed criticism here is incoherent and seems to be incomplete. What is he trying to do? Why can't he do it? But he can do it; he just doesn't like how it is done? Multiplication of like things: This is basically a weak criticism of TMTOWTDI, but using "orthogonal" in an incorrect way that makes the whole thing nonsensical. It complains that Ruby has too many functional constructs, which is not the typical complaint one sees. MN vs. M+N and what it did to the language: Nonsense again, suggesting that one must use multiple inheritance to write a polymorphic max(a,b) function, and since he doesn't like that there are two ways to include modules in Ruby, something is bad? No case made at all. Tooling and reasoning: This is just a disgusting set of lies. I think he's never heard of JRuby which has been an active project for 16 years. Try RubyMine if you want a smart IDE for Ruby. "The criticisms above are not matters of taste. They are errors in language design." Absolutely incorrect on two counts, they are almost all taste, and many of them have zero to do with language design. How about this- if they were errors, that would suggest that there is a right way to X, Y, and Z. Instead, we are given examples of how language A does something, and a statement that Ruby does it differently. Given that we are dealing with humans here, there are clearly large numbers of humans that prefer the Ruby way. Given that there is nothing listed here that can't easily be done by a single line of Ruby code, it hardly stands up as evidence of any error in language design. Frankly, I find the preferences expressed here bizarre. The attempt to tie them to language design errors just seems stupid.
- twelvechairs 9y agoFor me as a ruby user, the things that I can agree with (and maybe build upon) as criticisms here are: - Ruby's origin as a single implementation has led to a few ongoing issues in documentation. This has been generally fixed considerably over time. Its lack of a '100%' AST still bugs me a little (ruby2ruby and ruby_parser only get you so far). As noted also, its not really built for some tasks like moving a method from one module to another. These are all really quite a niche issues however which wont affect 99.999% of programming. - There's a few 'gotchas' in learning Ruby's module, namespace, etc. systems (include/extend, raise-rescue/throw-catch, return from a block). However, most programmers learn these reasonably quickly and as a language Ruby is probably simpler in terms of these issues than others. - Ruby's TIMTWODI approach has caused a few areas where there are different libraries doing the same things in different ways (e.g. as noted unit testing - though RSpec is great) - a more mature language may just 'pick a winner'. TIMTWODI's got its advantages though. However, the author also mixes the above with some very oblique views on language design. Particularly where it goes down to paragraphs like 'Multiplication of like things', 'M+N' and 'Compilation units' etc. - there's not much discussion on ruby at all other than rather weak criticisms of ruby's module/namespace systems at the end, as they dont meet the writers preconceived ideas of how these should work. The final assertation that these 'errors in language design' mean you shouldn't use ruby because 'it is not the only language in its niche' is really ridiculous however. The author doesn't state what the better alternative is (or even define what ruby's niche is), and I'm sure any one which is picked would have its own issues - and these would have at the very least a different set of tradeoffs than those in ruby.
- philwelch 9y agoThe obvious niche for Ruby is the niche shared by Perl and Python. Having used Ruby full-time for 4-5 years and Python full-time for the past year, I think Python is strictly better than Ruby in the particular areas mentioned by the author. I can think of a couple major reasons one would prefer Ruby to Python, but only a couple: * Ruby has a more flexible syntax, which means you can write "DSL's" in Ruby. Rake and RSpec are generally given as examples. Unlike actual DSL's, though, Ruby just lets you leave out parentheses so you can pretend that the handful of functions you just call a lot in a Rakefile or an RSpec test are keywords. I'm not sold, but some people may prefer this aesthetically, and there's really no way to argue against that. * Ruby is all-in on object orientation, in a "poor man's Smalltalk" kind of way. There are advantages to this, since you can just.call.methods.on.everything(like: this) or iterate by calling .each, which is simpler than Python's double-underscore protocols. There are surprisingly few disadvantages, because you don't have to actually write in an object-oriented style in Ruby. I personally don't find these arguments convincing.
- dsjoerg 9y ago"They are as hard to confuse in your memory as a small Chinese woman with a giant black man."
- flavio81 9y agoI found it a well explained article. The author throws good, pointed references to Smalltalk, Lisp, Python and C in the comparison, and indeed there are areas in which Ruby seems to be a bit awkward. However i'd say there is little criticism of Ruby there and more of a comparison of typical aspects of different programming languages.
- djr96 9y ago"Nor does Ruby provide a mechanism to turn code into an abstract syntax tree for you as Python and Lisp do" That's not even correct, ruby's standard library contains a Ripper class that does just that: http://ruby-doc.org/stdlib-2.0.0/libdoc/ripper/rdoc/Ripper.html http://ruby-doc.org/stdlib-2.0.0/libdoc/ripper/rdoc/Ripper.h...
- stevebmark 9y agoThis is so good. This person is eloquent and to the point and clearly very smart.