3 ms·
Which you can do with modules in Python, so the particular utility of classes gets increasingly hard to tease out. One neat use of classes is model objects in
by civilized 4y ago
Which you can do with modules in Python, so the particular utility of classes gets increasingly hard to tease out.
One neat use of classes is model objects in scikit-learn. But R manages to do the same thing with a much more basic system called S3. In this system, you have "generic" functions which dispatch to different methods based on the data type of the first argument. This is used to endow the programming environment with predict and plot functions that behave differently depending on what kind of model you feed into them. This is essentially the same as how two different OOP classes can have two different methods with the same name. But S3 has none of the other trappings of object-oriented programming whatsoever: no encapsulation, no inheritance, no polymorphism.
I found it a fascinating revelation. It's hard to point to anything that R's object system makes unnecessarily difficult, any killer app that proves how pure OOP is better. I would guess that traditional OOP excels in GUI systems, but outside that context, people seem to increasingly find it wanting as a paradigm. We are seeing an evolution away from unipolar OOP ideology and towards a more multipolar exploration of different paradigms and their comparative advantages.