Live data from Hacker News

Try Clojure – An interactive tutorial in the browser

tryclojure.org

71–80 of 96 posts

Re: Try Clojure – An interactive tutorial in the browser

#71

How 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.

Depending on your IDE, you could use different tools to provide the intellisense-like functionality for clojure. For Jetbrains, there is Cursive, for emacs, Cider, etc. I won't disagree that the beginning experience can be lacking even when coming from Java - for instance a good coding environment also includes setting up a hosted repl, but the extra effort does pay off in being able to code interactively as your program runs.

The lack of type checking is due to the entirely different paradigm that Clojure is built around. There are many benefits to it, but I can understand the frustration if you expect to use the language in a way that goes against that, especially when dealing with the interop layers. The fact that it is built upon the JVM is powerful but it's not necessarily an easy language switching from a language like Java.

Re: Try Clojure – An interactive tutorial in the browser

#72

How 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.

Clojure is dynamically typed, this is different from untyped or lacking type checking.

Also, you can have autocomplete, it's orthogonal to static typing.

Re: Try Clojure – An interactive tutorial in the browser

#73
post #64

Not 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.…

Try typing (doc range) and the docstring will appear.

Thanks. I guess the docs are correct about "end" defaulting to infinity, as "(range)" by itself in the REPL just locked everything up (for about 2 minutes, then resulted in an error of "Invalid string length")

Re: Try Clojure – An interactive tutorial in the browser

#74

I would love to work with clojure. I thought there were opportunities for to work on a clojure project in my previous company. But I was told that no one likes to work on these products hence why they moving away from clojure and rewriting everything in java or scala. I wish I could tell you exactly why they hated it, I never got an answer. Speaking to some of the individuals, they thought it came down to tooling, no…

It's the latter argument that did it for me. I never again want to work primarily with a technology that doesn't have encapsulation of optional types. It's just such an uninteresting problem to have to continuously suffer from.

You may have seen it already but Rich Hickey the creator of Clojure had a great talk about this https://youtu.be/YR5WdGrpoug

Re: Try Clojure – An interactive tutorial in the browser

#75
IT's worth knowing that this is you typing into a REPL, that when you are actually doign REPL driven development you almost never type directly into the REPL in Clojure.

ALmost all editors I've seen allows you to send code to the REPL from your editor, and get the results in line in your editor.

Typing into the REPL would be bad practice.

Re: Try Clojure – An interactive tutorial in the browser

#76

Earlier quoted context omitted.

It's the latter argument that did it for me. I never again want to work primarily with a technology that doesn't have encapsulation of optional types. It's just such an uninteresting problem to have to continuously suffer from.

You may have seen it already but Rich Hickey the creator of Clojure had a great talk about this https://youtu.be/YR5WdGrpoug

I’ve seen a few of his talks, but I do not accept his position on types more generally. I wrote a rebuttal to a similar talk he gave a few years ago.

https://jezenthomas.com/rich-hickey-doesnt-know-types/

Re: Try Clojure – An interactive tutorial in the browser

#77

How 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.

For intellisense / auto-complete, that is just down to your IDE.

See here, I have autocomplete and intellisense using VSCode and Calva, but I can also hover a function and see the clojure docs for it, then copy them to my IDE, and run the example code all within my editor. Then remove it when I'm done playing. The doc examples go into a rich comment form.

https://www.youtube.com/watch?v=LeNECtkJw6s

Re: Try Clojure – An interactive tutorial in the browser

#78
post #56

=>(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.

That's returning a transducer which is hairy implementation wise regardless of compilation.

Transducers are awesome! They are so elegant. If one is interested in transducers I liked Ben Sless's intro: https://bsless.github.io/transducers-intro/ or in video "workshop form" https://www.youtube.com/watch?v=1sC71eb9Ox0

Re: Try Clojure – An interactive tutorial in the browser

#80

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…

Like others said, Clojure does not reflect on every call. A good resource if you really want to push the perf limit http://clojure-goes-fast.com

Most data focused microservices for business applications devote most of their code to calling databases. The PoC microservices that I implemented in order to evaluate Clojure use Java libraries to communicate with Cassandra, MySql, Redis, and Elastic Search. Clojure is not currently at a point in adoption where it makes a lot of sense for these database vendors to support native Clojure libraries.

While it is true that not every method calls goes through Java reflection, it is also safe to say that every API call to this kind of service will end up making a lot of calls via Java reflection unless you use types hints all over the place in the DAOs.

Post reply on HN