5 ms·
> Object-oriented programming is the most successful programming paradigm in history. I don't think it is. The vast majority of code is imperative, with someti
by Zababa 5y ago
> Object-oriented programming is the most successful programming paradigm in history.
I don't think it is. The vast majority of code is imperative, with sometimes classes here and there, and these days with sometimes higher-order functions here and there, and with sometimes declarative programming (SQL and stuff like that). But the core is imperative code.
- wvenable 5y agoImperative code is the basis for almost everything -- whether it be OOP or functional or big ball of mud. It's not a significant distinction for this discussion.
- Zababa 5y agoIt is actually, and it is not the basis for almost everything. Functional code is usually declarative instead of being imperative. SQL is declarative, not imperative. The vast majority of the code written is imperative. It uses "if" instead of polymorphism for example, it doesn't rely on message passing or encapsulation or anything like that. You can't just ignore a paradigm and say that the second one is the most used.
- deltaonefour 5y ago>Imperative code is the basis for almost everything -- whether it be OOP or functional or big ball of mud Wrong. Imperative is NOT functional. You cannot have both functional and imperative. They are literally opposites. You CAN technically have both functional and OOP. However removing mutation from OOP removes the concept of setters and many associated "Design patterns" that are part of OOP.... so it's like removing the ignition from all car engines and still saying that the car is a car. Many people don't understand what functional programming really is. Allow me to elucidate. Whatever program you can write on a single expression. That is a functional statement. If you write multiple functional statements... the code becomes imperative. A functional program is an imperative program with ONE expression total. To write a functional program is to place your entire program ON ONE line. That's what functional is. Now you may have heard that all you need to do is make everything in an imperative immutable for the program to be "functional." This is true. Turns out an immutable imperative program is isomorphic to a functional program. See this: A = 2 + 2 C = A + 4 (immutable + imperative) is equivalent to: C = 2 + 2 + 4 (functional) However if you add mutation the isomorphism is lost. A = 2 + 2 C = A + 4 A = 3 You can no longer do the substitution above. Because of this isomorphism; to have any real linguistic meaning and differences between the words "functional" and "imperative" means that imperative programs MUST include reassignment. You can reassign a new value to an old variable in imperative programming and such a concept is literally impossible in a functional program because functional programs are just one line expressions. in FP all variable names are simply aliases or macro shortcut expansions. In imperative programs variables are mutating entities.