3 ms·
Can I ask which are those families?
by loup-vaillant 9y ago
Can I ask which are those families?
- bostik 9y agoOf course. 1: Imperative - C, Fortran, Pascal, ... 2: Object-oriented - C++, Java, Python, Ruby, (maybe Delphi's Object-Pascal), ... 3: Functional - OCaml, Erlang, Haskell, F#, ... 4: Declarative - Makefiles, QML, SQL, .... To be perfectly honest, I don't know which bucket I should use for Prolog. It's supposedly logical, declarative and functional at the same time. I've never managed to understand it, despite trying. And for the record: perl in basic form is imperative. With the introduction of "bless" keyword it crosses over to object-oriented domain but following the syntax is not necessarily straightforward. [I've spent a non-insignificant number of days auditing OO-perl. It's not a pleasant experience.]
- andrewflnr 9y agoThose are more dimensions than buckets, and not very orthogonal ones at that. In particular there is strong overlap between declarative and functional language features (you could argue functional is just a special case), and less strong overlap between imperative and OO languages, and OO and functional. OCaml fits pretty comfortably in all four of those categories, when you want it to. If I wanted to jam languages into 4 categories, it would probably be the Algol, Lisp, and ML families, plus All Those Other Languages. :)
- useranme 9y agoI'm curious, what makes the ML families different than Algol?
- andrewflnr 9y agoThe ML family tend to come from a research background, have a more rigorous approach to typing, solid type inference, and very differently flavored syntax. MLs are functional (first-class functions, expression-orientation), whereas the Algol family in the shape of C, Java etc are mostly imperative. They tend to have nice pattern matching facilities. There's more, but that's a lot of it. A lot of these features have been transplanted into languages that are basically on the Algol tree, so it's often a bit fuzzy these days.
- barrkel 9y agoI 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.