3 ms·
True. But I think that you can generally break them down into a few broad categories of functional style, and none of them can be followed comfortably in Java.
by bunderbunder 8y ago
True. But I think that you can generally break them down into a few broad categories of functional style, and none of them can be followed comfortably in Java.
- pjmlp 8y agoComfort is not a programming paradigm. Just because only might need a bit more boilerplate for currying or partial applications, doesn't prevent writing FP libraries in modern Java.
- deleted 8y ago[deleted]
- setr 8y agoBut since its all turing complete... this can be said of anything. There’s nothing stopping you from doing OOP in haskell, or functional in C, or procedural in prolog, if you’re willing to put in the effort. Disregarding “comfort”, or rather, how much the language lends itself to a style, makes the notion of programming paradigms meaningless, and we’re still left with something we all know exists, but have no way to express.
- Jtsummers 8y agoDifferent programming paradigms are not about what can be computed it is about what can be expressed in the syntax and semantics of the language. This is an important distinction. Brainfuck is capable, technically, of computing anything that Haskell can compute. However, it would be foolish to call it a functional (paradigm-sense) language. It lacks higher order functions and many other elements. You could construct a lambda calculus interpreter in brainfuck, but then that language would be functional, but not the underlying implementation language. By the same measure, Haskell implemented in C does not make C a functional (paradigm-sense) language.
- bunderbunder 8y agoThere's a whole lot of stuff you can do, short of writing interpreters, to construct library-level support for a paradigm in a language that lacks language-level support for that paradigm. For example, I would say that GTK+ is written in an object-oriented style. But, despite that, I would not say that OOP is a member of C's repertoire of language paradigms.
- Jtsummers 8y agoThat is true, some languages are sufficiently expressive to allow other paradigms to be used within them even though they aren't baked in. But it's not true that all languages can support all paradigms (either directly in the language as designed, or indirectly via library support). OO languages and functional languages support each other's paradigms (more easily) than a pure imperative language would support either. And both OO and FP languages support declarative styles (like relational or logic languages) better than C would. EDIT: It's also worth pointing out that C++ really achieved OO (initially) by using macros on top of C. So having a sufficiently expressive meta-language is also important to this. Via such a meta-language, you can achieve many more paradigms in a language than using the language alone. But many languages lack a meta-language or don't have a standard meta-language which people can rely on.
- jdmichal 8y ago> It's also worth pointing out that C++ really achieved OO (initially) by using macros on top of C. And this is extremely relevant to the point. If the primary complaint against function programming in Java is "comfort" and "boilerplate"... Macros address both those problems very well. If Java had macros, it would be very simple to isolate and minimize that boilerplate.
- pjmlp 8y agoJava emulates macros via annotations and compiler plugins.