This is neat. What worries me about this and similar efforts (like https://github.com/takeoutweight/clojure-scheme ) is that clojure's standard library design assumes that the underlying runtime will be do some kind of polymorphic method inlining. For example: the sequence library is all defined in terms of ISeq, which basically requires a "first" and "rest" to be defined for the data structure in question. These are…
ClojureC, a compiler for Clojure that targets C as a backend
51–60 of 89 posts
Re: ClojureC, a compiler for Clojure that targets C as a backend
#52sadly, this doesn't seem to support any sort of multithreading. Even something as simple as swap! isn't thread-safe in this implementation. So that kills one of the main reasons to use Clojure in the first place.
Maybe multithreading is just not yet implemented?
> So that kills one of the main reasons to use Clojure in the first place.
I could see ClojureC being very useful for when you want:
* small footprint
* easy C-library interop
* fast start-up time
and where you don't necessarily need multithreading.(BTW, I'd be curious to hear what you think might be the differences in use cases between ClojureC and mjolnir/clojure-metal.)
Re: ClojureC, a compiler for Clojure that targets C as a backend
#53Earlier quoted context omitted.
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...
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!
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.
Re: ClojureC, a compiler for Clojure that targets C as a backend
#54This is neat. What worries me about this and similar efforts (like https://github.com/takeoutweight/clojure-scheme ) is that clojure's standard library design assumes that the underlying runtime will be do some kind of polymorphic method inlining. For example: the sequence library is all defined in terms of ISeq, which basically requires a "first" and "rest" to be defined for the data structure in question. These are…
This requires you to execute the application with profiling turned on.
Then you compile the application a second time with the additional input of the profile results, this way the optimizer gets additional information that helps it to do decisions similar to a JIT.
It is all a matter of adding support for this.
Re: ClojureC, a compiler for Clojure that targets C as a backend
#55Earlier quoted context omitted.
Generating C is quicker to write and easier to debug (can more easily read intermediate output) and doesn't require accessing a C++ api.
I can't stress the C++ api part of this enough. At the moment I'm building a Pascal compiler in Clojure for course work and when the time came to do byte code generation the first thing I looked to was the LLVM infrastructure both for ease of use and because it would trivially provide me with the ability to target non-x86 platforms. The reality of the matter is that interacting with non-java linked libraries is a rea…
Re: ClojureC, a compiler for Clojure that targets C as a backend
#56So if I wanted to write CLI applications in Clojure, is this my best bet? Cause the JVM is about the least suitable platform I have ever worked with for CLI apps...which is most of what I do. I'm constantly in this pickle of wanting to use Clojure but defaulting to Ruby because the JVM is so terrible at it.
Re: ClojureC, a compiler for Clojure that targets C as a backend
#57As someone who doesn't use Clojure, but watches it fairly closely, I'd say the least appealing part of Clojure is its reliance on the JVM. As such, I'd say efforts such as these are greatly welcomed.
Like it or not, this is what made Clojure successful in the enterprise, at least when compared against other Lisps.
Re: ClojureC, a compiler for Clojure that targets C as a backend
#58Re: ClojureC, a compiler for Clojure that targets C as a backend
#59Earlier quoted context omitted.
Nonsense?! Outputting text to be interpreted as code is far more low level and error prone than targeting an AST via an API like LLVMs. And you loose a lot of high quality tooling that you could take advantage of.
"more ... error prone" Can you prove that? If not, it's just a baseless opinion.
You are wrong here. Unproved statements are not necessarily baseless opinions. They may be well supported opinions.
I think you meant to ask him, "Can you support that?"
Re: ClojureC, a compiler for Clojure that targets C as a backend
#60This is neat. What worries me about this and similar efforts (like https://github.com/takeoutweight/clojure-scheme ) is that clojure's standard library design assumes that the underlying runtime will be do some kind of polymorphic method inlining. For example: the sequence library is all defined in terms of ISeq, which basically requires a "first" and "rest" to be defined for the data structure in question. These are…
It might be interesting to translate Clojure into a subset of Scheme that is widely supported -- and use one of the mature Scheme -> C compilers (Gambit, Chicken, Bigloo) to generate the target executable.