Hacker News new | past | comments | ask | show | jobs | submit login

"And one reason many people consider Java “better than Ruby” is because you cannot open base classes like String in Java?"

Do people really say this? The ability to monkeypatch classes is one of Ruby's many strengths. It would only add unnecessary complexity if there were any "special case" classes. I guess it's somewhat helped by the fact that people generally modify base classes responsibly.

Rspec is one example of how this is used to great effect:

  my_object_of_any_kind.should == "pretty awesome"

  MyModel.should_receive(:find).with(id).and_return(@mock_model_instance)



People do argue that by allowing monkey-patching, you guarantee that groups of developers will step on each others' toes. Refinements in 2.0 (http://ruby.about.com/od/advancedruby/a/Refinements-The-End-...) are an answer to that.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: