Live data from Hacker News

Clojure Implemented in Pure Python

github.com

41–50 of 56 posts

Re: Clojure Implemented in Pure Python

#41
post #39
post #35

Earlier quoted context omitted.

I dougth CL-Clojure is faster then pypy-Clojure.

Why? CL compilers (SBCL at least) generate really fast code.

It does not matter with how good a compiler you compile an interpreter it stays an interpreter. With Pypy you get a JIT Compiler. Sure you could maybe write a JIT with CL but thats a lot more work.

Re: Clojure Implemented in Pure Python

#42
post #41
post #39

Earlier quoted context omitted.

Why? CL compilers (SBCL at least) generate really fast code.

It does not matter with how good a compiler you compile an interpreter it stays an interpreter. With Pypy you get a JIT Compiler. Sure you could maybe write a JIT with CL but thats a lot more work.

I don't understand. Do you mean that you can't compile Clojure into Common Lisp the way you can compile it into Python/PyPy?

Re: Clojure Implemented in Pure Python

#43
post #41

Earlier quoted context omitted.

It does not matter with how good a compiler you compile an interpreter it stays an interpreter. With Pypy you get a JIT Compiler. Sure you could maybe write a JIT with CL but thats a lot more work.

I don't understand. Do you mean that you can't compile Clojure into Common Lisp the way you can compile it into Python/PyPy?

You can, but I think you'd run into the same issues mentioned here: http://clojure-py.blogspot.com/2012/02/ive-been-asked-many-t...

Basically it reflection (aka dynamic dispatch) is a major performance killer if you don't implement a tracing jit.

Re: Clojure Implemented in Pure Python

#44
post #38
post #29

Earlier quoted context omitted.

I agree. Native access to legacy linear algebra functionality exposed by Numpy is the #1 reason this project seems exciting to me. I don't really care if the bulk of the code is O(10) slower so long as the numerical bits are O(1000) faster, which is a typical comparison of LAPACK for the JVM equivalents.

(Pedant warning) I think you may be abusing Big-O notation a little here since, technically O(10) is equivalent to O(1000)—and both are O(1).

It's fairly clear in the context that he's using O(x) in the informal 'order of' meaning: 'order of 10', 'order of 1000' etc.

Re: Clojure Implemented in Pure Python

#45
post #36
post #26

Earlier quoted context omitted.

PyClojure (in the link) didn't actually take it to the extent we are. clojure-py goes so far as to implement all the standard collections in pure python. So [1 2 3] in clojure-py is a PersistentVector not a python list.

Why? If your going to rewritte the collections, why not in Clojure? Speed?

Mostly because we have to have these collections inside the compiler. So it's a bit hard to write collections in a language that has no compiler. Chicken/egg issue..

Re: Clojure Implemented in Pure Python

#46

Please remember kids, language X implemented in language Y, probably means language X > language Y. (And if you question this, first implement a small, elegant language, and a large "pragmatic" one and then talk to me about it.)

What do you mean by "language X > language Y"?

It means that after cast language X and language Y to an int value language X is greater than language Y (that's my understanding).

Re: Clojure Implemented in Pure Python

#47
post #18

Earlier quoted context omitted.

First of all, it should be mentioned, that this is not an abstraction layer. Clojure-py functions are actual Python functions (not classes as they are on the JVM). This means that the speed of clojure-py is almost exactly the same as python code. Secondly, there is some benifit to not having to worry about static typing in a dynamic language. Anyone want to explain how to read a binary file in Clojure? Here's a hint,…

Ok, what's the use case? What is the benefit to this versus regular ol' Python? In what situations might I write clj-py assumine identical performance to Cpython or pypy, instead of just Python? I agree that this is a really cool project and I plan on reading through the source when I have time strictly as a learning exercise, but I cannot think of a use case.

If nothing else lispreader.py will be useful for reading Clojure data in Python. Think communicating with nREPL and reading the forms that come back

Re: Clojure Implemented in Pure Python

#48
post #38
post #29

Earlier quoted context omitted.

I agree. Native access to legacy linear algebra functionality exposed by Numpy is the #1 reason this project seems exciting to me. I don't really care if the bulk of the code is O(10) slower so long as the numerical bits are O(1000) faster, which is a typical comparison of LAPACK for the JVM equivalents.

(Pedant warning) I think you may be abusing Big-O notation a little here since, technically O(10) is equivalent to O(1000)—and both are O(1).

Haha, thanks for the warning. I am reminded of another time I ended up abusing the Landau notation in a numerical analysis class ( was it probability?) some years ago. The homework was to get and N^2log(N) algorithm of some kind, but I became concerned about certain large constant factors which I could determine exactly. However, these constant factor could be written as a series in another parameter, which I couldn't approximate in a certain limit and... well, you see where I'm going. There where lots of O's with slightly different semantics on the same paper.

Re: Clojure Implemented in Pure Python

#49
post #43

Earlier quoted context omitted.

I don't understand. Do you mean that you can't compile Clojure into Common Lisp the way you can compile it into Python/PyPy?

You can, but I think you'd run into the same issues mentioned here: http://clojure-py.blogspot.com/2012/02/ive-been-asked-many-t... Basically it reflection (aka dynamic dispatch) is a major performance killer if you don't implement a tracing jit.

Wouldn't SBCLs type inference(+ type hints) help with this? I'm no compiler expert, but i think clojure(with the possible exception of multimethods, which are slow even on the JVM) would map well to CL(maybe even better than the JVM).

Re: Clojure Implemented in Pure Python

#50
post #41

Earlier quoted context omitted.

It does not matter with how good a compiler you compile an interpreter it stays an interpreter. With Pypy you get a JIT Compiler. Sure you could maybe write a JIT with CL but thats a lot more work.

I don't understand. Do you mean that you can't compile Clojure into Common Lisp the way you can compile it into Python/PyPy?

PyPy is not just an Python-Interpreter. The PyPy Team build a Toolchain that can creat a JIT-Compiler out of a Interpreter (read some about the pypy project and you will be enlightened. Such a Toolchain does not exist for Common Lisp.
Post reply on HN