Live data from Hacker News

Ask HN: Why do new(ish) programming languages eschew OOP features?

news.ycombinator.com

191–200 of 234 posts

Re: Ask HN: Why do new(ish) programming languages eschew OOP features?

#191
post #165

Earlier quoted context omitted.

I wonder how much of this mess is because people get introduced to these concepts(Generics etc) through wrong languages. Now, there is a very similar problem with concepts like recursion. Even Algorithm, DS and problem solving in general. You never get to learn this stuff well because you get drowned in syntax juggling, type headaches, absence of good features to do recursion, first class functions, mutability, closu…

I am self taught in C++. I learnt it when I realized my BE FORTRAN wasn't going to enable creating GUI simulation. I did have a few hiccups like any beginner but soon it was alright, so have no idea what it is like to be formally taught in class. As for Lisp and ML, being Indian, I had no access to these, even in CS section of the library, as you might understand. Many years ago I tried learning Scheme by/after watch…

>>As for Lisp and ML, being Indian, I had no access to these, even in CS section of the library, as you might understand.

I understand being in the same situation myself.

>>I tend to think those who stick to Scheme like languages and solve real world problems do it for bravado and cry when no one is looking lol.

That's mostly because of lack of libraries and the amount of reading one has to do to learn totally new way(ironically the original way) of doing things. Data structures are linked lists(lists), stacks(lists with utility functions), queues(lists with utility functions), trees(list of lists), heaps(list of lists), graph(interconnected lists). Basically dealing with data structures is List processing, hence the name Lisp. Now since building lists using Lisp with recursion gets easier because of amazing native facilities that come with Lisp. These things just get a whole lot easier. A lot of people will tell you they see that moment of enlightenment when they learn recursion in Lisp. It just feels like the concept was always there and you discovered it neatly while work through it.

SML and its descendants are the same, additionally you get the same enlightenment with Type systems.

When you read through Lisp, and then work with DS/Algo you begin to feel, the entirety of DS/Algo work was invented, grown and perfected in a totally different set of tools and thinking philosophies and then artificially shoe horned into C languages.

In the modern context Clojure and F# come across as nice replacements. Tons of libraries and good documentation/books are available for help.

OTOH a lot of great work is done in modern incarnations of Lisp and ML. Including mission critical large software stuff. This is because of strong typing in languages like F#, and code compression using macros in Lisp. Clojure is also designed to solve a lot of big problems that effect software development at large.

One of the things I realized while working with Python after using SML. When using Python I was running a kind of buggy type inference engine in my brain, then write unit tests cases to validate it. No human should do things that can automated with a computer. That includes programming itself.

Someday people will look at type systems, macros and recursion the same way as we look at garbage collection. If a computer can do it, and it can do it better than you. It is criminal to spend human effort doing it.

This is really the digging with shovels equivalent of writing code. Let the compiler work for you.

Re: Ask HN: Why do new(ish) programming languages eschew OOP features?

#193

Earlier quoted context omitted.

Composition is entirely capable of creating an ad-hoc informally specified bug-ridden slow implementation of inheritance.

That relates to my comment in what way?

Pretty obviously, ridiculous_fish is claiming that that's what you're doing.

Note: I'm not saying that ridiculous_fish is right. But it's pretty obvious that that's the claim.

Re: Ask HN: Why do new(ish) programming languages eschew OOP features?

#194

I was a big fan of OOP in theory when I learned it in the 90s and I still use it quite often, but in practice, any sizable OOP codebase that I've had to work with is _way_, _way_, more difficult than a non-OOP codebase that just directly solves the problem in a straightforward way. OOP encourages adding layers of abstraction, indirection, and generic stuff that sounds great if you're trying to create some kind of gen…

And it turns out that defining interfaces is the compelling "divide and conquer" abstraction needed to tame largish software projects. OOP can do that too but interfaces are sufficient. "As simple as possible but not simpler." was one guy's general theory of things.

Re: Ask HN: Why do new(ish) programming languages eschew OOP features?

#195

Because, as it has been said countless [1] times before, 1. OOP is technically unsound 2. OOP is philosophically unsound 3. OOP is methodologically wrong 4. OOP is a hoax [1] http://www.stlport.org/resources/StepanovUSA.html

"Countless times", but you give one reference that has one paragraph that contains those bullets, with only a one-or-two-sentence justification for each (except the last, which is given no justification at all, just as an opinion). That's not much to back up your claims, even if it is Stepanov.

And even on "methodologically wrong", Stepanov's rationale is wrong. After programming in various languages for decades, to use his analogy, we had "proofs". Then the "axioms" of OOP were laid down.

Note also that Stepanov says that generic programming is for him the only possible way to program. I suspect (possibly wrongly?) that you adopt his criticism of OOP, but not the rest of his rather dogmatic statements.

Re: Ask HN: Why do new(ish) programming languages eschew OOP features?

#196

Earlier quoted context omitted.

C++ was explicitly about adding support for OOP to C, and most modern languages that have OOP support derive from C++ in that support (often by way of Java), though there area few that remain that are directly inspired by Smalltalk without C++ as an intermediary, and a smaller number that don't come from the class-based OO family rooted in Smalltalk (JS notably, though modern JS has added class-based features.)

Sure, but adding OOP to an imperative language kind of implies it's one of many systems coexisting. Modern C++ is best described as imperative, functional, and object-oriented.

> but adding OOP to an imperative language kind of implies it's one of many systems coexisting.

OOP is inherently an imperative paradigm; you might mean “procedural” instead of “imperative” (certainly, that makes both uses of “imperative” in your post more sensible), but even then, OOP as a paradigm is very closely related to the procedural paradigm.

Re: Ask HN: Why do new(ish) programming languages eschew OOP features?

#197

Earlier quoted context omitted.

Class hierarchies are the best way to structure OOP programs. The main reason why people started moving away from OOP is precisely because those people didn't know how to structure their programs correctly. With functional programming, you can write correct code without any structure... It's extremely hard to follow the logic but it works. IMO full functional programming is a bandaid patch which allows incompetent de…

No on so many levels... Your first statement is horribly wrong!

A refutation is worth more than a bare denial.

Re: Ask HN: Why do new(ish) programming languages eschew OOP features?

#198

Earlier quoted context omitted.

Agree about immutability (I would love to have “readonly” to be applicable to classes), but I like the current static classes approach. It’s a single keyword, the language guarantee you won’t have any instance fields or methods in these classes. Global functions pollute namespaces, and auto-complete index. Static classes provide local namespaces for these functions, they also hide implementation details. I sometimes…

It's a good point about auto-complete I hadn't considered, maybe globals could have some obvious name thing going on, I hate this suggestion but for example an underscore prefix. Some examples of where global functions might make sense, the Main function of a console application doesn't need to be in a class, or the general Utils and Helpers approach soon becomes cumbersome, you end up having to name things that don'…

> you end up having to name things that don't really need names.

Strictly speaking namespaces don’t need names, either. But for medium to large projects they’re still useful, and enforced by the IDE.

> to imagine functions living in just a namespace, not a class.

You can place them into a namespace on the consumer side of the API, with `using static`. While not the same, might be good enough in practice: you normally have multiple `using` statements on top, for namespaces.

> I'd be interested in seeing the model reversed, e.g. immutable defaults with something like `public mutable class Foo`

I wouldn’t want immutable defaults, but I do want readonly classes and structures, with readonly being part of the type system.

BTW, the new value tuples with named fields is a step in the right direction https://blogs.msdn.microsoft.com/mazhou/2017/05/26/c-7-serie... Useful but limited, I would prefer real immutable classes & structures. Currently I have to create them manually, mark all fields public readonly, implement the constructor, that’s more typing than I’d like.

Re: Ask HN: Why do new(ish) programming languages eschew OOP features?

#199
post #181

Earlier quoted context omitted.

> simply namespaces 1980 module, Modula-2 1979? package, Ada http://www.drdobbs.com/open-source/history-and-goals-of-modu...

Not sure what this says, except that this industry remains terrible about learning from the past.

It might say people really wanted more than simply namespaces ;-)

Re: Ask HN: Why do new(ish) programming languages eschew OOP features?

#200
post #5

Unpopular answer: pure fashion. There's nothing wrong with object methods (that's 100% pure syntax vs. a function call) and an implicit "this" scope for symbols (which is just a limited form of dynamic scope[1]). They don't make code hard to understand. OO can be abused to produce bad designs, of course, but that's not an indictment of its syntax. Non-syntactic aspects are maybe a more involved discussion. For an exa…

> There's nothing wrong with object methods (that's 100% pure syntax vs. a function call)

Not really; in OOP a method call like `foo.bar(baz)` sends the `foo` object the message `bar` with argument `baz` (in Kay's current terminology); or, in more 'mainstream' terminology, it looks for a method in the `bar` slot of `foo` and calls it with `baz`.

As far as I'm aware, this is a pretty core concept in OOP: if our code isn't organised along these lines, then we're writing non-OOP code which just-so-happens to use classes/prototypes/methods (in the same way that we can e.g. write OOP code in C which just-so-happens to use procedures/switch/etc.).

(Side caveat: I appreciate that I'm making some assumptions here; one of my pet peeves with OOP is that it's rife with No True Scotsman fallacies about what is "proper" OOP, e.g. see 90% of the content on https://softwareengineering.stackexchange.com )

There is a fundamental asymmetry between the roles of `foo` (object, receiver of message, container of methods) and `baz` (argument, included in message, passed into method).

A function call like `bar(foo, baz)` doesn't have this asymmetry: the order of the arguments is just a convenience, it has no effect on how the `bar` symbol is resolved (in most languages it's via lexical scope, just like every other variable). Swapping them is also trivial, e.g.:

    var flip = function(f) { return function(x, y) { return f(y, x); }; };
    var rab  = flip(bar);

    bar(foo, baz) == rab(baz, foo)
In contrast, I can't think of an OOP alternative to this which isn't messy (e.g. adding a `rab` method to `baz` via monkey-patching).

Of course, the elephant in the room here is CLOS, but that's sufficiently different from most OOP as-practiced that it's better considered separately (e.g. I'd be more inclined to agree that CLOS methods are "100% pure syntax vs a function call")

> Non-syntactic aspects are maybe a more involved discussion. For an example, I personally think traditional OO lends itself very nicely to runtime polymorphism.

I also disagree with this, again due to the artificial asymmetries that OOP introduces (that objects "contain" methods). In particular, as far as I'm aware OOP simply cannot express return-type polymorphism. The asymmetry between arguments and return values is certainly more fundamental than the completely unneeded distinction between receiver and arguments, but it's still very useful to dispatch on the output rather than the input.

The classic example is `toString` being trivial in OOP (a method which takes some object as input and renders it to a string; the implementation dispatches on the given object); whilst `fromString` is hard (a method which takes a string and returns some object parsed from it; OOP can't dispatch the implementation by "looking inside" the object, since we don't have an object until we've finished parsing).

Post reply on HN