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

I have two remarks here: even if some procedural languages like C seem boiler plate-ish by requiring you to write everything instead of having a platform which offer a high abstractions that has two huge advantages: you are in absolute control and you understand everything from how the bits are layed out in memory and system calls to higher level business logic. So if you need to change something, add a feature, improve performance you know exactly where you have to intervene. Encapsulating state is very bad on the large scale because you have hidden state in lots of places and you can't argue about what a program does, how it does it and how to modify it. You have to write lots of tests to make sure things won't broke.

In some very large OOP codebases adding features or fixing bugs becomes a nightmare. Every small change you make will break hundreds of tests and while you fix the code to pass those, you will break other tests. Thing that can take days at most in sane codebases might take weeks.




I would argue that, if the scope of impact on a change is that large, then, by definition, you have not encapsulated your implementation.

(That, or you should not have made the change that way in the first place. Much like best practices for API changes involve shipping a new version in parallel and then slowly migrating everything over to it, a breaking change to the behavior of a class that really does have a legitimate reason to be used pervasively - say, a collection - shouldn't be done by just suddenly breaking all the code that uses it.)

Which speaks to exactly the distinction I'm trying to draw when I say, "a tendency to favor explicitly state-oriented idioms over properly encapsulating state." Note that simply sticking getters and setters on your state is not the same thing as encapsulating it.

It's kind of hard to explain the difference except by example, so I'm not really prepared to dive into it here. To be honest, I think the best way to get a feel for it is to read and understand the source code of an early Smalltalk system. Smalltalk-80 is small enough that one can get a decent feel for how everything works in an evening or two.


Then a C compiler optimizer decides that knows better and changes the table underneath, or maybe it doesn't but the Intel microcode unit decides to write the Assembly instructions in unexpected way.

Or that spot we were 100% certain was a bottleneck as it clearly wasn't micro-optimized C code, shows 0.1% hit on the V-Tune profiler.




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

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

Search: