Re:ClojureC, a compiler for Clojure that targets C as a backend
by jared314 on Saturday May 04, 2013 @10:06PM
(#5657158)
Have you looked at mjolnir[0]? It was part of a presentation at Clojure West this year. I'm not sure if the video is out yet, but the slides are[1].
[0] https://github.com/halgari/mjolnir
[1] https://github.com/strangeloop/clojurewest2013/tree/master/s...
Re:ClojureC, a compiler for Clojure that targets C as a backend
by rdmckenzie on Saturday May 04, 2013 @10:13PM
(#5657179)
bah just as I was finishing my register allocator...
My Firefox history indicates that I have read the Mjolnir page before, but I don't recall why I didn't use it at the time. Taking another look :-P. Thanks for the link!
Re:ClojureC, a compiler for Clojure that targets C as a backend
by timbaldridge on Sunday May 05, 2013 @01:28AM
(#5657532)
Author of Mjolnir here. There's some major updates going on in the "datomic" branch. If you're thinking of using Mjolnir in a project, you'll want to keep an eye on that branch over the next few months.
With Datomic, the inference engine is completely re-written in datalog. This allows for a massive code clean-up, and the code in that branch is much cleaner.
The reality of the matter is that interacting with non-java linked libraries is a real pain from every JVM language know of. Two years ago this was posted here [https://github.com/jasonjckn/llvm-clojure-bindings], but since then LLVM has gone through two major restructurings so it didn't work out of the box and I estimated that it would take less effort to build my own naive infrastructure than to patch this one & integrate it.
As a result I'm generating code in terms of lists of newline terminated assembly statement strings that I can just print or write to a file when I'm done. While I agree that C is a sub-optimal output format in that you have to compile the output, it is also the clear lingua franca for systems programming and assembly generation these days. Generating C gives you interesting options like linking to other C codebases or your own C code the same way that cljs gives you the option of interacting with "native" javascript libraries as well as clojurescript toolkits.