
Clojure implemented on top of Python - DanielRibeiro
https://github.com/eigenhombre/PyClojure
======
Lazare
I know it's irrational, but I tend to avoid JVM languages after some bad past
experiences. (Yes, I know, Java is great, and the JVM is vastly improved! I
said it's irrational.)

On the other hand, I've been wanting to learn Clojure. It'd be nice to see
this project mature.

~~~
lclarkmichalek
Well the aim of this project seems to be to avoid the start up time of the JVM
so clojure can be used for scripting.

~~~
cabalamat
And also to "make use of [Python's] extensive, 'batteries included' libraries"

That's what seems the real benefit of it to me. Maybe Python will become not
just a language, but a platform, like JVM or CLR, supporting multiple
languages.

------
videoappeal
If complaining about the startup times of JVM then i believe a solution exists
laready i.e. ClojureScript running on top of Node.Js be a better fit?

~~~
masklinn
> i believe [...] ClojureScript running on top of Node.Js be a better fit?

Why? Python is likely to be installed in far more environment than Node, and
for scripting, Clj on top of Python provides the faster startup of Python
interpreters without the callback spaghetti inherent to Node. Because even if
Clojure(Script) handles functions better than Javascript (both in verbosity —
fns are no more verbose than lets — and in its scoping handling) it's still
callback spaghetti.

~~~
videoappeal
Why ClojureScript? because it is much closer to feature complete, tested,
supported by the core team yada yada

~~~
masklinn
> Why ClojureScript?

No, why is clojurescript a better fit (than clojure, running on Python)

------
pavelludiq
Why reimplement all of clojure as an interpreter? Why not just rewrite the
java parts in python and compile to bytecode? Honest question.

~~~
moonchrome
Actually a better path would have been to hack on the ClojureScript compiler
that compiles to JavaScript and fork it to compile to Python, most of the core
stuff is implemented with ClojureScript primitives (like seq library,
collections, atoms, etc.) so there would be substantially less work starting
from there.

------
djhworld
Initially when I first saw this I thought "nice but...really?" then I read the
blurb about writing scripts/automating system tasks and remembered the pain of
the JVM startup.

Will definitely be keeping an eye on this.

------
postfuturist
To solve the clojure script startup time:
<http://www.martiansoftware.com/nailgun/> "Nailgun is a client, protocol, and
server for running Java programs from the command line without incurring the
JVM startup overhead."

I only know about since vimclojure uses it (to good effect, so it obviously
works fine with Clojure).

~~~
gtrak
Also consider clojurescript on node.js, might be more worth the effort than a
python implementation at this point.

------
nathell
An insane idea: run this on top of CLPython on top of ABCL on top of the JVM.

~~~
mattdeboard
Yeah and let's get it to compile down to XML!

~~~
bwarp
I wouldn't even go there.

I worked on an ecommerce project in the early 00's which compiled a high level
turing complete DSL (not that far from LISP TBH) to XML and then used a
virtual machine written in Java to run the XML. I've never seen a language in
which the compiler output was 2 orders of magnitude larger than the source
code.

I really don't know how anyone came to the conclusion that any of that was a
good idea.

I still have nightmares about that.

~~~
lmm
>I've never seen a language in which the compiler output was 2 orders of
magnitude larger than the source code.

Ever used SWIG, or qt designer, or anything else that compiles to a source
code format? (heck, I can only assume most of those languages-that-compile-to-
javascript must be similar)

(not that that makes your project any less bad)

------
sandGorgon
I wonder what happened to Shen
(<http://www.lambdassociates.org/Shen/newappeal.htm>). From the blurb, __This
function set defined a Lisp that was much smaller than Common Lisp, in fact,
much more like John McCarthy's Lisp 1.5 which is the distant ancestor of all
subsequent Lisps.... I went further and suggested that this small Lisp could
probably be mapped into many of the Lisp-like successors to Lisp like Python,
Clojure and Javascript. This meant that because Qi was bootstrapped, these
mappings could be used port Qi into other platforms"

Actually come to think of it, what ever happened to clojure-in-clojure [1] -
that would have made implementing clojure on top of any VM, relatively trivial

[1] <http://blog.n01se.net/?p=41>

------
apgwoz
While I appreciate the sentiment, Python isn't exactly the fastest language
out there. But, if you have to do it, I'd suggest compiling to the Python AST
and emitting bytecode.

~~~
lloeki
Or restricting oneself to RPython and reap all the benefits of PyPy's JIT
basically for free.

~~~
celebdor
I was thinking of doing just that last weekend. I look forward to start soon
and hopefully use some of the infrastructure/ideas of this python
implementation.

------
andrewcooke
how does it implement clojure's lazy sequences? does it manage to map them to
generators?

~~~
irahul
From a cursory glance at
<https://github.com/eigenhombre/PyClojure/blob/master/core.py> it doesn't do
anything with the lists yet, other than having a list class which stores the
values.

As far as lazy goes, how does clojure does it? Thunks? The implementer can opt
for thunks or generators(doesn't generator serve as an higher level
abstraction to manually "thunk and force") as far as Python implementation
goes.

~~~
andrewcooke
i have no idea how clojure is implemented, but i guess i always assumed that
they were implemented as iterators.

------
steele
oh JVM startup time isn't that terrible, but this is cool.

~~~
regularfry
Yes, it is. When I compare red-green-refactor cycles between Ruby and Clojure,
and I've got sub-second turnaround in one and 5+seconds in the other, it's
painfully bad.

~~~
steele
Sounds like you need a slice of cake.

~~~
steele
Not sure about the -1. Cake is a clj build tool that would help alleviate the
severity of JVM startup cost...

