strace’ing a Clojure process under lein

August 16th, 2016

Today I wanted to strace a JVM process to see if it was making network calls, and I discovered a minor roadblock: It was a Clojure program being run using the Leiningen build tool. lein run spawns a JVM subprocess and then exits, and I only wanted to trace that subprocess.

Read full entry »

On the immiscibility of higher order functions and unboxed invocation in Clojure

February 17th, 2012

Recently, Tim McIver and I set out to bring clojure.contrib.import-static into the modern world. This is lib that looks on the surface to be quite handy: (import-static java.lang.Math sqrt PI) allows you to write (sqrt PI) instead of (Math/sqrt Math/PI). The huge downside is that sqrt is a macro, so it can't be passed around as in (map sqrt (range 10)). (This does allow (with appropriate hinting) primitive invocation (non-boxed passing of primitive JVM types such as long and double) and reflection at compile-time instead of runtime.) Our idea was to replace import-static with def-statics, a macro that could produce prim-invocable functions instead of macros.

Summary: You can't actually do that. HOFs in a dynamically-typed language are not compatible with unboxed primitive invocation.

Read full entry »