3 ms·
I reckon imperative and OO are almost identical; if you don't have objects, you use function pointers or discriminated unions instead and end up with something
by barrkel 9y ago
I reckon imperative and OO are almost identical; if you don't have objects, you use function pointers or discriminated unions instead and end up with something very similar. OO is a design pattern that often has language support. And I could make a similar argument that functional is mostly just a style of coding, where some more restrictive rules are followed - but it also depends on a few specific language features, e.g. garbage collection and possibly tail calls. You can get by without pattern matching and first class functions, but they make life much more pleasant.
Declarative vs imperative is more interesting: what vs how, building descriptions of problems rather than chains of calculations or lists of steps. I don't think functional style is strongly related to declarative, except in the very low level sense that a functional program doesn't necessarily have a sequential evaluation semantics. But that's increasingly true of seemingly imperative languages also.
- loup-vaillant 9y agoI've had teachers separate languages (or styles, or paradigm) in 3 categories: * Imperative languages describe how to perform the solution. * Functional languages describe the solution. * Logic languages describe the problem. I'm not sure I actually agree with this categorisation, though.