Live data from Hacker News

Object-Oriented Programming is Bad (2016) [video]

m.youtube.com

121–130 of 133 posts

Re: Object-Oriented Programming is Bad (2016) [video]

#121
There are a lot of mention on functional programming and OOP comparison in this thread. There's my 2 cents on the topic:

1. OOP is not necessarily bad.

2. The original OOP should be Smalltalk-like languages (messaging), but the term OOP we refer today basically related to Simula-like languages (inheritance, polymorphism).

3. OOP and FP are not exclusive. Language like Scala you can have a 'case class Stack[A]' with a method 'def push[A](a: A): Stack' returns new stack. First, it's a class and be able to have methods, inheritance etc. Second it's an ADT (Algebraic Data Type) and without any function with size effect. So both OOP and FP still makes perfect sense.

4. Main stream OOP languages design are mostly terrible. (Basically the 'Blub language' according to Paul Graham, I'll call those language Objective-Blubs because I want it to be a mainstream OO language without hurting someone).

5. There are a lot of arguments against Objective-Blub or OOP itself are related to state, side-effect etc. These are partially true. But I can't say stateless and pure is totally better than other approaches, I just feel better when I'm tackling complex domain so code does not affect each other in a crazy way. However if the whole program is pretty easy to make sense for you. For FP approach there is no obvious advantage over Objective-Blub. In this case choose the one with higher velocity.

6. The core problem that Objective-Blub to me is not simple state or side effects. It's the wrong/implicit modeling, if you are not modeling a problem, 9/10 you cannot address the problem. It's would bite you again and again. For small application these are fine, for large application these omitted modeling could be a real problem. But there are so few people mention this explicitly, please allow me to list some of them here:

a. Quick example - NullPointerException: Not modeling nullable concept makes you handle null everywhere. By explicit modeling Optional/Maybe/Some it could be resolved.

b. In Objective-Blub objects are reference type by default: Which means it's assume you only use the object in this specific machine and thread. Objective-Blub programmers always complain about object-relational impedance mismatch, and then they blame SQL. But the real problem is Objective-Blub itself. For Objective-Blub you have to throw away all the methods and references. Not only SQL, JSON or other serialization is also a big deal. If you use FP languages you just map tables to an ADT which is not a big deal. There's no assumption on identity on FP language at all, if you want an entity, just give it an id field. That also explained why FP languages is more concurrent friendly, because same data on different machines are still same data.

c. Sub-type polymorphism does not let programmer do the correct modeling easily: ADT have sum and product type. That's how you describe domain types, it's so straight-forwarded. Done. While languages like Objective-Blub have class and enums respectively, but no parametric enums. You have to write less obvious code to model simple concept like 'Payment = CreditCard(no, cvv) | Cash(amount) | FreeCoupon'

d. Sub-type polymorphism means strong assumption: This is so called inheritance, which encourage you do strong assumption like a Person extends a Head, which works but implicitly indicates a Person is a Head. This is ridiculous but if you convert Person and Head to some business type and services you can find too many code bases having this problem.

e. Sub-type polymorphism is under-powered than other polymorphisms: Less powerful is good when it's enough. But it's a huge problem when it's under-powered, which means you have to hack all the way round - like with old day Java, if you loop through an array, you have to cast type to every element. This is insane for a verbose statically typed language. Language should focus on simplify parametric polymorphism like OCaml or Haskell does to guide programmer choose a better way by default. Statically typed FP languages usually model effect with parametric/ad-hoc polymorphism, which could be a huge deal of separating dirty world concerns - like in Scala you can have your domain service accept F[_] as effect type parameter without knowing what this effect would be, it could be database IO or random generator or totally different abstract things.

f. Methods are everywhere: In Objective-Blub you have to write all methods in same class. So if a class having 100 methods is considered a code smell. And someone refactored them, move some of them to other classes and extract some of them to a new class. That's typically one reason why large code base are so hard to read, because typically in FP languages it's no big deal when you have hundreds of function operates on the same type, you just split them in several files if you want. For those extracted class and moved methods, they largely blurred how domain type and logic should be, because you have to create a new concepts, or move concepts to other places just because the old concept is too big.

g. Less expressive also blurred things: For the first time I was looking at a code base with design patterns everywhere I was so confused. Most patterns are the problem that language is so constraint that it cannot express simple idea, like TypeScript allow Partial in constructor it would eliminate most of the builders. Like singleton and static properties could be addressed with Scala object. When a code base is filled with BarFactoryBuilder etc, that means the language itself does not modeling these common patterns at all. This make people(both reader and writer) fighting with languages instead of just expressing domain business.

Re: Object-Oriented Programming is Bad (2016) [video]

#123

i love any kind of 'hate' article, and this guy is hilarious, so +1

yeah, that was pretty good. i guess OOP is not the end-all be all. prob would have been more useful if this was produced 10 years ago instead of 3 years ago. is anyone still using OOP?

Re: Object-Oriented Programming is Bad (2016) [video]

#124
post #118

Earlier quoted context omitted.

Those modern GUI based on HTML/CSS don't work at all without JavaScript. Prototype inheritance is also OOP.

I'm not a web developer, but I don't think the OOP features of JavaScript are really used much. I once saw some jQuery code and it looked pretty functional to me.

Other than those exposed via the Document Object Module.

Re: Object-Oriented Programming is Bad (2016) [video]

#125
post #117

Earlier quoted context omitted.

I only accept CS papers about it, do you have one at hand against Java favouring some random FP language instead? Something of this level of quality, not random assertions on online forums. http://kcsrk.info/multicore/gc/2017/07/06/multicore-ocaml-gc...

There are a few papers about Haskell's GC by Simon Marlow where this is discussed. The absence of mutable references is a big win for writing a concurrent collector.

I don't recall any of Marlow's papers having a table comparing performance of Haskell tracing GC implementations versus the tracing GC implementations available across several JVM implementations.

Re: Object-Oriented Programming is Bad (2016) [video]

#126

Earlier quoted context omitted.

interestingly Lisp/ocaml/clojure rank low in popularity, clojure shows it’s not because of libraries. That has to mean something other than libraries or unenlightend people. Idk maybe there is too much complexity in those languages and philosophy

Learning new languages is considered to be one of the highest costs a developer can pay. To be fair, there is a cost to picking up a new language, but nowhere near as high as is often believed, especially after one has learned two or three significantly different ones. I'd argue that those languages don't see as much use in great part because they are not the first languages people are exposed to, and therefore most…

Idk about that People are going out of their way to learn, go, typescript, swift, Kotlin, Scala (kind of)

Re: Object-Oriented Programming is Bad (2016) [video]

#127

Earlier quoted context omitted.

Ruby and Swift (and other languages I'm pretty sure) allow you to have named functions nested in functions

What the video specifically suggested was not any old nested function, it was nested functions that do not capture upvalues from their context.

PHP has those (e.g. function() use ($var) { })

Re: Object-Oriented Programming is Bad (2016) [video]

#128

I really liked the first half - he provides some insightful thoughts on both why OOP doesn't quite deliver on the promise, and why it continues to be popular anyway. I am also becoming increasingly enamored of procedural programming as a default approach. Functional is also good - it's one of my first loves - but I find that it can be similarly prone to encouraging premature abstraction. Like OOP, that problem isn't…

The small-versus-large-functions discussion is not about spaghetti code. It's about the question whether you should chop one large block of first-do-this-then-do-that code into smaller independent blocks and then call them in that very sequence from a superordinate function. In general I totally agree that sequential code should just be sequential, and it should not afford more functions. Because, the each time one l…

My concern there is not that a monolithic block of sequential code is inherently spaghetti code. It's that their natural tendency is to spaghettify over time.

Clean 300-line functions form an unstable equilibrium point; it requires constant effort by someone who cares about code hygiene to keep them clean. More so than factored code.

Re: Object-Oriented Programming is Bad (2016) [video]

#129
post #53

Earlier quoted context omitted.

> Stop that laziness and learn OOP properly, you'll find a good use for it! This is my biggest problem with OOP: proponents keep shifting the goalposts to avoid criticisms. If someone follows OOP practice, and it doesn't work out perfectly, then they must not have been doing it "properly". Hence "OOP" becomes a nebulous term, encompassing a whole bunch of approaches (encapsulation, inheritance, subtype polymorphism,…

> OOP is fraught with gotchas, misaligned incentives and lacks objectively checkable criteria Like, almost everything in programming these days (especially the frontend part)? I actually like how functional code looks like, especially ML dialects - OCaml, Haskell, F# What stopping me from trying to use these languages in prod is the lack of tooling (mostly refactoring), in the sense what Idea can offer. And when you…

> > OOP is fraught with gotchas, misaligned incentives and lacks objectively checkable criteria

> Like, almost everything in programming these days (especially the frontend part)?

Everything has problems; that doesn't mean everything is equally problematic. My point is that we should favour practices which are unambiguous and encourage objectively good things, and that OOP isn't either of those.

W.r.t. functional programming, I wasn't trying to argue in favour of it specifically here. I write a lot of procedural code, and keep looking for opportunities to learn/apply logic programming ;)

Re: Object-Oriented Programming is Bad (2016) [video]

#130

Earlier quoted context omitted.

At the heyday of the madness people were busy building object-over-network abominations like CORBA. There was even an unpleasant period of time in the 90's when people tried to make some of the Linux OS distro end-user apps run off of CORBA to bring about the interconnected "sea of objects" vision, slowing things down a lot. No wonder OO style is widely overused. It's overused in part, because it's easily sold. It's…

>Basically, software is organizational politics. I'd go further to say that software management is (often, mostly?) organizational politics. Software itself is about the flow of control and data, trouble often follows where dogma obscures this fundamental.

Software itself is about the flow of control and data, trouble often follows where dogma obscures this fundamental.

Trouble always follows where dogma conflicts with first principles and empirical data.

More correctly, a significant part of software development is organizational politics. The "flow of control and data" inevitably gets you embroiled in that.

Post reply on HN