|
|
|
|
|
by chmsky00
1711 days ago
|
|
> Sometimes you really do want to do all three of those things. But often you want to do some subset of them instead. So the language should give you ways to do parts of that without doing all of that, and then "extends" should be at most lightweight syntax sugar over that. Sounds like you’re describing something like C. Leverage individual header files to implement a specific behavior rather than features concretized in a spec we don’t always want. Making everything a class, monoid, etc. feels like the programmer equivalent of making 9 Star Wars movies where each is comprised of lightsaber fights from open to close. That’s a cool still image but … really 9 movies huh? |
|
Not at all. C has essentially no support for interfaces or polymorphism, yet alone delegation - even its data structure support is wonky (no real sum types). If C++ classes are "all you have is a hammer", C doesn't even give you the hammer, so you end up bashing screws in with a rock.
What I advocate is something like Rust, where you have both structs and traits as distinct concepts that serve separate purposes.