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

The integer is state, deciding if it's odd or even is behavior. Yes, it's a query method, but it's a good one. The only reason we need objects is to make programming convenient. I don't want my namespace polluted by a free floating function named even?/odd? when it can be restricted to the only type it cares about by being bound to it.

In some strictly ease of use sense, object.function() is better than function(object) because it better helps me organize and scope my code; I don't have to worry about function name clashes because every instance is essentially a module for those functions.

My tools also work better when they can see I'm asking what methods are on integer rather than just show me all functions visible to me right now. It's easier to say hey Integer, what can you do rather than hey world, what works with integers.

If you can only see functions, integers, and booleans and you can't realize those are all themselves perfectly good objects, then that's a failure of your imagination. Me, I like my functions, methods, booleans, integers, and all other types being objects because it's damn useful and damn convenient in making my day to day life easier.




Consider applying for YC's Spring batch! Applications are open till Feb 11.

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

Search: