4 ms·
Slow compared to what? Most benchmarks I've seen show that it easily beats most of the other popular dynamic languages if you care about that. In my own experie
by swannodette 17y ago
Slow compared to what? Most benchmarks I've seen show that it easily beats most of the other popular dynamic languages if you care about that. In my own experience with macro hackery you can often get very close to Java (2x-3x).
The lack of an object system is a downright feature since it forces you to take a functional approach. Most of the things you would want from an object system (polymorphism, multiple inheritance) are readily available via multimethods/hierarchies.
If you really want something CLOS-like, there's a library for that, http://code.google.com/p/explorersguild/wiki/XGModelAndGF http://code.google.com/p/explorersguild/wiki/XGModelAndGF.
- jrockway 17y agoforces you to take a functional approach I don't think Clojure is really a functional langauge, it's more of an imperitive/OO mix with immutable objects. Immutable objects aren't "functional programming", they're simply common sense. Functional programming is about composing parts of programs ("functions") with generic combinators. I have not seen anyone in Clojure doing this. Haskell is a different story; combinators are very reusable, and there is no way to combine functions (and other "categories") without them. (In Clojure, you combine program fragments by typing a closing paren and then opening a new one. Your program doesn't control its sequence of operations, a Magical Runtime does that for you. Inflexible.) The reusability in Haskell is quite interesting; for example, application in a monad is defined as "liftM2 ($)", the usual function application operator ("($)", itself a function of two arguments) lifted into a monadic context for functions of two arguments. Cool. The reusability is everywhere; you use the same Arrow combinators to traverse an XML document as you do to parse plain text. (See HXT and PArrows.) And of course, you compose Arrows with (.) (the function composition function), because (.) works on all Categories, not just functions. That is functional programming; Clojure is just immutable data and parens. (Both good ideas, mind you. But it's not doing anything that Pure Java can't.)
- weavejester 17y agoYour definition of "functional programming" is unusual. Wikipedia defines it as: "A programming paradigm that treats computation as the evaluation of mathematical functions and avoids state and mutable data" Wikipedia goes on to consider Erlang and Scheme functional programming languages, so it would seem your definition of what consists a functional programming language is more narrow than the norm. Most people would consider Clojure to be a functional programming language, just not a pure functional programming language. I'm also not sure why you describe a language with macros as being "Inflexible". I've used Clojure and Haskell extensively, and Clojure wins on flexibility. It's a dynamically-typed Lisp, after all.
- jrockway 17y agoI think I am agreeing with Wikipedia's definition. What function is evaluated that makes "foo" execute before "bar" in "(foo) (bar)"? Wikipedia goes on to consider Erlang and Scheme functional programming languages Yeah, people have diluted the term to near meaninglessness.
- weavejester 17y agoGenerally, in Clojure you'd write (do (foo) (bar)). The do form tells Clojure to evaluate its arguments in order. Some forms have an implicit do, e.g. (when x y z) is (if x (do x y)), but in general the order in which forms are evaluated depends on the form containing them.
- technomancy 17y ago> I have not seen anyone in Clojure doing this. Sounds like you need to get out more.
- jrockway 17y agoThanks for the link... I decided to take a look at your Clojure code on Github, and I am not seeing anything functional. Lots of OO/imperitive things going on; global variables (all instances of your HTTP client share the same cookie jar?), mutating objects, standard "imperative" control-flow (try/finally, with-<foo>, etc.), and so on. It looks basically like Emacs Lisp but with fewer parens in "let" clauses and with "defun" spelled "defn". That is not functional programming.
- cemerick 17y agoI'm so glad that someone is keeping it real when it comes to functional programming. sigh You don't mention where you saw all the "global variables", but I'll bet that what you saw were actually vars used in conjunction with binding. Are we really to the point where only monadic IO is acceptable to the high priests of functional programming? FP has always had two parallel tracks, the ML school and the lisp school. Maybe you prefer the former, but just because you really, really like Haskell doesn't mean you get to bar all other lisps from the FP club (as all of your problems with clojure -- i.e. it not being haskell -- certainly apply to all lisps I've worked with).
- jrockway 17y agoYou are attaching too much meaning to an expression. Who cares if you write functional programs? It doesn't matter. But calling a bunch of mutable state and non-composable program fragments that run from top to bottom is not really functional programming, and calling it that just confuses people. The idea of language is to be able to speak clearly about something; having a nebulous expression with no meaning is not helpful, right?
- cemerick 17y ago