Live data from Hacker News

Try Clojure

tryclojure.org

61–70 of 404 posts

Re: Try Clojure

#61
post #8

Cool site, I've never tried Clojure before. My first reaction though is that (+ 1 1) is a highly unconventional and possibly confusing way of writing 1+1, and I'm not sure why that design choice came about.

[dead]

Re: Try Clojure

#62
post #43

> (+ 1 2 '(1 2)) > "3(1 2)" Yup, I'm out.

Fair. I don't mind dynamic typing so much, but I agree that getting clever with automatic type conversion is just plain wat. (reference to: https://www.destroyallsoftware.com/talks/wat )

I wouldnt call that getting clever, its just a string of what you did

  > (type (+ 1 2 '(1 2)))
    #object[String]

Re: Try Clojure

#63
post #43

> (+ 1 2 '(1 2)) > "3(1 2)" Yup, I'm out.

Clojurescript compiles to Javascript and so inherits some of it's idiosyncrasies.

This is one of the real problems of clojure: you need some knowledge of the host language. It's also one of it's major strengths, and the only reason a lisp managed to get so much (relative) commercial traction.

Re: Try Clojure

#64
post #49

Earlier quoted context omitted.

On the contrary - I think it's much easier! The real advantage of this notation is that it's much, much easier to stack calculations. Example: (/ (+ 34 68 12 9 20) 140) You can imagine how the first part of that could come about: (+ 34 68 12 9 20) And then the second part (pseudocode): (/ sum 140) In Clojure it's easy to mash them together, or for example to paste the first calculation in the second. (/ (+ 34 68 12 9…

A programming language should be first and foremost precise and readable, not concise. I can barely understand the clojure version but when I read the "traditional" one I don't even need to think. If you work with clojure a lot, does it become natural?

I would say yes, as someone who got used to it a few years ago.

Re: Try Clojure

#65
post #8

Cool site, I've never tried Clojure before. My first reaction though is that (+ 1 1) is a highly unconventional and possibly confusing way of writing 1+1, and I'm not sure why that design choice came about.

On the contrary - I think it's much easier! The real advantage of this notation is that it's much, much easier to stack calculations. Example: (/ (+ 34 68 12 9 20) 140) You can imagine how the first part of that could come about: (+ 34 68 12 9 20) And then the second part (pseudocode): (/ sum 140) In Clojure it's easy to mash them together, or for example to paste the first calculation in the second. (/ (+ 34 68 12 9…

I'd take the verbosity over having to count the operators from the start of the line to figure out which one are used at the end of the line "1.5 2"

Re: Try Clojure

#66
post #8

Cool site, I've never tried Clojure before. My first reaction though is that (+ 1 1) is a highly unconventional and possibly confusing way of writing 1+1, and I'm not sure why that design choice came about.

On the contrary - I think it's much easier! The real advantage of this notation is that it's much, much easier to stack calculations. Example: (/ (+ 34 68 12 9 20) 140) You can imagine how the first part of that could come about: (+ 34 68 12 9 20) And then the second part (pseudocode): (/ sum 140) In Clojure it's easy to mash them together, or for example to paste the first calculation in the second. (/ (+ 34 68 12 9…

Use the thread macro to make this easier to think about:

(-> (+ 34 68 12 9 20) (/ 140))

Re: Try Clojure

#67
I'm glad this is back. A version of this existed in the ancient past and helped encourage me to try Clojure which ended up being by far the most impactful decision in my professional life. It went away for a while for reasons I'm unclear on.

I use Clojure nearly daily at my job and at home. Sometimes it's standard Clojure, sometimes it's the excellent Babashka flavor which I use as a make-like task runner and Zsh-like script replacement. It's not the only language I use of course, and Go is a strong second place most of the time especially if I need something compiled to a single binary. But Clojure is where I generally feel most at home thanks to the irreplaceable REPL based development flow which is more like a dialogue with my program than your typical write compile run loop.

Combine that with it running on the JVM and you have a wonderful set of tools to get things done in a pleasant way.

I strongly encourage anyone with even a passing interest in Lisp and functional programming to give it a try. If you're using VSCode there is the excellent Calva plugin to help you out.

Re: Try Clojure

#68
post #43

> (+ 1 2 '(1 2)) > "3(1 2)" Yup, I'm out.

That's because this is actually ClojureScript (JS under the hood) running as a browser library. If you try that in Clojure, you'll get: > ClassCastException class clojure.lang.PersistentList cannot be cast to class java.lang.Number If you try it in a "proper" ClojureScript dev environment (shadow-cljs), you get nil as a result with this warning: > cljs.core/+, all arguments must be numbers, got [number cljs.core/ILis…

Thats actually good to know, I thought this was reflective of Clojure itself.

Re: Try Clojure

#69
post #49

Earlier quoted context omitted.

On the contrary - I think it's much easier! The real advantage of this notation is that it's much, much easier to stack calculations. Example: (/ (+ 34 68 12 9 20) 140) You can imagine how the first part of that could come about: (+ 34 68 12 9 20) And then the second part (pseudocode): (/ sum 140) In Clojure it's easy to mash them together, or for example to paste the first calculation in the second. (/ (+ 34 68 12 9…

A programming language should be first and foremost precise and readable, not concise. I can barely understand the clojure version but when I read the "traditional" one I don't even need to think. If you work with clojure a lot, does it become natural?

Yes, especially because the language is so consistent.

99% of the syntax is just (foo arg1 arg2).

Re: Try Clojure

#70
post #31
post #22

Earlier quoted context omitted.

In my experience, the subsets of the community around clojure were one of the biggest problem with it. It's gotten better over the years, but circa 2016 - 2018 it had a spike in popularity despite being very hostile to newcomers. There was an almost apologist attitude towards rough edges or failure modes folks new to the community would fall into. I managed to work with it for a time despite that, but it left me with…

YMMV. I always found it very welcoming and full of interesting people.

I may be wrong, but I think the parent poster was talking more about the language and ecosystem than the community. I, too, have found the community to be amazing. But the language itself used to be quite frustrating to learn. It's better now, but I think that by the time it got fixed many companies and teams had already been burned.

Clojure is particularly vulnerable to that because it really is an enterprise applications language. That makes it more vulnerable to learning curve problems than a language like Rust whose most direct competitors are other languages with comparably steep learning curves.

Post reply on HN