Procedural programming languages hide goto underneath for, if and while. Functional languages hide for, if and while underneath filter, map and reduce.
Object orientated languages hide case/switch underneath method calls.

Procedural programming languages hide goto underneath for, if and while. Functional languages hide for, if and while underneath filter, map and reduce.
Object orientated languages hide case/switch underneath method calls.

The introduction of procedural programming was the largest step forward in the history of programming design.much more so that what Object Orientation The basic idea is you get rid of gotos. You do that by finding the non pathological cases and turning them into specialised structures.
References,(and particularly pointers, raw, machine level references)are the gotos of data. They can lead to a host problems, including circularity, and “dangling” (premature dereference ).
The process of getting rid of explicit references is similar to the process forgetting rid of gotos: identify the use cases, and replace them with special purpose constructs. (Of course, raw pointers will gave to be used somewhere down in the machinery, for the same reason that implied gotos will implement for, if and while in procedural languages)
Pointers are used to implement complex databstruxtures such as trees an linked lists in languages lke C, so one tranche of references can be got rid of by using flexible data containers.
The other main use is passing data out of subroutines. The safe pattern is to pass in a references from outer scope, for the subroutine to modify. This avoids the problems attendant on a subroutine passing out references to their local variables, which might have beendestroyed, leaving the pointer dangling.
Both those techniques are used in the new language Parasail.
One might wonder why it took so long to get rid of the “second goto”.
The rise of object orientation ameliorates the use of references to pass data out of a subroutine. “This” and “self” are effectively implicit references, when used in modifiers. And the rise of dynamic languages ameliorate the use if references to build dynamic structures,…dynamic languages often have references, but their programmers rarely need them.

PHP copies the basic Implementation of OO from C++, a static language, and then , seemingly noticing that it is unnecessarily restrictive, allows escape means of magic methods.

A class is a module n the sense that it is a unit of code reuse, and indeed the only one in many languages.
A module is potentially much more.
A class defines a type.
A module may define a number of types, and interfaces.
The disadvantage: modules are even less composable.

Even in static and compiled languages, therefore the despatch of a method to an object needs to be decided at run time. This is true of C++, where the _vtable is used for runtime dispatch, and also if function oanguages, where variant types ……. a variable whose actual type is decided by its current value….are used for despatch. This raises the question of whether the best way to add OO to a static language is minimally , as C++ does, or add a whole dynamic layer as Objective C does….and if you are going down the latter route, should the layers have different or .similar syntax? Id be inclined to go for a minimal difference. How to glue a dynamic layer to a static layer? If static code is embedded in dynamic code, some kind of dynamic despatch will be needed based on runtime parameter values. ( I’m assuming the dynamic layer will have only duck typing) Static types passed into an embedded dynamic call will have to have their values boxed. Returns from dynamic calls , including data fetched from dynamic storage, is tricked. It can’t .be reliably unboxed into a naturally typed value,….either a runtime error will have to be thrown, or iy will have to into a variant.

1 Functions aren’t allowed to have side effects.
2 Functions are first class citizens that can be passed to other functions.
3. All data is immutable.
The third and strongest stipulation means that FP sidestep the encapsulation issue in OO, because if all data is immutable, none if it needs to be protected from incorrect update.