News for hackers. Stuff that matters.
Re:How Class-based Programming Sucks (2011) by pjmlp on Friday December 13, 2013 @08:35AM (#6900373)
> OO is a horrible match for compilers, for example.

Actually it is a very good way to create ASTs if you need them to be extendable.

Which is exactly the use case where algebraic data types fail short.

Re:How Class-based Programming Sucks (2011) by emn13 on Friday December 13, 2013 @10:30AM (#6900965)
You want some way of specifying an interface - that doesn't necessarily imply classes. Also, class-based inheritance tends to be a poor fit for interfaces; note for example that C#/Java have their own special-purpose interface mechanics, and even C++ which allows multiple inheritance tends to use implicit template-based interface implementation instead.

Discriminated unions on the other hand are - the name says it - intended for cases where you want to discriminate between multiple possible values. They're by design not intended to hide differences behind an interface; they don't address the same problem at all.

All in all, I think that neither classes nor discriminated unions solve the interface problem (nor were they ever really designed to do so) - that's a different problem.

Re:How Class-based Programming Sucks (2011) by pjmlp on Saturday December 14, 2013 @03:02AM (#6905093)
You can have OO without classes.

I just meant OO in general, not classes specifically.

Re:How Class-based Programming Sucks (2011) by emn13 on Tuesday December 17, 2013 @06:04PM (#6924623)
You can have Objects without classes, certainly - even C had structs, and all functional languages I know of have records or something similar.

It's a question of terminology whether you call that object-oriented. It's certainly part of OO, in any case.