2 ms·
To make my point, let's go back to the very beginning of programming: plugboards. To create a program you used cables on a plugboard. You had a general purpose
by 29athrowaway 7y ago
To make my point, let's go back to the very beginning of programming: plugboards.
To create a program you used cables on a plugboard. You had a general purpose computer that can run multiple programs, but in other to switch programs you had to spend significant time setting up cables. A small change in the program may also result in the same thing.
So then we moved to stored program computers, so that we don't have to do that anymore, and the global consensus is that it was a good idea, because it saves time.
Then, we had programs in bare machine language. But that poses various challenges:
1) Having to keep track the state of memory and registers is difficult. So programming languages were created to create an abstraction over them in the form of variables.
2) Programs were full of jumps that became hard to track and maintain at scale. Structured programming was created to create an abstraction over jumps in the form of control structures (sequence/selection/iteration/recursion). Procedural programming was created to group statements into reusable procedures and functions.
3) Then, having variables around became hard to maintain as well. So then structures were created as a way to group variables that are used together.
But then, people understood that some procedures and functions are coupled with structures, and that some structures are supersets of other structures. And that's how OOP was born.
In this mindset, I do not think OOP is a bad idea. I also do not think that the natural consequence of OOP is bad software. The problem is how the paradigm is used, not the paradigm itself.
The problem people are facing now is shared mutable state, which is not only a maintainability problem, but is also problematic in multithreaded software. Functional programming is a viable solution to address that problem.
NOTE: edited based on suggestion, since apparently I got some concepts mixed up.
- Jtsummers 7y agoJust a note, structured programming wasn't about structures in the data sense, but in the logic sense. Organizing program logic in a way that was more structured. Using a pseudocode: function unstructured_summation (int lower, int upper): int sum := 0; label loop: sum := sum + lower; lower := lower + 1; branch_neq lower, upper, loop; return sum; // this is assuming there's even a return concept This is short and simple, so that goto or branch is fine here for reasoning about. But it doesn't scale very well [0]. Structured programming discouraged these ("discourage" being a scale from: don't use unless it makes sense to don't use at all) in favor of other constructs that were more clear in their intent and easier to reason about (particularly in the days when you couldn't write a piece of code and test in in 10 seconds or less). [0] I once inherited a Fortran codebase that was essentially written in an unstructured style, many gotos and computed gotos. The guy who wrote it (yes, singular) over a 20 year period knew exactly what it did. But that didn't help me, because he was 70 and retired with a nice pension. The whole thing had to be rewritten using the original as a reference for testing because it was unmaintainable.
- deleted 7y ago[deleted]