Hacker News new | ask | show | jobs
by mrweasel 1911 days ago
Much of the debate or criticism of OO have been targetted at the theoretical side of object orientation, and perhaps less towards the practical implementations, which allows for some flexibility in the programmers approach to objects.

I would like to see someone do a language that enforces all of the OO paradigms and best practices on the programmer, just to see what the resulting code would look like and behave.

For instance, I'd love to see a compiler than throws a error if you violate the single responsibility principle. Much of the OO spaghetti code I've seen have been because objects are basically just structs with methods and 10 different ways and object could change state.

For practical purposes I doubt I'd ever use such a strict language, but it would be interesting to see if the result is safer and clear code. I suspect it's more code though.

1 comments

The problem is that the "OO paradigms and best practices" are not formally defined, so the program that would enforce them on you cannot be written. OOP was unfortunately never defined formally enough to be amenable to this approach. (For example there are different interpretations of Liskov substitution principle.)

There are strongly-typed functional languages that are based on a consistent formal foundation, like Haskell, so you can look into these. But there are still some "escape hatches", because sometimes you just need them.