I can't remember the quote or source, but there's a pseudo programmer-interview question which goes something like this:
"What's your favourite programming language?"
"OK, what are 5 things that are wrong with it that other languages do better?"
This is something I've thought about from time to time, and so I figure I'll give it a shot. Obviously ruby is my favourite programming language at the moment, mostly(at the moment) due to the
map and
inject functions :-)
1. Green Threads are Useless!
The ruby interpreter is co-operative - it can't context switch a thread unless that thread happens to call one of a number of ruby methods. This means that as soon as you hit a long-running C library function, your entire ruby process hangs.
I encountered this situation, and tried then to ship it out to another process using DRb. This was even more useless, as when you do that, the parent process blocks and waits for the DRb worker process to return from it's remote function... which doesn't happen as the worker is blocking on your C library function :-(
I ended up having to create a database table, insert 'jobs' in it, and have a seperate worker which polled the database once a second. STUPID.
2. You can't yield from within a define_method, or write a proc which accepts a block
It appears to be to do with the scoping of the block, but in ruby 1.8.X, this code doesn't work:
class Foo
define_method :bar do |f|
yield f
end
end
# This line raises "LocalJumpError: no block given", even though there obviously is a block
Foo.new.bar(6){ |x| puts x }
The other way to skin this cat is as follows, which also doesn't work :-(
class Foo
define_method :bar do |f, &block|
block.call(f)
end
end
# The "define_method :bar do |f, &block|" gives you
# parse error, unexpected tAMPER, expecting '|'
# :-(
This means there is a certain class of cool dynamic method generating stuff you just can't do, due to stupid syntax issues. Boo :-(
3. The standard library is missing a few things
I vote for immediate inclusion of Rails' ActiveSupport sub-project into the rails standard library. I'm sure I won't be alone in thinking this.
4. Some of the standard library ruby classes really suck.
Time, I'm looking at you.
Strike 1: Not being able to modify the timezone. Seriously, people need to deal with more than just 'local' and 'utc' timezones. Yes I know there are libraries, but they shouldn't need to exist. Timezones are not a new high-tech feature!
Strike 2: The methods
utc and
getutc should be
utc! and
utc, in keeping with the rest of the language. This alone has caused several nasty and hard-to-spot bugs
Strike 3: What the heck is up with the
Time class vs the
DateTime vs the
Date class? This stuff should all be rolled into one and simplified.
The
Tempfile class is also notably annoying. Why doesn't it just subclass
IO like any sane person would expect?
5. The RDoc table of contents annoys me
This is probably more "Firefox should have a 'search in current frame'" feature, but under
http://ruby-doc.org/core/, have you ever had the page for say Array open, and wanted to jump to say it's
hash method? I usually do this using firefox's find-as-you-type, but seriously, try doing just this in the rdoc generated pages with the 3 frames containing
everymethodever open. Cry :-(
No comments:
Post a Comment