Implementing Clojure

383 views
Skip to first unread message

evins...@gmail.com

unread,
Feb 27, 2016, 3:39:24 PM2/27/16
to Clojure
Hey, guys. Suppose I wanted to tinker around with a compiler for Clojure on a new back-end. What would you guess is the best starting point (perhaps ClojureScript?), and what's the best spec to use to ensure compliance with the language?

Alan Moore

unread,
Feb 27, 2016, 8:09:39 PM2/27/16
to Clojure
It kind of depends on the backend you are targeting. If it looks and smells like the JVM you might look at ClojureCLR.

If it looks like Python see Clojure-metal by Timothy B.

The ClojureScript compiler was optimized for speed (as recently pointed out) so it may not be as straight forward to use as a reference. Although, as it is/can be self hosting this may be an advantage if your goals include self-hosting on the target.

What are your target/goals?

Alan

evins...@gmail.com

unread,
Feb 27, 2016, 8:38:56 PM2/27/16
to Clojure
I thought I might fool around with a Clojure on Common Lisp because I want some things that Common Lisp runtimes do and existing Clojure runtimes don't. I know how to write Lisp compilers and interpreters and how to implement Clojure's data structures, so what I mainly want is a handy reference to the definition o the language so that I'm not just bumbling around in in random documentation. But I wouldn't mind swiping from existing compilers wherever it makes sense.

Andy Fingerhut

unread,
Feb 27, 2016, 10:11:38 PM2/27/16
to clo...@googlegroups.com
The reference documentation is available here, starting with the Reader at this link, but continuing on with all of the other topics you see on the left hand side of this page, such as Evaluation, Special Forms, Macros, etc.


Any questions not answered there are probably best answered by the implementation itself.

Andy

--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clo...@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+u...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
---
You received this message because you are subscribed to the Google Groups "Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email to clojure+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Alan Moore

unread,
Feb 27, 2016, 10:53:50 PM2/27/16
to clo...@googlegroups.com
You might look at Nathan Sorenson's work compiling to gambit scheme here:


There is a ClojureWest talk (?) about this. I think things got a little hairy but YMWV.

Alan
-- 
"Whatever you can do, or dream you can do, begin it. Boldness has genius, power, and magic in it. Begin it now." - Goethe
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clo...@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+u...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
---
You received this message because you are subscribed to a topic in the Google Groups "Clojure" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/clojure/LskGXxEsufE/unsubscribe.
To unsubscribe from this group and all its topics, send an email to clojure+u...@googlegroups.com.

evins...@gmail.com

unread,
Feb 28, 2016, 1:34:00 AM2/28/16
to Clojure


On Saturday, February 27, 2016 at 9:11:38 PM UTC-6, Andy Fingerhut wrote:
The reference documentation is available here, starting with the Reader at this link, but continuing on with all of the other topics you see on the left hand side of this page, such as Evaluation, Special Forms, Macros, etc.


Any questions not answered there are probably best answered by the implementation itself.


That's what I was afraid of. Thanks.
 

Mark Engelberg

unread,
Feb 28, 2016, 5:13:23 AM2/28/16
to clojure
Yes, unfortunately, Clojure doesn't have an actual spec.  The lack of a spec probably helps keep the language more "agile", but I know several people who automatically discount the language because of that.

evins...@gmail.com

unread,
Feb 28, 2016, 1:40:54 PM2/28/16
to Clojure


On Sunday, February 28, 2016 at 4:13:23 AM UTC-6, puzzler wrote:
Yes, unfortunately, Clojure doesn't have an actual spec.  The lack of a spec probably helps keep the language more "agile", but I know several people who automatically discount the language because of that.

I don't discount it; it's a good language with a good ecosystem. A spec would be nice when writing an implementation, though. Even more convenient would be a suite of compliance tests. I can use the linked reference docs, of course, but it's more work to slog through them, and is exactly what I was hoping to avoid.
 

Mark Engelberg

unread,
Feb 28, 2016, 2:31:40 PM2/28/16
to clojure

--

Stephen Nelson

unread,
Feb 28, 2016, 3:17:19 PM2/28/16
to clo...@googlegroups.com
You could also consider implementing an interpreter

evins...@gmail.com

unread,
Feb 28, 2016, 5:13:45 PM2/28/16
to Clojure


On Sunday, February 28, 2016 at 1:31:40 PM UTC-6, puzzler wrote:


Excellent; thank you. 

evins...@gmail.com

unread,
Feb 28, 2016, 5:15:37 PM2/28/16
to Clojure


On Sunday, February 28, 2016 at 2:17:19 PM UTC-6, Stephen Nelson wrote:
You could also consider implementing an interpreter

That's precisely what I am considering--an interpreter or compiler--and exactly why I'm asking these questions.

Kevin Downey

unread,
Mar 1, 2016, 5:48:35 PM3/1/16
to clo...@googlegroups.com
The lack of a spec combined with a goal of "embracing the host" and
having two implementations you might choose to emulate (clojure and
clojurescript) can lead to a lot of confusion. Clojure and ClojureScript
have differences, so if you are targeting a new runtime, do you just
sort of aim between the two and add your own set of hosting embracing
mechanisms and tradeoffs? Clojure came before ClojureScript, and I have
alot more experience with it, so my sort of default stance is the
trade-offs and different things ClojureScript does are are compromises
due to compiling to javascript, and Clojure(JVM) is the best. But other
people point out that ClojureScript is newer, so is based on ideas that
did not appear in Clojure until after it had already go through several
releases. So ClojureScript is more refined and the best.

The definitive reference for both ClojureScript and Clojure remains
their respective compilers. The ClojureScript compiler is, I think more
approachable because it is written in Clojure and outputs Javascript. I
think because of this, getting ClojureScript up and running on a new
backend is a much more approachable target (someone did a lua backend at
one point, and I know a few people who have kicked around an elisp
backend). This kind of drives me nuts, because as I said, Clojure on the
JVM seems more like the "real" Clojure to me.

Nicola Mometto actually maintains a Clojure compiler written in Clojure
https://github.com/clojure/tools.emitter.jvm, but turning Clojure into
JVM bytecode is still more complex than emitting javascript.

>
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clo...@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+u...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
> ---
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to clojure+u...@googlegroups.com
> <mailto:clojure+u...@googlegroups.com>.
> For more options, visit https://groups.google.com/d/optout.


--
And what is good, Phaedrus,
And what is not good—
Need we ask anyone to tell us these things?
Reply all
Reply to author
Forward
0 new messages