Live data from Hacker News

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

news.ycombinator.com

171–180 of 234 posts

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

#171

Earlier quoted context omitted.

It's "pure fashion" until you try to massage your new subclass into behaving slightly differently when you're living with class hierarchies that are N levels deep. Clean compositions, ala Scala traits, can be done with OO. It's just not something I've seen in the wild, or something actively encouraged by any OO teachings I've witnessed. At the same time, composition is pretty much the only way FP is taught (at least…

Exactly this. I think this is the issue with OO that developers have come to realise, and which more functional languages get around. It's the "banana, gorilla, forest" problem that Joe Armstrong of Erlang once mentioned in a book I think, and it boils down to the lack of care when considering separation of concerns. Of course you can separate concerns properly in an OO context, but most developers don't. It's much e…

I think I understand what you meant. I like comparing it with the Directories vs Labels comparison (that presumably was won by Labels).

Back when Gmail just started, one of the things that it made different from other web-mail services (including hotmail) was letting you "label" emails instead of "moving them" to folders.

The problem with Directories was that, at some point, content might have two different classifications, so the question of putting it in two directories arises (if using that abstraction).

Same thing happens with Object hierarchies, even if you start meticulously defining the hierarchy of your objects given the current domain you are mapping, chances are in 2 years you will get a trait/data that does not really fall in one of your defined objects, and you will struggle to put it in one or the other, and your encapsulation will start breaking.

That happens "in practice" in real life, and is something that tons of books about OOD, OOA, and OOP define as incorrect architecture in theory, but there was always a disconnect.

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

#172

Objects are not fundamental to computing. This is why there are no deep solutions to any of the standard downfalls of OOP.

A small but very insightful tidbit. I am not completely sure if I agree with you: At some point in my life I programmed in assembler (8086 and Z80), so I know very well how computing looks in its more reductionist way. They are JMPs, calls and JNZ, JZ, PUSH and POPs.

However, the reason why we use say, structured programming, functional programming and OOP is because abstractions are always helpful for people. It makes it easier to think about the solution to a problem.

In my opinion, OODesign came at a moment where GUI development was really strong, and the 1:1 mapping from "window", "button", "menu", from real-life to the computing space was very useful. However, as we continue modeling more complex processes and entities in computers, that mapping becomes more cumbersome both in the encapsulation and even the naming (who has not wasted time coming up with a proper name for THAT class, or the infamous SimpleBeanFactoryAwareAspectInstanceFactory). This is where OO fails IMO.

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

#173
post #165

Earlier quoted context omitted.

No. OOP is just one aspect, but the most popular one.

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 watching the lecture series. I even have the book SICP. It is fun and elegant, refreshingly so, no doubt, but only till a point. I found once we venture into necessity for conditionals & data mutation, its unbearably cumbersome - I can deal with spaghetti C code but not this - may be I am conditioned by exclusive C++ usage. 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.

As for design pattern, I don't see it being exclusive to OO. Its just a bunch of ideas to build software. One would have it for assembler as well if it was used for mass production (I wonder how it was in early days when it was exclusively assembler). Its certainly poorly used and abused, agreed.

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

#174

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…

>65 layers of unrelated generic abstract stuff

Do you know what is monad?

Layers of abstraction are mostly based on polymorphism, Rust and Go support polymorphism. Though layers of abstraction are mandatory in modern coding practices in all languages if you don't write code as a single function with gotos and global variables.

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

#175
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…

> OO can be abused to produce bad designs, of course, but that's not an indictment of its syntax. It is. The strength of a language isn't just in what allows you to do, but also in what it limits you to do. OO in the style of C++/C#/Java is extremely flexible in terms of code organization. This means that most codebases eventually grow towards a mess of different styles and inconsistent design patterns. One guy's abs…

"The advantage of paradigms like procedural or functional programming as well as trait based "OO", is that there is generally an obvious way to structure something."

And surely that would be the way that you consider correct.

After seeing codebases with hundreds of global variables I know that OOP is not the only paradigm that can be abused.

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

#176
Because OO as the sole or primary paradigm supported deliberately in the design of a programming language is a space that has been explored extensively, being dominant in language design since the late 1980s or so. The OOP-centered-language space is rather thoroughly explored.

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

#177
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 design pattern, I don't see it being exclusive to OO. Its just a bunch of ideas to build software.

One could in fact think of monads as a design pattern for FP.

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

#178
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…

> OO can be abused to produce bad designs, of course, but that's not an indictment of its syntax. It is. The strength of a language isn't just in what allows you to do, but also in what it limits you to do. OO in the style of C++/C#/Java is extremely flexible in terms of code organization. This means that most codebases eventually grow towards a mess of different styles and inconsistent design patterns. One guy's abs…

Traits can be abused too, you can create a trait for every thing because abstraction is good and pass traits everywhere. Where to get the trait? From a factory of course. Then you roll an IoC container.

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

#179
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…

Pure fashion? I think that's a bit much. Rust was inspired heavily by ML/Haskell/C++, which are not particularly object oriented (C++ is object friendly, not object oriented).

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.)

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

#180
It seems that what people actually mean when they say "OOP" is inheritance.

I haven't used Julia, but it seems that Nim has inheritance[1]. Rust has traits that can have default methods, so it's closer to Java and C# in that regard.

OOP is quite useful, it's easy to write bad code in any language (and I've seen lots of it in golang for instance, which, due to the nature of the language, ended up making it even more difficult to follow than badly written Java for instance). So be careful to not fall for the hype that is going on.

[1] https://nim-lang.org/docs/tut2.html#object-oriented-programm...

Post reply on HN