I started Jarc by writing an s-expression reader. Then I implemented the 9 Arc primitives in Java and then I started writing eval in Java. Then I incrementally added the missing
global functions used in arc.arc - that took a while, but wasn't particularly difficult.
I spent a lot of time thinking about the Arc to Java interface. I wanted it to be
as light weight as possible and as brief as possible, in keeping with the Arc goal
of making programs shorter. In particular, I wanted to avoid any 'import' or 'defcall'
requirements if possible.
Another important consideration is how much of your interpreter can you write in Arc.
I was anxious to stop writing Java and be able to add missing global functions in Jarc
as soon as possible. At last count, I have 61 functions implemented in Java and
73 in Jarc itself.
Jarc doesn't have first-class continuations or fractional numbers. The interpreter also doesn't do tail call elimination. (I did write a compiler this year to do
tail call elimination in recursive functions.)
From what I learned working on Arc and talking with Conan about Rainbow, implementing a
continuation passing style interpreter is the way to go if you want first-class
continuations and tail call elimination.
Writing Jarc has been great fun, and I've learned a lot.
"I started Jarc by writing an s-expression reader. Then I implemented the 9 Arc primitives in Java and then I started writing eval in Java. Then I incrementally added the missing global functions used in arc.arc - that took a while, but wasn't particularly difficult."
That's how I planned to start the implementation, but I've also considered writing a compiler that translates the arc code into MSIL using Reflection.Emit. That would allow me to do tail-call optimization, and possibly CPS.
So what do you have currently for your Arc/Java interface, and what are your thoughts on difficulty of implementation, ease of use, etc. associated with that choice? Are there other options that you considered and discarded, or haven't gotten around to implementing yet? I was thinking of trying to treat assemblies, namespaces, classes, and objects like hash tables, and letting (obj 'name) access the member, but I don't know how well that will work with mostly static typing.
I'm not sure what to think about fractional numbers. I don't think I've ever had a good reason for using them, so I won't bother implementing them myself until I do.
In fact, CPS benefits from TCO. By converting a program into explicit CPS, every function call becomes a tail call (to the current continuation); without TCO, stack space would run out quickly. Certain TCO implementations can also use CPS; see http://en.wikipedia.org/wiki/Tail_call#Implementation_method....