Hacker News new | ask | show | jobs
by projektfu 1135 days ago
This is the Smalltalkiness of Ruby. Why have a separate place to put a function that operates only on strings when you can put it in String?

Of course, in Smalltalk you might have #trim defined by two different packages and they might conflict. Then what? Maybe you have to manage that complexity. However, it's not much different from having conflicting functions in the global namespace in C, but actually easier to resolve in a given situation.

1 comments

Well, I suppose that's compelling if you're one of the many programmers trying to decide if you will implement your project in Ruby or C.
Yeah, more modern Smalltalks are able to put things in various namespaces so they don't conflict but still generally work as expected. In Smalltalk, adding methods doesn't weigh down a class like in other languages, because method lookup is on-the-fly like in Objective-C, not precalculated and placed in a table.