News for hackers. Stuff that matters.
Re:Why I'm Productive in Clojure (2013) by pron on Sunday October 22, 2017 @08:27AM (#15526506)
I generally agree with you, but Clojure is not at all like other dynamic languages (like, say, JS). For one, Clojure's dynamic dispatch is more like C++/Java's -- i.e., when you call a function, you can statically know either the precise target or an explicitly designated set of possible targets. Second, Clojure allows you to specify the types of arguments (and much more, in fact), not with a type system, but with a specification system. It's not exactly the same, but it can be more/less powerful than types, depending on usage.
Re:Why I'm Productive in Clojure (2013) by ngrilly on Sunday October 22, 2017 @09:14AM (#15526668)
How is the specification checked, statically or dynamically?
Re:Why I'm Productive in Clojure (2013) by hellofunk on Sunday October 22, 2017 @09:41AM (#15526780)
You can see my other comment to your same question. Also, even if you do not use Spec, you do get a lot of compile-time validation like making sure all arguments are passed to a function, not leaving them out, etc. Try that in Javascript!
Re:Why I'm Productive in Clojure (2013) by ngrilly on Sunday October 22, 2017 @04:16PM (#15528700)
Are you sure about "you do get compile-time validation like making sure all arguments are passed to a function"?

If I run this:

    (defn bar [x y]
        (println x y))

    (defn foo [v]
        (if v (bar 12 42 79)))

    (foo false)
The program prints nothing and Clojure reports no error.

But when I run this:

    (foo true)
Then Clojure reports an error:

    Exception in thread "main" clojure.lang.ArityException: Wrong number of args (3) passed to: user/bar, compiling:(.../test.clj:6:5)
Re:Why I'm Productive in Clojure (2013) by hellofunk on Sunday October 22, 2017 @05:07PM (#15528938)
I don't spend much time on the JVM, but in ClojureScript, this is what I get for a similar test (including multiple definitions of foo in my case, i've elided the whole source file here):

     (defn foo [a b] :hi)
     (defn bar [] (foo 1 2 3))

     WARNING: Wrong number of args (3) passed to prepost.core/foo at line 25 src/cljs/prepost/core.cljs
     WARNING: foo at line 24 is being replaced at line 48 src/cljs/prepost/core.cljs
It's a compile-time warning even when the app is not running, but ClojureScript goes through a different compilation step than JVM Clojure. Perhaps I was mistaken in the JVM case, or someone else can chime in.
Re:Why I'm Productive in Clojure (2013) by ngrilly on Wednesday October 25, 2017 @05:10AM (#15548584)
Maybe ClojureScript is doing something Clojure doesn't at compilation time…