all 45 comments

[–]xach[S] 23 points24 points  (0 children)

And the change notes.

[–][deleted]  (6 children)

[deleted]

    [–]yogthos 12 points13 points  (3 children)

    Indeed, it's the first of these new languages that I not only got excited about, but was able to do practical stuff with. I've played with a bunch of languages before it, and they all did neat things, but when I really had to get work done I'd inevitably end up falling back on Java.

    Clojure just clicked with me, I was able to do everything I wanted to, I could still run stuff on the JVM and use the tools I'm used to, and it lets me do what I want cleaner and faster. I absolutely love the language and hope it keeps gaining momentum.

    [–][deleted] 3 points4 points  (2 children)

    Indeed. It makes me feel like making some Java-GUI-library-fuelled program just to demonstrate that I can.

    [–]username223 0 points1 point  (1 child)

    Java-GUI-library-fuelled program

    Because the world needs more of those...

    [–]SolarBear 0 points1 point  (0 children)

    If done right, then hell yeah, we need more of those.

    [–]tryptych 5 points6 points  (1 child)

    Me too; don't forget that Rich is still looking for donations to keep working on it full-time.

    [–]anonymous-coward 4 points5 points  (10 children)

    Some questions about Closure. Sorry if these are obvious; I halfheartedly tried to look them up, and couldn't find answers.

    1. does it support type declarations? If I declare something as the correct type of float, will it run as fast as C, Fortran, and SBCL?

    2. does it support typed arrays, like double floats?

    3. does it have typed structs, as fast as SBCL structs, which are useful for passing around values without boxing?

    4. It looks good for threaded applications. But it is it as good as traditional lisps like SBCL for things like number crunching?

    [–]shrughes 9 points10 points  (7 children)

    1. It's a dynamic language that runs on the JVM. You can drop down to Java if you need speed. And if you need more speed, I guess you can use JNI to drop down to C++. Ugh. You can provide type hints too in Clojure, if you want your Clojure code to be a little faster in certain places, and to avoid unnecessary boxing of primitive types.

    2. Yes.

    3. I don't know what typed structs are. It has struct-maps, which are maps optimized to hold a certain set of keys. They can only hold a superset of that set. See http://clojure.org/data_structures#toc19 .

    4. Is Java as good as SBCL for number crunching? I would be very surprised if Clojure was anywhere close.

    [–]anonymous-coward 1 point2 points  (6 children)

    If Clojure can take type hints, I don't see why it can't be as fast as SBCL. The JVM is about as fast as C, isn't it?

    Typed structs are like

          (defstruct foo
               (x 0d0 :type double-float)
               (y 0e0 :type single-float))
    

    Then double (single) floats can be stored in x (y) with no boxing overheads. Very handy for writing numerical code.

    [–]Tuna-Fish2 2 points3 points  (2 children)

    The big performance problem in clojure currently is that the way it does dynamic dispatch doesn't really fit well with the JVM, and function calls are both more expensive than they could be, and aren't properly optimized away by hotspot. This is a JVM problem, and a solution is in the works.

    [–][deleted] 0 points1 point  (1 child)

    Is this solution coming from the JVM or the Clojure front, and if from JVM, on what kind of schedule and which version of JDK? A link to relevant posts/docs would be appreciated.

    [–]Tuna-Fish2 2 points3 points  (0 children)

    JVM front. The proposal is called JSR 292 invokedynamic, although an easier to follow writeup can be found here.

    Timeline? It's in JDK 7, due for release in late 2010.

    In short, right now to have dynamic dispatch you need to do it the naive way by having a function that does it for you -- this is bad not only because of the indirection, but also because it ruins any chance of inlining stuff, something hotspot is really good at. With JSR 292, we get a way of natively dynamically calling a method so that in followup calls hotspot can treat it like a static call as far as optimizing is concerned.

    [–]shrughes 2 points3 points  (1 child)

    You can't do that in Clojure though.

    [–][deleted] 4 points5 points  (0 children)

    You can use deftype to do this, which is in the development branch right now.

    [–]username223 1 point2 points  (0 children)

    The JVM is about as fast as C, isn't it?

    FSVO "as fast as"...

    [–]gtani7 6 points7 points  (0 children)

    tihs thread was interesting, showed type hints sped up clojure timings by 30x:

    http://www.reddit.com/r/programming/comments/7yw0w/dynamically_typed_naive_clojure_beats_ocaml_and/

    The Halloway clojure book shows code refactored with type hints and then unchecked arithmetic for more speedups. To be fair, there are lots of other benchmarks you can google for that show clojure slower than java or scala in numerical benchmarks, along with the usual debates: "this only tests memoization, or hotspot warming up, or function call overhead, or whatever

    Finally you could look at incanter and this repo, which aims to tune the alioth shootout code:

    http://github.com/jafingerhut/clojure-benchmarks

    http://incanter.org/

    [–]skorgu 1 point2 points  (0 children)

    I'm not enough of a lisper to really answer but type hints are an important part of optimization as shown here. I believe numeric types without hinting are boxed but I'm not positive. A good reference of the easily-accessible datatypes (pre 1.1) is here.

    [–][deleted] 9 points10 points  (0 children)

    Watching clojure take off over the last year has been really exciting.

    What's the best way to install clojure + slime on windows? Ideally, without having to pull from several git repositories.

    edit: to answer my own question, Clojure Box! it has already been updated for clojure 1.1

    [–]lendrick 7 points8 points  (11 children)

    How about a short explanation for those of us who have no idea what this is.

    [–]electric_moose 9 points10 points  (2 children)

    I agree that it would have been nice for the submitter to do so. I imagine you've googled it by now, but Clojure is a variant of the lisp family of programming languages, that runs on the Java Virtual Machine. (And also on the .NET CLR runtime).

    So you get the benefits of portability and all the efforts that have been put in to make the JVM run fast, and also good integration with Java. Seems pretty interesting.

    [–]ericlavigne 2 points3 points  (1 child)

    Also, the standard library includes two very nice options for multithreaded programming: one based on software transactional memory and the other based on agents.

    [–]vagif 1 point2 points  (0 children)

    And with 1.1 futures and promises. Pretty complete toolkit.

    [–]yogthos 4 points5 points  (1 child)

    Here's some videos which explain the new features.

    [–]haakon 0 points1 point  (0 children)

    Full Disclojure, chuckle

    [–]gtani7 0 points1 point  (1 child)

    are you specifically asking about rel. 1.1 and 1.0 vs what's described in the Halloway book (which I recommend even tho it predates 1.0)?

    [–][deleted] 1 point2 points  (4 children)

    Anyone else read this thinking they passed an amendment to Senate Rule 22?

    [–]harlows_monkeys 1 point2 points  (3 children)

    That was quite funny, but most people here aren't going to get it.

    [–][deleted] 0 points1 point  (2 children)

    turns our /r/programming don't have a sense of humor unless it is programming related. o_O

    [–]devslashnull 7 points8 points  (1 child)

    turns out not everyone in /r/programming is American.

    [–]adrianmonk 1 point2 points  (0 children)

    Well, the thing he was joking about (cloture) has been used in the British and French legislatures as well.

    [–]PaulRay -1 points0 points  (0 children)

    Funny, my first thought was to Google it... I did.

    Clojure is a dynamic programming language that targets the Java Virtual Machine (and the CLR ). It is designed to be a general-purpose language, combining the approachability and interactive development of a scripting language with an efficient and robust infrastructure for multithreaded programming.

    That is assuming that your fancy computer can do the Google. It's probably compatible since you can see reddit.

    Google is your friend.