News for hackers. Stuff that matters.
Re:The Future's Pretty Cool, or Why I Love Ruby by gcv on Wednesday April 28, 2010 @12:01PM (#1301853)
Why I don't love Ruby:

Ruby 1.8.6:

    require 'set'
    [[5, 6].to_set].to_set == [[5, 6].to_set].to_set
    => false
Meaning, two identical objects are not equal. This is fixed in 1.8.7, but:

Ruby 1.8.7:

    require 'set'
    [2, 3].to_set.hash == [4, 5].to_set.hash
    => true
I understand hash functions can produce collisions, but they really shouldn't collide for something as trivial as [2, 3] and [4, 5].

Broken semantics for such simple things make me seriously distrust the language runtime completely. At the very least, this means that the much-touted Hash object in Ruby is untrustworthy and can easily lead to data loss or corruption.

Re:The Future's Pretty Cool, or Why I Love Ruby by erikpukinskis on Wednesday April 28, 2010 @02:59PM (#1302369)
> they really shouldn't collide for something as trivial as ...

Why not? Hashes produce collisions. If you don't want collisions don't use hashes. Or if you want a hash function that doesn't produce collisions for your specific data type, write one. It's not hard.

Relying on a generic hash function to never create a collision is just poor engineering on your part.

Re:The Future's Pretty Cool, or Why I Love Ruby by steveklabnik on Wednesday April 28, 2010 @12:07PM (#1301874)
As you say yourself, 1.8.6 is slightly broken. But do you expect old releases to always be bug-free? 1.8.6 isn't even the newest version of the 1.8 branch, let alone that 1.9 is the current branch of Ruby.

And as for your distrust of the runtime, did you know that 1.9 is an entirely new one?

Re:The Future's Pretty Cool, or Why I Love Ruby by gcv on Wednesday April 28, 2010 @12:40PM (#1301960)
As I noted, 1.8.7 produces a hash collision for [2, 3] and [4, 5]. 1.9.1-p376 has exactly the same behavior. I reiterate: the Hash object is unreliable, regardless of the runtime version. Based on such nasty behavior in such a simple case, I distrust Ruby's runtime and standard library for more complicated uses.
Re:The Future's Pretty Cool, or Why I Love Ruby by steveklabnik on Wednesday April 28, 2010 @12:44PM (#1301969)
Gotcha. I misread that part. My bad. I don't use sets, so I've never encountered this.