3 ms·
A language has 2 main purposes: 1. communication 2. representation of concepts 1 is pretty obvious, and for a programming language this means communication b
by koonsolo 8y ago
A language has 2 main purposes:
1. communication
2. representation of concepts
1 is pretty obvious, and for a programming language this means communication between a person to a computer
2 might not be as clear, but if you know that people cannot count in languages that have no numbers, it becomes obvious. There is a tribe that only has 0, 1 and many, and guess what, they can't tell the difference between 7 and 8.
Now back to programming languages and their communication between computer and programmer: the old programming languages were very close to the computer. As languages evolved, they started to be become 'human', where it is easier for us to read and write them.
OOP in that sense leans very close to concepts of normal humans. Objects, things objects can do, objects have separate responsibilities, etc. It's easy for a human to have such a model inside his head, because we already do this every day.
Now as a programmer, most of the things that I need to do is make a representation of the real world into a program. Since the real world is made up of things that do stuff, it's easy to model it in such a concept.
Most arguments against OOP always come from either a theoretical or academic background.
But in the real world, with real companies, real problems to solve and real programmers, OOP is used. Because it lends itself really well for representing the real world in a computer model.
EDIT: not saying that anyone that doesn't use OOP isn't a real programmer. But those people are more into the algorithmic or mathematical problem space, not a problem space where a real-world concept needs to be modeled. Most software is like the latter, and therefore most programs are OO. Is it the best solution for everything? Definitely not.
- hliyan 8y agoOOP in that sense leans very close to concepts of normal humans. Objects, things objects can do, objects have separate responsibilities, etc. This is not entirely accurate. Human languages are closer to functional languages: they have verbs that operate on nouns. Verbs are not attached to nouns, but rather, the operation of the verb is dependent on the noun.
- koonsolo 8y agoYet OOP reads more like English and functional programming more like math.
- mercer 8y agoThat's bullshit. Consider a recipe: Heat 2 tablespoons olive oil in a large skillet or paella pan over medium heat. Stir in garlic, red pepper flakes, and rice. Cook, stirring, to coat rice with oil, about 3 minutes. Stir in saffron threads, bay leaf, parsley, chicken stock, and lemon zest. I'm not saying there's no place for OOP in the English language, but I strongly disagree that OOP always, or even most of the time, reads as OOP.
- dwaltrip 8y agoI think the claim may have been that the brain is usually doing something more akin to "noun.verb(...)", rather than "verb(noun, ...)". It's a very interesting question. The concepts of agency and intention are very important in human cognition. If we hear a sound, we wonder if some intentional agent (predator, enemy, etc) that we need to be aware of caused the sound. Or if it was something inanimate like the wind rustling a tree. The OOP paradigm seems to map more closely to agents taking action. But perhaps my speculations aren't well grounded. I'm not sure.
- mercer 8y agoIt is a very interesting question. As an FP fan, I'd argue that we model the world primarily in terms of the actions we want to perform, with the objects secondary. But I'm obviously biases. Furthermore, perhaps how we actually model the world mentally is or should not bear much of a relation to how we do so in code. I haven't made my mind up about these things, even though I lean towards the FP approach in my day to day coding. But I love (constructive) discussions about the issue because somehow I feel they're about more than just 'making shit work'. Aside from the occasional flame-war I really like the discussions on HN about this stuff, and usually there are at least a few comments that give me new insight into both OOP and FP.