>> I've been debating on working on a native Clojure

I've also been debating this for over two years now,y but I keep
coming back to the same problems over and over again:

1) A from-scratch native Clojure either needs to be just a compiler
(as this project is), or you're going to need a decent GC, JIT and
object system
2) The Boehm GC is easy to use, but it's not fast or accurate. The
JVMs can implement generational concurrent compacting GCs (and do
depending on your implementation). These are all very useful features,
and things that Boehm doesn't support. In addition, Boehm isn't
accurate, so memory leaks can still occur.
3) Unless you plan on staying strictly AOT, and igoring the REPL, then
we're going to need a JIT, that's not exactly something you can hack
together in an afternoon
4) Arithmetic must auto-unbox or it will be quite slow. This also
requires a JIT.
5) Clojure is made up of hundreds of single line functions, a JIT
should be able to inline this, one more reason why its needed


All these reasons have brought me to the conclusion that the simplest
way to get all this, is to base a native version of Clojure on PyPy.
No, I didn't say write it in Python and have it run on the Python VM.
PyPy is technically speaking a "language agnostic JIT generator
written in Python".

A good overview of this process is here:
http://morepypy.blogspot.com/2011/04/tutorial-writing-interpreter-with-pypy.html

What you get with a JIT written in PyPy:

1) Your interpreter/JIT is written in a dynamic language with tons of
meta-programming abilities
2) You get at least 3 GCs (reference counting, mark-and-sweep, Boehm)
3) You get a tracing JIT, that for dynamic languages blows method
level JITs away
4) You get STM abilities (as of the most recent work in PyPy)
5) Automatic unboxing, inlining and constant propagation of JIT'ed
code (comes free with a tracing JIT).
6) And you still have great interop with C and with some work C++ (via Reflex)

I don't really want to hi-jack this thread, I just wanted to make
people aware that writing a fast native Clojure takes a bit more work
than simply slapping LLVM and Boehm together. Do that and the JVM will
beat you every single time.

Timothy

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to