12 ms·
Object-oriented programming: Some history, and challenges for the next 50 years [pdf]
- Rochus 6y ago> which started at the Norwegian Computing Center in the Spring of 1961 The date is wrong; only Simula 67 qualifies as an "object-oriented" language (the term was not used then though). The development of Simula 67 started in 1966. The author probably means the predecessor language, which did not have the properties associated with object orientation (moreover, it was a simulation language, whereas Simula 67 was designed as a general purpose programming language). > Smalltalk-72 ... was clearly inspired by Simula, and took from Simula the ideas of classes, objects, object references, and inheritance Smalltalk-72 had no inheritance. Kay was aware of it but didn't like the idea. Only Ingalls added it to his Smalltalk-76 implementation. Not the only inaccuracies as it seems.
- tabtab 6y agoPeople disagree widely on what OOP really is/means. I've read and been in many definition debates. Even defining what inheritance, polymorphism, and encapsulation is, is also a can of worms.
- Rochus 6y agoWell, some people disagree, as usual; not really an issue; if you need a theory and formal semantics, consult the standard work: https://www.amazon.com/Theory-Objects-Monographs-Computer-Science/dp/0387947752 https://www.amazon.com/Theory-Objects-Monographs-Computer-Sc....
- tabtab 6y agoThat's just one person's model. It may be an interesting model, but it's not necessarily "true" in the sense of acceptance. Type theory is also a model, not a definition. It's useful in the practical sense, but that doesn't necessarily mean it defines "types". Competing models may be developed.
- bird_monster 6y agoSuper proud to see work like this from Portland State! Without entering into the debate of Object Oriented Programming vs. Not OOP, I think legitimate research and examination is important for progress on both sides. Excited to do more than just skim this after work.
- deleted 6y ago[deleted]
- Rochus 6y agoThe paper is from 2012, and it is not actually about research results, but a historical outline, even with a few errors. But still interesting to read.
- lmilcin 6y agoSame story repeating over and over again. Initial hype. Then abuse and overuse. Disillusionment. Decline. At some point people will finally figure out what OOP is all about by looking up decades' old works and youtube videos (if youtube is still available) and hopefully will learn to integrate it. * A discussion with a dev recently when I started refactoring his PR with him and started pulling business logic from services into model. Dev: "NOOO!!! You can't do this!!!" Me: "But why?" "You can't put code in model. Model is for fields and getters and setters only and business logic belongs in business services" Me: "Why?" Dev: blank stare... (imagined, this was over zoom) Me: "So... why do you bother with having fields private if you plan to have public getters and setters for everything?" Dev: blank stare Me: "Isn't object oriented programming about having logic alongside the data rather than separate? Isn't it about modeling operations that act on the data to limit exposure to internal state?" Dev: blank stare Me: sigh...
- dennisgorelik 6y agoIt is better not to put business logic into data model - in order to: 1) Keep your business logic simpler. 2) Keep your data model simpler. If you put both business logic and data model in the same class, then: - When you investigate data references pointing to your class -- you will see references noise from your business logic. - When you investigate business logic references pointing to your class -- you will see references noise from your data model. 3) Combined "business logic + data model" class is much harder to refactor. So, technically, you can combine business logic and data model in the same class. But practically, such code combining will significantly complicate maintainability of your code.
- valbaca 6y agoJust to set some context, I'm of the "OOP Generation" where I learned to program when OOP was at its zenith. Every major language was Class-based OOP (C++, C#, Java, Python, Ruby) and it was just THE way to code for all things in the foreseeable future. That said, I've since looked into and learned other methods of programming: classic C, prototype-based JS, functional Clojure, and Go. From what I can gather, even from the SOLID principles and other Class-based OOP advice (prefer composition over inheritence) is that Interfaces (as abstraction and reuse), Aggregation (that objects can have other objects), and Delegation (which allows of ergonomic aggregation) are the real winners of OOP. In this way, Go gets it mostly right IMO, though at the risk of "initial hype" I'm still cautious on it. It feels so backward that OOP is taught with a focus on abstract & subclasses, with very little emphasis on interfaces, which is really how we achieve the goals of abstraction and reuse. What's funny is seeing languages like Java trying to "undo" the arguable "mistake" of abstract classes by adding more and more power into interfaces: default methods, etc. To your original conversation, there's a mix going on with "model." Are they talking about the Service's API Model, the internal model representation, or the database model? The outer layers (API & Database) of your code should be plain structs (POJOs in Java), but you're absolutely right that within the business code itself, you should have logic within the classes. Otherwise, you're not coding much different than C passing around struct pointers. Related terms: MVC, Data access object
- faichai 6y agoI think Alan Kay himself has suggested that what he really wanted when thinking of OOP was something more akin to the Actor model as espoused by Hewitt and realised by Erlang and to a lesser extent Scala on the JVM. This model gives full benefit of FP at the actor level whilst being realistic about distributed messaging semantics. I’ve always felt that it would be interesting to research processor cores that could better exploit the assumptions in this model, and this would be the future of both multi-core and distributed computing. Actor message queues would be in hardware, there would be opportunities to reduce context switching overhead between actor activations, memory models would be more fine grained, capability based security would be ingrained.
- Rochus 6y agoHave a look at the paper. It's actually one of its conclusions that Simula had active objects even in 1961 and also in the OO version 1967, but for some reason this aspect didn't make it into the concept generally envisioned by OO today.
- to11mtm 6y ago> I think Alan Kay himself has suggested that what he really wanted when thinking of OOP was something more akin to the Actor model as espoused by Hewitt and realised by Erlang and to a lesser extent Scala on the JVM. > This model gives full benefit of FP at the actor level whilst being realistic about distributed messaging semantics. It's interesting you bring that up; I normally am very much on the 'Use interfaces and Dependency injection instead of inheritance' camp. And yet, When I work with Actor Model frameworks (Mostly Akka/Akka.Net) I find places where using some simple inheritance is insanely powerful yet intuitive. You wind up getting something in-between OOP and AOP with the results.
- moocowtruck 6y agohave some examples?
- valenterry 6y agoI think so too. FP does not work over a distributed system, because it requires to view "the world" in one chunk. But that does not scale. Using actors is a great way to chunk the worlds into smaller parts, each of which can then be handled in fully FP manner.
- taffer 6y agoHere are some thoughts about OOP I had recently, maybe someone here had similar thoughts: It seems to me that the biggest cause of maintenance problems in object-oriented programming is that it tries to manage global mutable states by partitioning and encapsulating all state into objects. However, the only way to prevent two unrelated objects from manipulating the same part of the state is to create a strict dependency hierarchy or arborescence[0] between all objects in the system. This combination of data and code in a strict hierarchy means that all data access patterns are baked into this dependency tree, which makes later, unforeseen changes to the software extremely difficult without taking shortcuts in the dependency tree and thereby destroying the encapsulation, which would destroy the whole point of OOP in the first place. [0] https://en.wikipedia.org/wiki/Arborescence_(graph_theory) https://en.wikipedia.org/wiki/Arborescence_(graph_theory)
- dpc_pw 6y agoThat's a very interesting observation, that is very much aligned with my own views, but I'll need some time to absorb the details here. I'm myself on the quest to fully understand what is really wrong with OOP and then try to share it with more people. It's actually very hard because it's a complex topic, ridden with subtleties, and even the exact definition of "what is OOP-code" is elusive. I've just recently made a reddit post that you (and other's who find your post interesting) might also enjoy: https://www.reddit.com/r/rust/comments/ju5oqp/how_to_avoid_repetition_without_inheritance/gch4gbp/?context=6 https://www.reddit.com/r/rust/comments/ju5oqp/how_to_avoid_r... I wish there was some "OOP-deniers" community, where we could discuss things like that with an open mindset. Usually discussing OOP degenerates quickly and it's impossible to even establish some shared understanding.
- atty 6y agoI am a little confused about your point - are you saying that OOP is a strictly worse, or has some inherent irredeemable flaw that is not present in other programming styles? Because that’s a statement that would need a lot of supporting evidence, considering the success of OOP over the last 30 years or so. I think a more strongly defensible position is that OOP is not a magic bullet that works for all types of problems, and identifying when and where it is a natural fit is not always obvious.
- andrewl 6y agoThere's an article from 2000 called Why OO Sucks, by Joe Armstrong: http://www.cs.otago.ac.nz/staffpriv/ok/Joe-Hates-OO.htm http://www.cs.otago.ac.nz/staffpriv/ok/Joe-Hates-OO.htm It was originally discussed here at: https://news.ycombinator.com/item?id=19715191 https://news.ycombinator.com/item?id=19715191
- bedobi 6y agoNo one, not even the supposed originators or the terms or the ideas, knows or can agree on what OOP even is or means. So when codebases coded in the ubiquitous "OOP" style, (essentially procedural code full or state, mutation, temporal dependencies, side effects, exceptions and other things which make it impossible to reason about what's going on) are full of defects, the advocates can always claim it's because it's because it's not Real, True Object Oriented Programming.
- lincpa 6y agoPeople who insist that mathematics is not beautiful are wrong. The main forms of beauty are order, symmetry and clarity. -- Aristotle Object-oriented and functional programming completely do not meet these three beautiful conditions, only "The Pure Function Pipeline Data Flow with Warehouse/Workshop Model" perfectly meets the requirements. https://github.com/linpengcheng/PurefunctionPipelineDataflow https://github.com/linpengcheng/PurefunctionPipelineDataflow
- testtest1929 6y agoI keep going back and forth on OOP. I was really into about a year ago, but have now adopted mostly functional except for large projects.
- Tainnor 6y agoBy now, most of the classes I write are immutable and I use inheritance rarely (although I do use interfaces). The one feature that I still find very useful from OOP is the ability to have a "shared context" for a related set of methods/functions. This works especially well with dependency injection: I can have some properties passed to the class constructor (say: the base directory where some files lie, a logger implementation, etc.) and then write my file manipulation functions without having to pass those properties around from function to function. I wonder if there is something similar in some FP languages.
- willtim 6y agoThe reasoning behind "closures", is that one can capture some context such as the example you describe. If we think of an object as simply a record of functions, then we can close over some shared context during the construction of such records, if we have a language with records and closures.
- maattdd 6y agoYes, it's called a closure.
- deleted 6y ago[deleted]
- nesarkvechnep 6y agoLook up the Reader monad. Don't be intimidated by the M word, it's a simple pattern which make use of function arguments but masks the argument drilling.
- chriswarbo 6y agoOthers have mentioned closures; there are also a few other patterns that can do similar things. One is "ad-hoc polymorphism", which lets us associate values with types. This is essentially the same as implementing an interface in languages like Java, except we don't need to modify any existing definitions (e.g. we don't need to edit a class to say "extends Foo"). This is useful for picking between pre-defined sets of values, e.g. for your example of logger and base dir we can define an interface like 'Environment' with methods returning a base dir and a logger; then we can define a 'Production' type which implements this interface by providing the real logger and base dir, a 'Test' type which returns a temp dir and stdout logger, a 'Dev' type whose logger keeps verbose debug messages, etc. We can write our code in terms of a generic Environment, then in our 'main' function we specify that we're using 'Production'; in our test suite we specify that it's 'Test'; when debugging we can specify 'Dev'. Another approach is called 'Reader', and it's based around the following type and helper functions (in Haskell syntax): data Reader a b = R (a -> b) read :: Reader a a read = R (\x -> x) runReader :: Reader a b -> a -> b runReader (R f) x = f x Or in Scala: final class Reader[A, B](f: A => B) { def run(x: A): B = f(x) } final object Reader { def read[A]: Reader[A, A] = new Reader(x => x) } Note that this type literally just contains functions from some type A to another type B. The function 'read' is a wrapped-up identity function (returning its argument unchanged), the 'run' function just applies a wrapped-up function to an argument. This gets interesting if we do two things. First we can specialise the input type (a or A), e.g. in Haskell: type Application t = Reader (Path, Logger) Or in Scala: type Application[T] = Reader[(Path, Logger), T] The type 'Application[T]' represents functions from a Path+Logger pair to a T. Next we can define some functions for manipulating Reader values: -- Applies a function f to a Reader's result; AKA function composition map :: (a -> b) -> Reader t a -> Reader t b map f (R r) = R (\x -> f (r x)) -- Wrap up a value into a Reader, by accepting an argument and ignoring it wrap :: a -> Reader t a wrap x = R (\y -> x) -- Combine two Readers, so they're given the same argument and their return values are paired product :: Reader t a -> Reader t b -> Reader t (a, b) product (R f) (R g) = R (\x -> (f x, g x)) -- "Unwrap" nested Readers, by passing the argument into the result join :: Reader t (Reader t a) -> Reader t a join (R f) = R (\x -> runReader (f x) x) Together these functions let us write arbitrary functions "inside" this 'Application' type. For example: -- The 'fst' function gets the first element of a pair baseDir :: Application Path baseDir = map fst read -- The 'snd' function gets the second element of a pair logger :: Application Logger logger :: map snd read -- Use the logger to log the given string (via some 'logWith' function) log :: String -> Application () log msg = map (\l -> logWith l msg) logger -- Read the contents of a given file from the base dir openFile :: Filename -> Application String openFile f = map (\d -> readContents (d + "/" + f)) baseDir -- Log the contents of a given file from the base dir logContents :: Filename -> Application () logContents f = join (map log (openFile f)) Note how we can only access the base dir and logger from 'inside' the Application type; i.e. we can get an 'Application Logger', but we can never just get a 'Logger'. That's because the code doesn't actually define a logger or base dir anywhere; any value 'Application T' is really just a function '(Logger, Path) -> T'. To extract a result, we need to give it to 'runReader', which (in the case of Application) also needs to be given a '(Logger, Path)' pair. Using these functions directly can be a bit tedious. Some FP languages have special syntax which makes it nicer, e.g. in Haskell we can write things like: do x <- foo y <- bar x baz x y The Scala equivalent is: for { x <- foo y <- bar(x) z <- baz(x, y) } yield z These get rewritten to (the equivalent of): join (join ((map (\x -> map (baz x) (bar x)) foo)) This API is a combination of Functor (map), Applicative (wrap and product) and Monad (join). Hence people sometimes call this "the Reader monad"; but don't let that scare you!