4 ms·
> OO is wonderful; try writing some programs in a language that forces you to do proper OO (e.g. Smalltalk). Have you tried implementing a numeric tower with p
by psykotic 12y ago
> OO is wonderful; try writing some programs in a language that forces you to do proper OO (e.g. Smalltalk).
Have you tried implementing a numeric tower with proper OO in Smalltalk? Would you describe the experience as wonderful and the program as beautiful? Rinse and repeat for any other problem that requires simultaneous pattern matching on several values.
I do think Smalltalk's style of single-receiver message passing is a sweet spot for structuring many kinds of programs.
- dragonwriter 12y ago> Have you tried implementing a numeric tower with proper OO in Smalltalk? The number of languages that I've seen with a proper numeric tower that aren't Scheme (or direct descendants of Scheme like Racket) are zero, so "OO makes it hard to do something almost no one ever does"...? > Rinse and repeat for any other problem that requires simultaneous pattern matching on several values. No problem requires pattern matching, much less on several values, any more than a problem requires OOP. Pattern matching and OOP are idioms that can be used to solve problems, but they are never the exclusive idiom that can be used to solve a problem (though either might be the only one that a particular language provides.)
- psykotic 12y ago> The number of languages that I've seen with a proper numeric tower that aren't Scheme (or direct descendants of Scheme like Racket) are zero, so "OO makes it hard to do something almost no one ever does"...? It doesn't have to be an elaborate Scheme or Common Lisp numeric tower. I mean any kind of lattice ("X and Y gives Z") that would normally be implemented with case analysis. Especially if that lattice has symmetries (e.g. commutativity). > No problem requires pattern matching, much less on several values Of course, but I think you know what I mean. Take any of the standard problems that are not amenable to natural forms of cascaded single dispatch. Pattern matching has its own limitations, but sometimes it's the right tool for the job.
- seanmcdirmid 12y agoPattern matching is overused in Scala, dispatch also works well via trait flexible compositions, which also provide a Wadler compliant solution to the extension/expression problem. But I guess it is a question of taste: Martin's 1000+ line mega match, or my 100 trait solution.