Live data from Hacker News

The Ruby Stdlib is a Ghetto

mikeperham.com

1–10 of 49 posts

Re: The Ruby Stdlib is a Ghetto

#2
I got the updated version of the Pickaxe recently and skimmed through all of the 1.9 updates. I was appalled to see REXML is still the blessed XML parser. I liked it when I started using Ruby and I still see it in the wild, but to me that's usually the sign of old code or a developer not tuned in to the latest developments.

On the other hand, there has been some progress. It's good to see MiniTest replace Test::Unit (while also remaining mostly backwards compatible).

Re: The Ruby Stdlib is a Ghetto

#3
I am not sure the author's solution, removing the said libs, is the right direction. I agree that the stdlib is crufty and slow, but they do 'work', and people certainly use them. I think the better option might be to deprecate and replace.

Re: The Ruby Stdlib is a Ghetto

#5
post #4

Database Error :(

Copy:

Much of Ruby’s standard library (the set of classes shipped with the Ruby VM itself) is old and crufty. For laughs, go look at the code for some of the classes that you’ve never used. Chances are it’s from 2000-2003 and doesn’t even look like idiomatic Ruby. I’m wondering what classes should be removed from the standard library or deprecated so that higher quality replacements can take their place.

The canonical example is Ruby’s net/http library. Its performance and API are just terrible. (Side note: how do you know if an API is terrible? If you have to consult the docs even after having used the API for the past 5 years.) But because it’s in the standard library, most people use it as the base for higher-level API abstractions (e.g. httparty, rest-client).

So looking at Ruby’s core RDoc, my suggested list for removal (where removal means move to a rubygem):

Net::* DRb REXML RSS Rinda WEBrick XML

Any others I missed? Will Ruby 1.9.3 or 2.0 get a good spring cleaning or will we have to live with these classes forever?

Re: The Ruby Stdlib is a Ghetto

#6
post #2

I got the updated version of the Pickaxe recently and skimmed through all of the 1.9 updates. I was appalled to see REXML is still the blessed XML parser. I liked it when I started using Ruby and I still see it in the wild, but to me that's usually the sign of old code or a developer not tuned in to the latest developments. On the other hand, there has been some progress. It's good to see MiniTest replace Test::Unit…

REXML is kept because many projects that need a pure ruby XML parser rely on it and it works for them. Usually, if you use XML beyond something small, you should use Nokogiri.

Actually, 1.9.2 ships with replacements where possible: for example, CSV is now FasterCSV with a compatibility interface, Psych can be used instead of Syck for YAML parsing.

Re: The Ruby Stdlib is a Ghetto

#7
post #5
post #4

Database Error :(

Copy: Much of Ruby’s standard library (the set of classes shipped with the Ruby VM itself) is old and crufty. For laughs, go look at the code for some of the classes that you’ve never used. Chances are it’s from 2000-2003 and doesn’t even look like idiomatic Ruby. I’m wondering what classes should be removed from the standard library or deprecated so that higher quality replacements can take their place. The canonica…

Great comment - I completely agree about REXML. One question for you - what's an example of a http library in another language which you think provides a good API? Personally, I haven't found net/http to be any worse/better when compared to many other standard http libs.

Re: The Ruby Stdlib is a Ghetto

#8
I don't think this is that much of a problem. If I want to use a modern library, I just type "gem install whatever" and I have the new library. Documentation for the stdlib is not really better or easier to find than that for third party libs, so I tend to use whatever seems nicer after a quick google search and I guess other people do it like that, too.

Re: The Ruby Stdlib is a Ghetto

#9
It seems to me the massive "investments" made in mainly web-related frameworks (Rails, Merb, Sinatra + ORMs) didn't help the foundation of the Ruby ecosystem: Take rubygems, take RAA, take the MRI development process.

If you got "brainwashed" in the last 5 years about code quality (DRY etc.) + test methods (TDD/BDD) and then look at today's Stdlib, you'll scream and want to put bleach into your eyes…

To me it seems the "übercool" guys already moved away to their NoSQL/node.js/whatever next party, so it's not easy to motivate people to change such "messy" and large projects anymore.

I'm also not sure about the number of Ruby interpreters around and their useful impact: If you e.g. change something for Ruby 1.9.x / 2.0.0, it will cost a lot of manpower to port those changes to JRuby, Rubinius, maglev, IronRuby and BlueRuby (if SAP's Ruby is still alive?) and most of them are just used by very few people.

Maybe resources are better spent in creating a new Stdlib, improve the rubygems infrastructure (already started with gemcutter) and do something with RAA?

Re: The Ruby Stdlib is a Ghetto

#10

I am not sure the author's solution, removing the said libs, is the right direction. I agree that the stdlib is crufty and slow, but they do 'work', and people certainly use them. I think the better option might be to deprecate and replace.

Unfortunate choice of wording on the authors part, because it makes it seem like your solution is less drastic than his, whereas your solution is actually more drastic. To quote the author: "removal means move to a rubygem".
Post reply on HN