6 ms·
The Ruby Stdlib is not a Ghetto
- aaronbrethorst 16y agoWith all due respect, Net::HTTP is clunky. I'm typing the following from memory, too: require 'open-uri' response = open("http://blog.segment7.net/").read
- derefr 16y agoIf you're doing more than one of those in a single document, having a persistent connection object and sending it request messages wins. (Though open-uri could actually do this, if it cached the connection objects by host:port.)
- catch23 16y agothat's great if all you're trying to do is HTTP GET. standard libs are supposed to make all use cases fairly easy. making an http post isn't too bad: Net::HTTP.new(host, port).start do |http| post = Net::HTTP::Post.new(url) post.set_form_data('blah' => '123') http.request(post) end
- petercooper 16y agoThat's "not too bad" if you're coming from Java. Thankfully most other Ruby libraries have significantly less verbose APIs than this.
- aaronbrethorst 16y agoPersonally, I'm a big fan of open-uri for super-simple requests and HTTParty for anything more complex.
- carbon8 16y agoThere's a much simpler way to do POSTs with Net::HTTP: response = Net::HTTP.post_form(URI.parse("http://example.com"), {:param => "val"})
- leif 16y agoThis is tangential, but I've found that ruby's non-standard libs have, for the most part, been horribly named. Recall from the article: curb, nokogiri, syck, psych, home_run. Others: sinatra, rack, thin, unicorn, maruku. None of these give me the slightest clue about what they do, and if I wanted, for example, to parse XML, how on earth would I know that I wanted to find "nokogiri" (or "hpricot")? Could I pick what I wanted out of a lineup? How do you ruby people find the good libraries when you need to perform a task? Is it all word-of-mouth (word-of-blog I guess)?
- nwmcsween 16y agoTwo second google search would suffice http://ruby-toolbox.com/ http://ruby-toolbox.com/
- leif 16y agoWhat was the query?
- shubber 16y ago'gem -r -d search' works pretty well.
- koenigdavidmj 16y agoSame applies to nearly every tool for every language. yacc, for instance, does not give any indication as to what it does (well, until you expand the initialism). Java is, of course, one place where this is a bit better. log4j and jUnit both tell you what they do quite easily. (But then again, Apache Maven does not.) We have Google these days, and if that doesn't help you, go on the #ruby IRC channel and ask what they recommend.
- jshen 16y agoLucene, guice, solr, spring, hibernate, jmx, osi, nailgun, etc.
- 16y ago
- chrisbroadfoot 16y agoWe should probably aim higher than "not a ghetto" :) I didn't read the article in great detail, but I noticed this: it provides many ways to do the same thing for programmer convenience This is not a good thing, in my opinion. I do, however, find it peculiar that utilities like RSS, FTP and mail handling are included in a stdlib.
- 124816 16y ago> This is not a good thing, in my opinion. This is extremely common, and not at all unique to Ruby. For example, providing defaults for parameters is perhaps the most common and simplest form of this. Whenever a library is used by wildly different clients, there is a good chance the API it chooses will be better suited to one or the other. The same Net::HTTP is presumably used for the simplest of uses, maybe 5 line download scripts, and the most complex of cases, perhaps forwarding http requests with all headers intact. In general I go by "minimal, but complete"; but for widely used libraries that have clients of very different complexities, it makes sense to provide a simple API for convenience. I'd rather not be specifying the client headers, user agent, supported encodings, etc, etc each time I want to fetch a file over http.
- Argorak 16y agoI think the point here is: Net::HTTP has convenince methods to just "fire off a GET request" as well as the ability to hand-craft a request and send it over a pre-established connection (maybe implemented by myself).
- erikpukinskis 16y agoPeople also need to be a little more careful about using the word "ghetto". It has a long history, from Jewish ghettos in Europe during World War II, to modern day black ghettos that persist in most big cities in the U.S. Many people today still grow up in "The Ghetto," which is a place of geographic, economic, and political marginalization. Before you go talking about "Wii is a ghetto" or "Ruby is a ghetto" you should really understand something about what that means, and who you might be affecting with your words. And even if you've decided that you want to throw the word around, use it fucking properly. A ghetto is not just something that "sucks". Ghettos are defined not just by being run-down, but by being isolated in some way. If you want to say something sucks, just say it sucks.
- latch 16y agoDefinitions of words evolve. Has "it sucks" always meant that something was bad? No, but that's what it means now because that's how people started using it.
- deleted 16y ago[deleted]
- raganwald 16y agoThat's an old and always interesting argument, and I honor you for brining it up. However, the fact that English usage evolves is no excuse for going along with every bit of its evolution without asking yourself if the new usage is an improvement or not. It's our responsibility as writers to sift through the entire language and pick and choose the words and idioms that communicate our ideas well. In this particular case, although plenty of people use "is a ghetto" to mean "sucks" rather than "is isolated," and although almost everyone uses "sucks" to mean "is poor" rather than "performs fellatio," I personally think that "is a ghetto" is a strong metaphor when used to imply a marginalized, isolated technology and is incredibly weak when used to imply something has fallen into disrepair. It really doesn't add anything insightful. Which brings me to my personal metric for deciding how well a metaphor fits. Does it add some insight? If "is a ghetto" is synonymous with "sucks," I gain nothing form using it other than passing myself off as a hipster. But when someone uses "is a ghetto" to describe something with an insular culture, I get an "aha!" moment as I think about the various implications, such as people trying to live their entire lives within the ghetto, or people learning to speak a crazy creole of their programming languages. I think using "is a ghetto" in the social sense conveys extra insight or meaning, so I personally prefer it. I will go further. Using it to merely suggest that something sucks is--well--gay.
- mxcl 16y agoHis counter argument seems to be that the original blog post didn't offer alternatives or patches and so it is invalid. Which of course is not a counter argument at all. IMO the Ruby stdlib is a mess. Denying it won't improve it.
- Rusky 16y agoHis argument is rather poor. The other post doesn't offer details or alternatives, but all his does is offer details that really don't support his argument ("it's /only/ 2.4 times slower, and you should use persistent connections anyway!"). What kind of defense is that?