=>(map inc) function(b){return function(){function c(k,t){t=a.g?a.g(t):a.call(null,t);return b.h?b.h(k,t):b.call(null,k,t)}function d(k){return b.g?b.g(k):b.call(null,k)}function e(){return b.s?b.s():b.call(null)}var f=null,g=function(){function k(w,u,B){var p=null;if(2 The output is correct as far as I can tell but that's some pretty hairy Javascript right there. Edit: Formatted code.
clojurescript used to go through the Google Closure compiler, maybe it still does?
Try Clojure – An interactive tutorial in the browser
61–70 of 96 posts
Re: Try Clojure – An interactive tutorial in the browser
#62I 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…
> 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. That's not true. Clojure functions calling each other do not use reflection. It is only when interoping with Java, and trying to call a Java member method of an object that reflection might be used if there are multiple concrete implementation of the method and t…
Re: Try Clojure – An interactive tutorial in the browser
#63And auto-complete when it comes to Java library interop?
I tried Clojure, to build a tool on top of a popular Java library that I was new to.
And compared to other JVM languages it was not good because there was no type-checking or intellisense/autocomplete popups for the methods.
Re: Try Clojure – An interactive tutorial in the browser
#64One piece of feedback - "Range of N" should clarify that "range" is generating N numbers starting at 0, so N won't actually be included ("0 to N exclusive"). I know this is fairly common for most programming languages, but "So (range 5) will return numbers from 0 to 5." is still ambiguous enough that I think it should be clarified.
Also can't copy the text from the instructions or REPL (at least in Vivaldi on Windows 10).
edit: I'm not a huge fan of the "multiples of 11" algorithm ("100" and "11" never actually show up in the expression...), so I ended up with this abomination which I think strongly reiterates that I don't get Clojure yet...:
> (let [multiplier 11 limit 100] (map (fn [n] (if (> limit (* n multiplier)) (* n multiplier))) (range 1 (/ limit multiplier))))
(11 22 33 44 55 66 77 88 99)
The conditional is probably not needed, but I was curious how they worked... Also glad that range accepts a float for the second value, as I forgot to wrap that in "int" (and "Math/round" didn't seem to work). And yeah, tested and this works just as well for at least the basic version:
> (let [multiplier 11 limit 100] (map (fn [n] (* n multiplier)) (range 1 (/ limit multiplier))))
Re: Try Clojure – An interactive tutorial in the browser
#65How do people who write Clojure deal with lack of type checking? And auto-complete when it comes to Java library interop? I tried Clojure, to build a tool on top of a popular Java library that I was new to. And compared to other JVM languages it was not good because there was no type-checking or intellisense/autocomplete popups for the methods.
I think the other key to working with clojure is to set up your program as a set of transforms on simple data structures as much as possible such that complex class interactions aren't used much, and that cuts down on the need for great intellisense and static typing. Ymmv, of course, but I've found this way of working more productive than when I was working in Java.
Re: Try Clojure – An interactive tutorial in the browser
#66How do people who write Clojure deal with lack of type checking? And auto-complete when it comes to Java library interop? I tried Clojure, to build a tool on top of a popular Java library that I was new to. And compared to other JVM languages it was not good because there was no type-checking or intellisense/autocomplete popups for the methods.
The short answer is that you don't. Rich Hickey, the creator of clojure, made the language *very* opinionated by design. And one of the strong options is that folks should be aiming for simplicity in their code, checking their code as they go along using the repl in real time. Dynamic typing makes it much easier to do this.
Whether or not this is a good approach (I happen to like it) is up for debate (and likely a matter of taste too), however that's at least some of the rationale at a high-level.
To really enjoy using clojure, you have to do things the way the language wants you to. If you try to bring your java style workflow into clojure, it's not going to be a lot of fun.
Re: Try Clojure – An interactive tutorial in the browser
#67How do people who write Clojure deal with lack of type checking? And auto-complete when it comes to Java library interop? I tried Clojure, to build a tool on top of a popular Java library that I was new to. And compared to other JVM languages it was not good because there was no type-checking or intellisense/autocomplete popups for the methods.
First of all, yes there is. Maybe your editor didn't support it, but e.g. IntelliJ IDEA with the Cursive plugin does.
Re: Try Clojure – An interactive tutorial in the browser
#68How do people who write Clojure deal with lack of type checking? And auto-complete when it comes to Java library interop? I tried Clojure, to build a tool on top of a popular Java library that I was new to. And compared to other JVM languages it was not good because there was no type-checking or intellisense/autocomplete popups for the methods.
Re: Try Clojure – An interactive tutorial in the browser
#69Re: Try Clojure – An interactive tutorial in the browser
#70Not sure I "get" Clojure yet, but I appreciate the effort and will poke at it further. One piece of feedback - "Range of N" should clarify that "range" is generating N numbers starting at 0, so N won't actually be included ("0 to N exclusive"). I know this is fairly common for most programming languages, but "So (range 5) will return numbers from 0 to 5." is still ambiguous enough that I think it should be clarified.…