r/Clojure • • Jan 19 '14

Clojure, the bad first impressions

http://kodare.net/blog/clojure-bad-first-impressions/
70 Upvotes

81 comments sorted by

View all comments

Show parent comments

4

u/yogthos Jan 19 '14

I definitely agree with some of the issues listed, such as poor error reporting and the fact that the official documentation is less than adequate.

However, I'm not sure I agree with some of the other complaints. For example, I like the way the built in test works. I see what function I ran, what was the expected result and what the produced result was. I'm not sure how much clearer it can be frankly.

The REPL output is often useful as it gives you more information about the cause of the error. In most cases the line number is sufficient, however sometimes you might want to see the complete stack trace.

Also, this is not an issue when you use a decent editor. For example, Cursive will catch the error and simply print the error message for you.

The editor is the proper place to address this kind of thing, I would want the language to give me as much information as possible and have the editor worry about displaying it in a nice way.

Clojure source code has a lot of commented out code with no explanation. This is unprofessional and makes me suspicious about the entire thing.

The commented code is definitely not a pretty sight, but I certainly can't agree that this alone should make you suspicious of anything. The fact that Clojure is used by lots of companies in production and many successful products have been built with it clearly demonstrates that there's nothing suspect about it.

Also, as a Java developer I don't really see anything obscure about the formatting of the source.

5

u/ds300 Jan 19 '14 edited Jan 19 '14

as a Java developer I don't really see anything obscure about the formatting of the source

It uses 8-space indentation and this crazy-weird brace alignment. e.g.

        public ITransientMap conj(Object o) {
                ensureEditable();
                if(o instanceof Map.Entry)
                        {
                        Map.Entry e = (Map.Entry) o;
                
                        return assoc(e.getKey(), e.getValue());
                        }
                else if(o instanceof IPersistentVector)
                        {
                        IPersistentVector v = (IPersistentVector) o;
                        if(v.count() != 2)
                                throw new IllegalArgumentException("Vector arg to map conj must be a pair");
                        return assoc(v.nth(0), v.nth(1));
                        }
                
                ITransientMap ret = this;
                for(ISeq es = RT.seq(o); es != null; es = es.next())
                        {
                        Map.Entry e = (Map.Entry) es.first();
                        ret = ret.assoc(e.getKey(), e.getValue());
                        }
                return ret;
        }

You can't tell me this is idiomatic Java style.

Having said that, I've read most of Clojure's source now and It's all pretty readable. Except the compiler, which is 8000-odd lines of long complex methods and practically zero comments. I gave up pretty quick with that one.

2

u/lechatsportif Jan 20 '14

That's interesting, obviously he was tuning the style for scanability. You almost dont need syntax highlighting when blocks are so visible.

2

u/kankyo Jan 20 '14

Except of course that all C, C++, C#, Javascript, Java, etc etc coders in the world are used to scanning code formatted in one way and NOT that way. So that's a bit of a fail in that case. And of course, just hiding the braces totally would give you the same readability for blocks because it's all about indenting anyway...