5 ms·
In Lisp one has the freedom to code in Structured Programming, OOP, AOP, FP, meta programming, or create his own DSL. Does the same stand true for Clojure? I
by habibur 18y ago
In Lisp one has the freedom to code in Structured Programming, OOP, AOP, FP, meta programming, or create his own DSL.
Does the same stand true for Clojure?
I am thinking about switching. Only risk is that if it doesn't work, I can't port the code anywhere else, because it's so different from CL.
- weavejester 18y agoClojure is a Lisp, so you get all the usual things like first class functions and macros. Clojure leans toward FP philosophically, so all the built in data structures are immutable. Concurrency support is generally very good, and it has some useful syntax sugar for vectors and maps. I prefer Clojure over all the other Lisps I've tried, but YMMV.
- habibur 18y agoGood. Only thing missing in Clojure seems OOP. But I can live without that. Hope Clojure doesn't push the FP thing too far. Pure functional languages are evil. In broad sense, pure anything in evil. Look what Java turned into trying to be a pure (or too much of an) object oriented language. It’s multi paradigm that wins. Giving programmers freedom on how he wants to code any specific set of problem.
- brl 18y agoNot sure what your point about Java is since it doesn't seem to be either very evil or a very pure OO language.
- ramchip 18y agoEverything is in a class. Everything. Even poor little printf or the main function.
- weavejester 18y agoAlthough Java puts everything in an class, not everything in Java is an object. For instance, you can't write: Package p = java.lang; Class x = p.String; x y = "Hello"; Method z = y.substring; w = z(0, 5);
- mike_organon 18y agoThat's just the syntax failing to support such a nice way of accessing those objects. Packages, classes, and methods are objects. Of course, primitives are not objects, but autoboxing helps.
- weavejester 18y agoSure, they're represented as objects in the JVM, and you can access this via refection; but they're not treated as objects in Java's syntax. I'd argue that OOP is a property of a language's syntax, rather than how it is internally represented.
- ericlavigne 18y agoClojure supports OOP in the same style as Common Lisp. http://clojure.org/multimethods http://clojure.org/multimethods The integration with Java is almost seamless, so of course you can also use Java-style OOP if you're feeling masochistic :-P Clojure is definitely not pushing FP too hard. It was designed to be especially supportive of FP, but it is definitely a multi-paradigm language.
- 11ren 18y agoAnother Java-style construct: Clojure has a do form, which enables you to consecutively execute the following expressions in the list. It seems to me a way to sneak statements into the language. Or does lisp have something like that as well?
- weavejester 18y agoI believe 'do' is found in the majority of Lisp dialects.
- pivo 18y agoYes, but it looks like Clojure's do is not the same thing. Lisp's do is for iteration, while Clojure's do seems to be the same as progn in Lisp.
- weavejester 18y agoAh, my mistake.
- 11ren 18y agoI came across this http://en.wikibooks.org/wiki/Clojure_Programming/Tutorials_and_Tips#Clojure_for_Common_Lisp_Programmers http://en.wikibooks.org/wiki/Clojure_Programming/Tutorials_a... which seems to confirm progn ~ do I'm just surprised that (it seems) you can do statement-based code in lisp. I thought it all had to be expressions. This feels like cheating. BTW: I can see that progn/do syntactically produce expressions, but the value of all but the last one are thrown away - similar to python in that respect. This seems against the spirit of expressions.