Hacker News new | past | comments | ask | show | jobs | submit login
Ferret: An Experimental Clojure Compiler (nakkaya.com)
86 points by trptcolin on June 30, 2011 | hide | past | favorite | 11 comments



I loved the literate programming style and the cleanliness of the FFI also. Org-mode is even more useful than I had previously thought, the http://orgmode.org/worg/org-contrib/babel/intro.html Babel addition also has a wonderful introduction and looks like an extremely powerful way of presenting code and commentary.


I applaud his effort (and this certainly isn't an easy project, he's a smart guy, etc.), but felt progressively more and more queasy reading this. I thought I could keep going even once I had realized the necessary lack of a runtime lambda or first class closure. When I got to the refcounting part, I mashed the back button in horror. Am I spoiled or what?


The reason I used ref counting instead of a proper garbage collector is that, most microconstollers have couple kilobytes of ram (a ATmega328 has 2KB) every garbage collection scheme I've looked at was using a lot of ram, plus ref counting is slow but it is predictively slow, if you are taking measurements at 100 times a second it will always be 100 times a second, you won't have pauses right in the middle of the routine (or say when you are in the air making a maneuver).


It's a myth that malloc/free is constant-time in a reference-counting scheme. If you are doing real-time programming, malloc/free should be avoided as much as garbage collection.


Very cool, and certainly not easy to pull off. It would be interesting to see a good native run-time for Clojure, essentially freeing it from the JVM (though, granted the JVM is driving its adoption). I fear that this is a lot of work however. The JVM may not be perfect for Clojure but a ton of work has gone into HotSpot. One way out is leveraging native libraries, extending the language with means to call into them. If that could be made more convenient, it would be incredibly powerful.


Correct me if I'm wrong, but to me in looks more like a C++ code generation than real compiler.

I would like to see real effort to have Clojure on the bare metal, but that will probably have to wait until "Clojure in Clojure" get more priority on clojure core.


This is how most Lisp compilers work. Gambit, Stalin, Chicken they all use C as the intermediate language. Currently this works on my MacBook, beagleboard and any avr microcontroller with enough ram and flash memory. If I were to use machine code I would have to output 3 completely different instructions sets.


Have you considered LLVM?


Compiling to LLVM is an interesting prospect, because if you could make the language dovetail nicely with, meaning compile functions into LLVM functions and use their datatypes fully you could presumably be highly interoperable with other languages(?). Sounds like it could be a serious departure from the Clojure standard though, but perhaps another Clojure inspired LISP. Still, LLVM won't give you a run-time, which seems to be the main problem.


No, I didn't know there was a llvm backend for avr.


Per Wikipedia, a compiler is "a computer program ... that transforms source code written in a programming language ... into another computer language".




Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: