News for hackers. Stuff that matters.
Re:Goodbye, Object Oriented Programming by wvenable on Monday January 24, 2022 @01:26PM (#30061719)
Imperative 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.
Re:Goodbye, Object Oriented Programming by deltaonefour on Monday January 24, 2022 @09:50PM (#30067289)
>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.

Re:Goodbye, Object Oriented Programming by Zababa on Monday January 24, 2022 @01:42PM (#30061990)
It 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.
Re:Goodbye, Object Oriented Programming by wvenable on Monday January 24, 2022 @01:47PM (#30062053)
OOP is a strict superset of imperative. You don't even need an object-oriented language to do object-oriented programming -- just an imperative one.
Re:Goodbye, Object Oriented Programming by Zababa on Monday January 24, 2022 @01:53PM (#30062151)
OOP is absolutely not a superset of imperative, that would mean that imperative code is OOP code too, which is false.