Skip to content

Comment on Why Is Object-Oriented Programming Useful? With a Role-Playing Game Example

Comments

The problem is that object oriented programming is a premature optimization that has outlived it's usefulness.

Object oriented programming enshrines mutation.

Mutation is a good optimization when memory is expensive and fast relative to computation. Memory is now cheap and slow relative to computation. You can execute 100's to 1000's of operations in the time it takes to chase a pointer that is not cached.

If OOP encourages mutation can you explain to me why the String class in java is immutable?

It's a holdover from when Java was supposed to be a language for small machines.

However, if you're being snide, let me retort "So why does everybody in Java immediately recommend that you use the StringBuilder class instead of String?"

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.