Live data from Hacker News

Does OO really match the way we think (1997) [pdf]

leshatton.org

221–230 of 253 posts

Re: Does OO really match the way we think (1997) [pdf]

#221

No comment about OO in general, but I think Java/C# is a damn fine language design, avoiding many problems of newer paradigms. Here's an example: 1) Java: starts out with one opaque string type, because that's what OO methodology says. Changes the internals when needed. All clients continue to work forever. 2) Haskell: starts out with strings as exposed linked lists of characters, because functional methodology says…

The String and &str thing is a common criticism of Rust, but I feel it's a bit shallow when said without context. Maybe it's just me, but it makes sense when you consider Rust's ownership semantics (which are a new idea in language design, so you can't really look at how other languages solved issues arising from them). Basically, when you have the notion of ownership/lifetime in a language, you have to make a distin…

[deleted]

Re: Does OO really match the way we think (1997) [pdf]

#222

Earlier quoted context omitted.

How can you know that without comparing the same programs with a FP version? What if those codebases would become messy even with FP simply because the problem they are trying to solve is difficult? Also in what way does OOP prevent you from writing the code in a FP-style? It doesn't because the concepts FP and OOP are orthogonal.

It is much harder to do functional programming in an OOP language, as one is often fighting the syntax, semantics and various defaults. For example all variables are typically by default mutable, null in every type, libraries and frameworks with pervasive mutable state etc. Granted it has been getting easier as OOP languages have been slowly getting more and more functional features. But it really is easier to favour…

[deleted]

Re: Does OO really match the way we think (1997) [pdf]

#224

Earlier quoted context omitted.

That's not the idea I was trying to convey. I think any claim that any language (computer or ordinary or otherwise) captures the way people think independent of the use of that language is at least suspect [and for me probably false, but I could be wrong]. To me, it seems more likely that the flexibility of human cognition allows a person to think in terms of a programming language than any particular programming lan…

I'm afraid we disagree entirely. Before the existence of any computer language, humans talked, and thought: at various levels of rigor. Mathematical books were published for millennia. People thought, interpreted their world, argued with each other, and so forth. With the advent of computer languages, some of these have captured more of this independent thinking and abstraction, others capture less of it, while still…

Mathematical books were published for millennia.

Writing is thinking...etc.

Re: Does OO really match the way we think (1997) [pdf]

#225

Earlier quoted context omitted.

I'm afraid we disagree entirely. Before the existence of any computer language, humans talked, and thought: at various levels of rigor. Mathematical books were published for millennia. People thought, interpreted their world, argued with each other, and so forth. With the advent of computer languages, some of these have captured more of this independent thinking and abstraction, others capture less of it, while still…

Mathematical books were published for millennia. Writing is thinking...etc.

Can you be a bit more precise? I feel like we're talking past each other but perhaps have misunderstood each other.

Re: Does OO really match the way we think (1997) [pdf]

#226

Earlier quoted context omitted.

I think you'd benefit from taking a look at Entity Component Systems. Generally used for games, this programming pattern assigns behaviour to entities based on the components that they have. Moreover, neither entities nor components on their own actually own any behaviour. Behaviour occurs by systems that operate on entities with the associated component "signature". For example, an entity with a position and a veloc…

ECS as you describe it sounds like a good idea, but notice how it is a step away from OO which was supposed to keep code and data in a single encapuslated thing called an "object". Now our componenents are nearly just plain-old-data and entities are slightly more sophisticated data-structures for tying them together. All the code is now kept is "systems", which are starting to look very much like plain-old modules. N…

Yes, ECS is very much not OOP.

Re: Does OO really match the way we think (1997) [pdf]

#227
post #68

Earlier quoted context omitted.

So LISP and Caml aren't functional programming language nowadays ? Because both allow you to modify what's in a closure.

There is no language definition or implementation called "LISP". Both Scheme and OCaml lexically capture variables by value, as if they have been passed in as arguments. This is not how it works in e.g. Python.

> There is no language definition or implementation called "LISP".

Well, yes there actually is: the Lisp 1 language that MacCarthy and friends developed on the IBM 704, and its immediate follow-ups through Lisp 1.5. Since that, there isn't.

Re: Does OO really match the way we think (1997) [pdf]

#228
post #149

Earlier quoted context omitted.

Wait, isn't that exactly how lexical scoping in Scheme works? That's how you implement "objects" using lambdas. You make closures that mutate their closed-over bindings.

The question is if you mutate the variable, create a closure, mutate the variable, create a closure, and so on -- do those closures -- when executed -- each use the value that the variable had at the time the individual closure was created, or do they all use the latest value that the variable had? Scheme (and other academic languages) do the first, Python (and other scripting languages) do the second. But the proble…

No, multiple closures in Scheme will not capture different values of the same, mutated variable. For that to happen, the block has to be re-entered such that a fresh binding is created for those variables. That is not mutation.

Scheme's version of the do loop actually performs fresh binding, rather than mutation, so lambdas in the do loop capture the iterations separately.

If you mutate a variable with set!, all the closures over that variable see the change.

Re: Does OO really match the way we think (1997) [pdf]

#229
post #199

Earlier quoted context omitted.

Rust doesn't have two string types. They have one string literal type (str&) and a poorly named string buffer (String).

Actually, Rust has four string types: str/String, CStr/CString, OsStr/OsString, and Path/PathBuf.

Only str is in the language. The others are standard library types. Libraries may introduce more types too.

We almost made str a library type but the downsides outweighed the upsides.

Re: Does OO really match the way we think (1997) [pdf]

#230

Earlier quoted context omitted.

Is structure defined just by type? Like is all things which only have two integer properties considered the same? { Int age; Int weight; } Would be equal to: { Int x; Int y; } ?

Close, any objects with the same properties and types are compatible. The name of the properties and their types need to match. And this isn't always a good thing. If you have a function dealing with the property 'length' or 'value' for instance, you might as well have no type system because Typescript will allow you to pass in any object with those properties which is almost anything. While the code will still compi…

I see, sounds interesting. Are the names namespaced? And how would a method know its compatible? Do you type the properties a method needs instead of the object name?
Post reply on HN