Live data from Hacker News

Try Clojure – An interactive tutorial in the browser

tryclojure.org

1–10 of 96 posts

Re: Try Clojure – An interactive tutorial in the browser

#3
post #2

Do I need to have a somewhat decent knowledge of Java to plunge into Clojure right away?

Mostly for understanding any stack traces you might see while running the code, I'd say. Other than that, you can use the bulk of the core language without needing a deep level of Java knowledge. Those bits of Java you may touch can be used as 'incantations' until you learn more.

Re: Try Clojure – An interactive tutorial in the browser

#4
post #2

Do I need to have a somewhat decent knowledge of Java to plunge into Clojure right away?

Java the language? Very likely not. As proof - a majority of Clojure runs in JavaScript without any code changes (via ClojureScript). That said exceptions tend to look like Java classes, so you’ll definitely see Java bits.

Java the JVM? You _probably_ don’t need to know it to get started, but you’ll have to get familiar with JVM deployment, dependency management, packaging, JVM memory settings, etc if you want to run something outside your dev machine. Getting to 90% here is pretty easy, but the last 10% (to me at least) tends to feel a lot more difficult that other languages.

As a small pro-tip: use jstack. I wish every language came with a jstack. It just dumps the stack traces of all threads of a program by pid.

Re: Try Clojure – An interactive tutorial in the browser

#6
post #2

Do I need to have a somewhat decent knowledge of Java to plunge into Clojure right away?

Mostly only for interop, which unfortunately includes the language itself. Normal usage you shouldn’t have to care. But if you get internal stack traces you’re gonna be learning about the various Map implementations etc, all of which are defined in Java. Significantly easier to trace than machine code though!

Re: Try Clojure – An interactive tutorial in the browser

#7
post #2

Do I need to have a somewhat decent knowledge of Java to plunge into Clojure right away?

Java the language? Very likely not. As proof - a majority of Clojure runs in JavaScript without any code changes (via ClojureScript). That said exceptions tend to look like Java classes, so you’ll definitely see Java bits. Java the JVM? You _probably_ don’t need to know it to get started, but you’ll have to get familiar with JVM deployment, dependency management, packaging, JVM memory settings, etc if you want to run…

My experience with ClojureScript is you absolutely have to know the host environment because you will encounter type errors and the maintainers have negative interest in making them clear to users (as in flatly refused offers to contribute changes to make those errors easier to understand).

Re: Try Clojure – An interactive tutorial in the browser

#9
I started playing around with Clojure back in 2014 by implementing a rudimentary polyglot persistent news feed microservice. That microservice used Ring which sits on top of Jetty. I blogged about that implementation at https://glennengstrand.info/software/architecture/oss/clojur... which is my personal blog. Last year, I re-evaluated Clojure with a feature identical microservice. This time, I integrated with Donkey which sits on top of Vert.x and https://glennengstrand.info/software/architecture/microservi... is where I blogged about that implementation.

I put each of these implementations in a load test lab where I collect then analyze the performance data for comparison purposes. Those two blogs include the performance results. It is hard for Clojure to compete with other tech stacks, primarily because each method call in Clojure goes through Java reflection which is pretty slow. There is a way to prevent the use of Java reflection in Clojure but then the Clojure code doesn't end up looking very Lisp like. The usual advise is to use type hints very sparingly like in hot spots in the code.

I still like Clojure, though.

Re: Try Clojure – An interactive tutorial in the browser

#10
post #2

Do I need to have a somewhat decent knowledge of Java to plunge into Clojure right away?

Not right away no, but it will help to have an understanding of Java/JVM for Clojure and Browser/Javascript for Clojurescript if you are intending on building real systems.
Post reply on HN