News for hackers. Stuff that matters.
Re:Challenging Clojure in Common Lisp (2014) by krat0sprakhar on Sunday January 08, 2017 @04:33AM (#13349041)
> as long as you put the right type hints everywhere.

I'm a novice Clojure programmer and haven't previously heard of this. Can you please elaborate?

Re:Challenging Clojure in Common Lisp (2014) by hkjgkjy on Sunday January 08, 2017 @06:45AM (#13349324)
You don't need to specify what type a function takes in Clojure, which is often nice. If you do though, the compiler can sometimes optimize, and make things much faster. Basically, the compiler does not have to

* look up the type of the thing * run the action on it

but can instead skip straight to step 2.

If you somewhere in your Clojure program (or repl) run (set! warn-on-reflection true) it will print to the console when you are doing reflection.

I think it's a good idea to put in the beginning of your core namespace - so that it is always on. Why not always wear the seatbelt when driving, you know?

Re:Challenging Clojure in Common Lisp (2014) by moomin on Sunday January 08, 2017 @04:45AM (#13349061)
Short version: put :warn-on-reflection in your leiningen file, And then add type hints (google them) to reduce the warnings to zero.

There's no reason the average Clojure project ever need be using reflection for dispatch.

Re:Challenging Clojure in Common Lisp (2014) by raspasov on Sunday January 08, 2017 @04:53AM (#13349083)
Correct, a lot of the average application-level code you see in the wild does not have to worry about this. If we're talking about things like load-balancers or databases or endpoints/functions that will be hit 1000s of times per second - then it's a diff. conversation.
Re:Challenging Clojure in Common Lisp (2014) by ajss on Sunday January 08, 2017 @04:41AM (#13349055)
(defn [o n] (.write o n)) will have to look up the .write method by doing reflection on o & n at runtime, which is really slow.

(defn [^WriteInterface o ^long n] (.write o n)) can be much faster because the compiler knows the type of o & n.

Re:Challenging Clojure in Common Lisp (2014) by abc_lisper on Sunday January 08, 2017 @01:18PM (#13351077)
I think you meant to say, (defn func[o n] (.write ^WriteInterface o ^long n))

This is needed only when calling Java methods, because Java allows overloading. Clojure only does arity-overloading, not type overloading, and hence doesn't need the type info.