I don't think lack of types is a drawback to Cloju...
# getting-started
b
I don't think lack of types is a drawback to Clojure. Maybe if you're a programmer who's used to static types, the lack of "typing" can be a big shock to the system. Clojure works in a different way so what you thought you would do with types can be achieved with multimethods and protocols. Furthermore with Clojure 1.9 you know have Clojure.Spec which allows you to specify the expected behaviour of a function with respect to the datatypes passed in or out so you get the advantages of static whilst still having dynamic typing. I say this as a current Java/Kotlin programmer who also uses Clojure. Just a different way to achieve the same objective.
s
generally I’m pretty in the middle of these kinds of debates, but in this case I don’t agree that dynamic typing is just a different way to achieve the same thing
static typing enforced by the compiler helps cut down on lots of subtle bugs and makes it easier to determine whether or not a given function is correct
👍 1
also, refactoring dynamically typed code can be a nightmare 😬
but I suppose I’m not telling you anything you haven’t heard and evaluated for yourself 😅
to be clear, these are also all points for why Clojure.Spec isn’t just for the people who are “shocked” by the type system lol
b
You can do the same thing with Clojure spec. I felt a bit naked without static typing at first but then I got used to that approach and I can switch from say Kotlin to Clojure quite happily these days. Agree that without a static compiler, refactoring can be arduous for dynamic languages but there are good tools out there for Clojure like Cursive which help enormously. Here's a good example which I think demonstrates spec approximates what static compilation would cover. https://adambard.com/blog/domain-modeling-with-clojure-spec/ Having said that I'm enjoying Kotlin programming. It's what Java should currently be.
p
I was doing Clojure for a long time and loved it a lot. It was so much fun to write with it. The problem is reading the code though. Coming back to my old project written in Clojure I just have no idea what's going on. That has never happened to me with Java or Kotlin. It's pretty easy to figure out what does the code do. Maybe I am just bad at Clojure..
b
I know what you mean. You're in the zone when writing it but came back a month later ...😆. That's why I think Clojure spec is a great addition
p
cool, I should check it out.. I think Kotlin should really work on getting it's REPL into much better state. It's such an awesome way to work.
g
I think it's mostly a trade off between being able to quickly change things dynamically vs preventing some errors because the code would not compile. But static typing is no guaranty against bugs.
I never had problems going back to 'old' clojure programs before, might be because of spec, or because I really like to keep the functions and namespaces small.