Live data from Hacker News

The Repeated Deaths of OOP (2015)

loup-vaillant.fr

61–70 of 220 posts

Re: The Repeated Deaths of OOP (2015)

#61
post #16
post #13

Classes were never definitional for OO, so prototypes, as originated in Self and adopted in JS, are not a violation of it. Function calls and messages are, fundamentally, isomorphic. Messages were never definitional. The notion of "purity", everything is an object, was never definitional. That was a Smalltalk conceit. Alan Kay named the idea, but stole it. So he doesn't get to impose his religion. What is definitiona…

The essence of OOP is not inheritance, that’s a nice to have. The essence of OOP is to encapsulate the data and the functions that operate on that data into an object and hide the internal state of the object from the rest of the program.

> The essence of OOP is not inheritance, that’s a nice to have. The essence of OOP is to encapsulate the data and the functions that operate on that data into an object and hide the internal state of the object from the rest of the program.

What is inheritance but a way to encapsulate data and methods in a way where you only need to override a subset of very specific methods and/or data to specialize an implementation?

Re: The Repeated Deaths of OOP (2015)

#62
post #16

Earlier quoted context omitted.

The essence of OOP is not inheritance, that’s a nice to have. The essence of OOP is to encapsulate the data and the functions that operate on that data into an object and hide the internal state of the object from the rest of the program.

Every OO proponent seems to have their own definition of OO. Another I’ve heard is “message passing”, although that one even has many different flavors since it isn’t well defined and some argue that methods constitute message passing and others envision something closer to an Actor model. This is all well and good as long as people are clear about what their definition is (although it is weird how many proponents ha…

For yet another definition, OO is about encapsulated polymorphic interfaces. Which raises a communication difficulty: encapsulated polymorphic interfaces are very useful in some of the cases (ADTs, modules), and a misfeature for the other cases (data modeling). I have yet to see a conversation, especially an internet conversation, where participants reach a rough consensus on the contextualized upsides / downsides of a given concept. It's either 100% heaven or 100% hell.

Re: The Repeated Deaths of OOP (2015)

#63
post #51

Earlier quoted context omitted.

Did you have a look at e.g. https://www.amazon.com/Theory-Objects-Monographs-Computer-Sc... ?

Yes, that's one of the most prominent in a long line of attempts at creating formal models of OOP. And in the preface, you'll find: > There is a well-established theory of functions, the λ-calculus, ... However, our theory of objects is self-contained; it is the first that does not require explicit reference to functions or procedures. So that answers your question in the negative and proves my point: no, not every l…

There are also different "schools of thought" for functional programming. That in itself is not a bad thing. The thread was about formal definitions; such are therefore available for those who need them.

Re: The Repeated Deaths of OOP (2015)

#64
post #56

ECS is often implemented in an OOP language. I know of no ECS languages. You have objects that you iterate over and apply changes to the struct or object's fields like x and y coordinates in a game tick for the "next state" Essentially you end up with lots of global functions and very large API space that has no ordering. There's inherent ordering to global function application to produce the correct result. So it pr…

What would an ECS language look like? Would it differ substantially from an OO language? ECS seems to me more like a pattern than a paradigm.

And that pattern is easy to implement in C or fortran 77 without being unidiomatic. So I don't vthing you need anything special.

Edit: to clarify, a system can just be a function, an entity just an ID and a component should be plain old data anyway, so a struct is perfect.

Re: The Repeated Deaths of OOP (2015)

#65
post #26
post #20

Earlier quoted context omitted.

> Alan Kay named the idea, but stole it. So he doesn't get to impose his religion. Bit rich to say he "stole it" when he himself said it's just the foundational principle around which systems form (living or not). Which already implies he doesn't claim to have invented it.

Somebody else invented it. Kristen Nygaard , in particular. He identified the three elements. It is common, when you steal an invention, to insist it is wholly natural , so not really any sort of invention at all. Saying it does not make it true. There was a time before; Kay came after.

He has been pretty clear in giving a lot of credit to the inventors of Simula, but that at the same his ideas derive more from Lisp. He even has a Quora answer where he explains that Lisp is the greatest language because he views it as a big shift in thinking.

There is also a well known clear answer of his to the question of what is OOP to him. We ended up with something different in real life, but it's pretty silly to accuse somebody of stealing an idea and giving it a name, when they wanted to do something else. If anything, the name OO was "stolen" to refer to something not originally intended. But even in this case the word steal is too harsh, and your general style leaves a really bad impression.

Re: The Repeated Deaths of OOP (2015)

#67
post #23

Earlier quoted context omitted.

The funny thing is it's exactly the same thing with functional languages, and no, there's no clear definition of FP. Some FP is lazy, some isn't. Some is immutable, some isn't. Some claim it's a style in any language, others that it's a type of language.

FP means that every expression (= part that can be evaluated) is referential transparent. Nowadays the word "functional" is used different from the original meaning (which some now call "pure functional") > Some FP is lazy, some isn't. The definition of FP implies that laziness is irrelevant. A language can enforce a pure functional style without being lazy or not. > Some is immutable, some isn't That's wrong. And it…

> FP means that every expression (= part that can be evaluated) is referential transparent.

Most real-world programming requires handling of side effects somewhere, so such programs have parts which are not referentially transparent.

It's why I distinguished between "core" and "meat" in my other response. Functional programming languages offer features that help making a larger part of the program referentially transparent (and, optionally, to ensure that property in the types).

> Nowadays the word "functional" is used different from the original meaning (which some now call "pure functional")

I don't think the meaning changed, just the tools offered and the scope of the support they offer to achieve referential transparency (pure functions). Early Lisp offered expression oriented programming which was a step towards it, but used dynamic scoping which isn't really helping. Later on both Lisps and ML offered lexical scoping. Then the purely functional trend came up via Miranda and (Clean and) Haskell, the latter encoding purity in the type system. In the last decade mainstream programming languages added functional programming features but are falling short in encoding purity in the types (just as Lisp never did), which means that it's (easily) possible for the abstractions offered (both functions but also libraries built on iterators) to not be referentially transparent, manual care (and/or culture) is required instead. The tooling doesn't help enough to guarantee referential transparency. But the core idea, the target of the efforts, is the same.

> Referential transparency implies immutability.

I didn't go into immutability in my other response because you can use mutation inside pure functions, as long as the effect doesn't leave the function. Building referentially transparent functions does not imply using immutable data structures or variable bindings inside.

Re: The Repeated Deaths of OOP (2015)

#68
post #16

Earlier quoted context omitted.

The essence of OOP is not inheritance, that’s a nice to have. The essence of OOP is to encapsulate the data and the functions that operate on that data into an object and hide the internal state of the object from the rest of the program.

If this is the essence of OOP, would you consider modules/existential-types in StandardML to be OOP? As a followup, what about OCaml (is that "more OOP"?)

ML modules are definitely OO

Re: The Repeated Deaths of OOP (2015)

#69

ECS is often implemented in an OOP language. I know of no ECS languages. You have objects that you iterate over and apply changes to the struct or object's fields like x and y coordinates in a game tick for the "next state" Essentially you end up with lots of global functions and very large API space that has no ordering. There's inherent ordering to global function application to produce the correct result. So it pr…

> I know of no ECS languages.

Any language with mixins and reflection can do ECS. e.g. Use mixins (components) and reflection to check which mixins an object (entity) has, then executing a code path (system) based upon that answer. Many dynamic languages, like Ruby, support this combination of features. I think the issue is many game developers work in C++ which lacks them.

There is a school of thought that design patterns are actually missing language features [1]. ECS seems like a text book case.

[1] http://wiki.c2.com/?AreDesignPatternsMissingLanguageFeatures

Re: The Repeated Deaths of OOP (2015)

#70
post #49

Earlier quoted context omitted.

Explain why closures are allowed to mutate state in this “simple, well understood” framework.

They are not allowed to. Why do you think they are?

From the Swift docs regarding closures (I would have used Haskell doc reference, but the Haskell docs are so esoteric and vague as to be nearly useless):

“A closure can capture constants and variables from the surrounding context in which it’s defined. The closure can then refer to and modify the values of those constants and variables from within its body, even if the original scope that defined the constants and variables no longer exists.”

https://docs.swift.org/swift-book/LanguageGuide/Closures.htm...

Post reply on HN