Clojure implemented on top of Python(github.com)
github.com
Clojure implemented on top of Python
https://github.com/eigenhombre/PyClojure
10 comments
There is one big problem in projects like these - Clojure's packaging system is strongly tied to the java ecosystem.
packages written in pure clojure are also distributed as jars and the ecosystem is strongly dependent on maven.
packages written in pure clojure are also distributed as jars and the ecosystem is strongly dependent on maven.
I guess .Net [1] is no option either?
Not sure if that stuff works on top of mono as well..
1: https://github.com/clojure/clojure-clr
1: https://github.com/clojure/clojure-clr
I have that same irrational feeling about the JVM, I'll say this, go ahead and learn Clojure; it only slightly smells like the JVM.
To be fair, the JVM is why Clojure doesn't have TCO (and no, trampolines don't count).
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.
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.
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.
You can use Clojurescript on top of Node.js to achieve that. I never tried it so I don't have first hand experience.
https://github.com/clojure/clojurescript/wiki
https://github.com/clojure/clojurescript/wiki
How does it accomplish that better than say, clojurescript+node?
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?
> 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.
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.
Why ClojureScript? because it is much closer to feature complete, tested, supported by the core team yada yada
> Why ClojureScript?
No, why is clojurescript a better fit (than clojure, running on Python)
No, why is clojurescript a better fit (than clojure, running on Python)
Python is preinstalled on a lot of platforms. That might be relevant.
Why reimplement all of clojure as an interpreter? Why not just rewrite the java parts in python and compile to bytecode? Honest question.
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.
Are you familiar with PyPy? It was originally just an exercise in implementing Python in Python, but then it was discovered that this led to some very interesting possibilities for JIT compilation, and after a lot of work PyPy is now much faster for most tasks than regular CPython.
The thing is, there's nothing about PyPy that says it has to be implementing Python itself, and recently here on Hacker News there was an article where someone was singing the praises PyPy as a way to implement the language he was developing. http://tratt.net/laurie/tech_articles/articles/fast_enough_v...
And it seems this person had come to the same realization.
EDIT: Oops, rereading I see I misunderstood something the README said, and he is only now considering using PyPy instead of CPython.
The thing is, there's nothing about PyPy that says it has to be implementing Python itself, and recently here on Hacker News there was an article where someone was singing the praises PyPy as a way to implement the language he was developing. http://tratt.net/laurie/tech_articles/articles/fast_enough_v...
And it seems this person had come to the same realization.
EDIT: Oops, rereading I see I misunderstood something the README said, and he is only now considering using PyPy instead of CPython.
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.
Will definitely be keeping an eye on this.
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).
I only know about since vimclojure uses it (to good effect, so it obviously works fine with Clojure).
Also consider clojurescript on node.js, might be more worth the effort than a python implementation at this point.
An insane idea: run this on top of CLPython on top of ABCL on top of the JVM.
Yeah and let's get it to compile down to XML!
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.
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.
>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)
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)
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
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
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.
how does it implement clojure's lazy sequences? does it manage to map them to generators?
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.
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.
i have no idea how clojure is implemented, but i guess i always assumed that they were implemented as iterators.
oh JVM startup time isn't that terrible, but this is cool.
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.
JVM startup time is terrible, compared to the alternatives.
On the other hand, I've been wanting to learn Clojure. It'd be nice to see this project mature.