r/rust • u/---cameron • Apr 23 '20
ClojureRS - Clojure, implemented atop Rust
https://github.com/Tko1/ClojureRS7
7
1
u/denis631 Apr 24 '20
Actually I was thinking of porting Clojure to LLVM myself.
Nice!
However I don't know whether Rust is a good choice (I was planning to do it in OCaml), due to complications of implementing persistent collections in non-GC languages
2
u/---cameron Apr 25 '20 edited Apr 25 '20
Yes, this has come up a few times as well in my research and overall its a case where I want to work with the constraint and see what happens. I think no matter what, that even if this doesn't end up the most optimal implementation, I think there will be value just in this existing as something unique, and being another 'path' one can explore. I don't know, I can't find the right words for exactly what I mean in this case. It was never intended to be a practical project, but I would definitely now like to explore making it as practical as possible
1
u/denis631 Apr 25 '20
actually I don't even know if porting to LLVM is a good idea.
LLVM is not really designed for functional/repl languages (not an expert here, just an assumption), therefore maybe it would be even smarter to port it to OCaml/Haskell infrastructure :thinking:
1
Apr 23 '20
That's very interesting, thanks for sharing. I'm curious what do you mean by "atop Rust". Do you see the project as some sort of a macro-language, that compiles to Rust code? Or will it be run by a virtual machine written in Rust?
2
u/TheDan64 inkwell · c2rust Apr 23 '20
Glancing at the source, I think it just means that it's interpreted in Rust itself, rather than compiling down to LLVM IR or something like that
3
u/---cameron Apr 23 '20 edited Jul 19 '20
So, right now its indeed just an interpreter in Rust, with some plans for some shape of FFI or Rust interop. To be honest, I semi regretted the phrasing 'atop Rust' at first, as I realized it was a result of always thinking about Clojure in terms of what it was sitting on top of, since its normally a hosted language (despite the fact that this project is in fact intended to be the opposite). I also regretted it as the original plan was to look into possibly going in the direction of some sort of JIT compilation anyways, in which case the fact that the compiler is implemented in Rust wouldn't be so relevant to begin with honestly, unless there's something I'm missing. But, since it is indeed currently a interpreter, and is now actually staying in that direction (focusing more on possibly being embeddable into Rust apps, and having other Rust specific things like the aformentioned Rust interop and FFI), I've left the phrasing in. As far as embedding this into another app, I in particular would love to use this for a project I've wanted to do for a while, which is some sort of implemention of a fusion of emacs and the Smalltalk environment.
Anyways, I am 99% most likely going to go with a bytecode / VM as well, but it is for now a simple interpreter.
17
u/---cameron Apr 23 '20 edited Apr 23 '20
Hey guys, I meant to post this a good bit later when it was more mature, but someone found it pretty early and posted it on some Clojure forums, so I figured I'd like to post it here as well if this interests anyone. I will say that I'm a programming language enthusiast, and one thing I do like about a project like this is getting to sorta have this sort of discussion in two language communities.