Re:Python becomes a platform. Thoughts on the release of clo...
by agentultra on Thursday March 15, 2012 @12:32PM
(#3709181)
The idea of a python implementation becoming host to other languages is somewhat interesting. Python has had a good interop story with the vibrant ecosystem of C libraries and is pretty good at being cross-platform as well.
However, I'm not sure Clojure is going to impress Python developers for the reasons the author states. Python has metaprogramming and it has an immutable type (the tuple). However, Python has rejected functional purity for pragmatism so I'm not sure there will be a great many Python developers suddenly switching to clojure. It's generally not the implementation that impresses Python developers the most AFAIK -- it seems that most Pyhtonista's like the language more than anything.
That being said I'd be interesting to see how far clojure-py goes. Pypy is the ideal implementation for this sort of project as they're aiming to be a JVM-like platform for dynamic languages.
Re:Python becomes a platform. Thoughts on the release of clo...
by whateverer on Thursday March 15, 2012 @12:36PM
(#3709205)
Users of a host platform are almost never the target of a port such as this. ``Pythonistas'' are not the audience here, it's Clojure programmers who wish to sneak Clojure in a Python environment or use its libraries in lieu of Java's.
Also, I must add that I really dislike the use of the word ``pragmatism'' in the context of a programming language. It almost always is used to justify either sloppiness, misunderstanding or just plain (and save for the word, valid) aesthetic preference.
Re:Python becomes a platform. Thoughts on the release of clo...
by CPlatypus on Thursday March 15, 2012 @01:05PM
(#3709340)
Fair point about "pragmatism" but the contrary "elegance" often comes across as dogmatic or even elitist. Most languages strive for both pragmatism and elegance, but tend to favor one a little over the other.
And yes, this is relevant since Python and Clojure embody exactly this kind of tension.
Re:Python becomes a platform. Thoughts on the release of clo...
by whateverer on Thursday March 15, 2012 @01:24PM
(#3709445)
I guess one could pinpoint it to the clashing of the traditions of pure mathematics and engineering which one finds in Computer Science.
Elegance is an often trotted epithet in mathematical writing, and sure, it has some sort of established connotation (minimalism, what we call orthogonality, etc.), but in the end it's almost always something like "it has sugar, and marmalade, and skittles and ketchup! All my favorite ingredients! I'm very glad they didn't put that icky caramel stuff in it".
Anyhow, Clojure sports a fair bit of ``pragmatism'' with its own, very leaky sequence abstraction, as you sometimes feed a vector to a function and you get a linked list and next thing you know, your head has been put in your ass (when you conj/cons an element to a sequence).
Lisp has also always leaned to a sort of messiness in its use, even if the language's features and libraries are held to a higher standard. Thus you see phrases like ``ball of mud'' used in a subtly positive way.
Re:Python becomes a platform. Thoughts on the release of clo...
by eric_bullington on Thursday March 15, 2012 @12:47PM
(#3709257)
As a Python programmer, I agree with most of your assessment. Most Pythonistas I know have chosen Haskell as their primary functional language (and Haskell is the PL I'm constantly working on mastering).
But this clojure-py project is very interesting to me. I've heard so many positive things about Clojure and Lisp in general. I've been wanting to explore Clojure, but I've been holding off because I knew I would need to become more familiar with the Java infrastructure to learn Clojure well, and learning the JVM is one challenge I just don't feel like tackling at this point in my life.
On the other hand, I love PyPy, and I've been fascinated by the progress in performance the PyPy team has been making. I'm even hoping to eventually implement a version of CoffeeScript on PyPy. Given my Python background and interest in PyPy, Clojure now seems much more approachable thanks to this implementation. I'll probably wait until it's a little more mature, but I look forward to trying clojure-py out!
Re:Python becomes a platform. Thoughts on the release of clo...
by cabalamat on Thursday March 15, 2012 @10:22PM
(#3711649)
> Most Pythonistas I know have chosen Haskell as their primary functional language (and Haskell is the PL I'm constantly working on mastering).
I'm currently learning Haskell too. My ideal functional language would be one similar to Haskell which runs on the Python VM and has good interoperability with Python.
Re:Python becomes a platform. Thoughts on the release of clo...
by vutekst on Thursday March 15, 2012 @12:36PM
(#3709202)
Clojure is not a purely functional language either. You can have side-effects anywhere, it's just that Clojure emphasizes immutable, persistent data structures.
Re:Python becomes a platform. Thoughts on the release of clo...
by DanWaterworth on Thursday March 15, 2012 @02:34PM
(#3709869)
Python has a quite a few immutable types, tuple, string, none, boolean, int, float, but they are all primitive types. Some of Clojure's immutable types are much more interesting, like the finger tree for example.
In a few years clojurers/lispers will be able to target multiple platforms with one simple language.
As a pythonista myself, I used to feel overcome with nausea just by looking at Clojure/Lisp code. However, Erlang was my gateway drug into the functional/bizarre-syntax world and now, after a few weeks (and two books) with Clojure I'm having a bit of an identity crisis: my brain simply refuses to touch messy-non-Lisp code ever again.
Re:Python becomes a platform. Thoughts on the release of clo...
by tree_of_item on Thursday March 15, 2012 @04:48PM
(#3710521)
Joxa is not Clojure. From joxa.org:
> Joxa (pronounced 'jocksah') isn't Erlang, though its very compatible. Its not Clojure though there is plenty of shared syntax. It's not Common Lisp though that is the source of the macro system. While Joxa shares elements of many languages, it is its own specific language. of all these languages, and knowing these languages will help you get up to speed with Joxa, but it is its own unique language.
Re:Python becomes a platform. Thoughts on the release of clo...
by cabalamat on Thursday March 15, 2012 @10:31PM
(#3711673)
> In a few years clojurers/lispers will be able to target multiple platforms with one simple language.
I doubt it, unless either their code doesn't use any external libraries, or Clojure writes a library abstraction layer containing all the Java/Python/etc libraries.
Re:Python becomes a platform. Thoughts on the release of clo...
by rlander on Thursday March 15, 2012 @11:16PM
(#3711788)
I did not mean to imply that Clojure code would be portable across runtimes (though it is a possibility).
I meant that things like ClojureScript One (if you don't know it, please take a look, it's worth it) will be possible across a variety of domains. Simple interoperability between platforms, same data structures, fewer context switches, Clojure all the way down.
Re:Python becomes a platform. Thoughts on the release of clo...
by lightcatcher on Thursday March 15, 2012 @04:33PM
(#3710456)
Sadly, I believe all of these ports run slightly different dialects of Clojure (beyond the things that must be different, like interacting with code written in other languages).
Re:Python becomes a platform. Thoughts on the release of clo...
by swannodette on Thursday March 15, 2012 @04:42PM
(#3710495)
ClojureCLR and ClojureScript are not Clojure dialects - they are Clojure implementations. I'm not sure what the creators of clojure-py intend and Joxa is not Clojure as far as I can tell.
Re:Python becomes a platform. Thoughts on the release of clo...
by rlander on Thursday March 15, 2012 @04:31PM
(#3710440)
Yeah, I started with TJoC, but it felt like watching a movie before reading the book: it's fun, but you miss many of the insights that went into producing the movie.
So I backed up, practiced some (koans, 4clojure, Euler), read Stuart Sierra's Programming Clojure and then read TJoC. Both excellent books, btw.
Re:Python becomes a platform. Thoughts on the release of clo...
by daviddaviddavid on Thursday March 15, 2012 @01:43PM
(#3709562)
I'm not sure why the author would say that metaprogramming is "absent" from Python.
Do decorators and metaclasses not count as metaprogramming features? I'm sure that languages in the Lisp family might be better suited for metaprogramming than Python but the author's claim seems straightforwardly false.
Re:Python becomes a platform. Thoughts on the release of clo...
by DanWaterworth on Thursday March 15, 2012 @02:37PM
(#3709886)
> "Do decorators and metaclasses not count as metaprogramming features?"
Not when compared to macros in lisp dialects. The closest python comes is: http://docs.python.org/library/ast.html but lisp with it's simple structure is much less unwieldy.
Re:Python becomes a platform. Thoughts on the release of clo...
by kibwen on Thursday March 15, 2012 @12:16PM
(#3709101)
I'm curious, can PyPy JIT-compile Python bytecode by itself, or does it require the source to be in Python? Because it would be really cool if you could target the Python "platform" and get a free JIT as well.
Edit: Nevermind, just read the project readme[1] where they explicitly mention targeting PyPy as a goal.
Re:Python becomes a platform. Thoughts on the release of clo...
by masklinn on Thursday March 15, 2012 @12:46PM
(#3709256)
> I'm curious, can PyPy JIT-compile Python bytecode by itself, or does it require the source to be in Python?
Considering you can run bytecode-only Python, it would be weird if Pypy's JIT only worked from source.
Beyond that, they're apparently implementing Clojure on top of (in) Python, so they won't get the JIT for free (the interpreter code will be JITed, but the Clojure code won't be unless their runtime compiles to Python bytecode which does not seem to be the case). They'd get it for free if they implemented a Clojure in RPython as well, but would leave the Python ecosystem behind.
Re:Python becomes a platform. Thoughts on the release of clo...
by obtu on Thursday March 15, 2012 @01:09PM
(#3709362)
From the article
> clojure-py is an implementation of the Clojure language in Python, compiling Clojure code to bytecode for Python’s virtual machine
Which means both the compiler (mostly an AST walk from the look of clojure/lang/compiler.py) and the Python bytecode it produces should benefit from PyPy's JIT.
Re:Python becomes a platform. Thoughts on the release of clo...
by halgari on Thursday March 15, 2012 @04:47PM
(#3710517)
This is very correct. We compile Clojure code to Python bytecode. Clojure functions become python functions, clojure deftypes are Python classes, Clojure namespaces are Python modules. And yes, it runs perfectly well on PyPy. Actually it sometimes runs a bit better. CPython segfaults with bad bytecode sequences (unbalanced stacks). PyPy actually throws an error so you can fix the code.
Re:Python becomes a platform. Thoughts on the release of clo...
by zem on Thursday March 15, 2012 @04:10PM
(#3710347)
Interestingly, when I saw the release announcement a week or so ago, I thought "neat, but I can't think of any use I'd have for it". And then yesterday I ran across SimpleCV [http://simplecv.org/] and realised I could potentially use it from clojure, which would be really nice. There really is a lot of nice scientific/visualisation work going on in the python community and it is great to have access to it from clojure.
Re:Python becomes a platform. Thoughts on the release of clo...
by aklein on Thursday March 15, 2012 @10:13PM
(#3711625)
"Clojure is strong in two areas in which Python isn’t. One of them is metaprogramming, a feature absent from Python which Clojure had from the start through its Lisp heritage."
Re:Python becomes a platform. Thoughts on the release of clo...
by beza1e1 on Thursday March 15, 2012 @05:28PM
(#3710713)
Last time i looked the Python bytecode was not considered stable. This means, Python devs might change syntax and semantics in minor version changes. This would be a major problem for clojure-py.
Re:Python becomes a platform. Thoughts on the release of clo...
by exupero on Thursday March 15, 2012 @04:56PM
(#3710551)
I've used Clojure on and off but never really learned enough Java to be comfortable with it. Clojure-py has been a lot more fun because I can use the Python libraries I'm already familiar with.
However, I'm not sure Clojure is going to impress Python developers for the reasons the author states. Python has metaprogramming and it has an immutable type (the tuple). However, Python has rejected functional purity for pragmatism so I'm not sure there will be a great many Python developers suddenly switching to clojure. It's generally not the implementation that impresses Python developers the most AFAIK -- it seems that most Pyhtonista's like the language more than anything.
That being said I'd be interesting to see how far clojure-py goes. Pypy is the ideal implementation for this sort of project as they're aiming to be a JVM-like platform for dynamic languages.
Also, I must add that I really dislike the use of the word ``pragmatism'' in the context of a programming language. It almost always is used to justify either sloppiness, misunderstanding or just plain (and save for the word, valid) aesthetic preference.
And yes, this is relevant since Python and Clojure embody exactly this kind of tension.
Elegance is an often trotted epithet in mathematical writing, and sure, it has some sort of established connotation (minimalism, what we call orthogonality, etc.), but in the end it's almost always something like "it has sugar, and marmalade, and skittles and ketchup! All my favorite ingredients! I'm very glad they didn't put that icky caramel stuff in it".
Anyhow, Clojure sports a fair bit of ``pragmatism'' with its own, very leaky sequence abstraction, as you sometimes feed a vector to a function and you get a linked list and next thing you know, your head has been put in your ass (when you conj/cons an element to a sequence).
Lisp has also always leaned to a sort of messiness in its use, even if the language's features and libraries are held to a higher standard. Thus you see phrases like ``ball of mud'' used in a subtly positive way.
But this clojure-py project is very interesting to me. I've heard so many positive things about Clojure and Lisp in general. I've been wanting to explore Clojure, but I've been holding off because I knew I would need to become more familiar with the Java infrastructure to learn Clojure well, and learning the JVM is one challenge I just don't feel like tackling at this point in my life.
On the other hand, I love PyPy, and I've been fascinated by the progress in performance the PyPy team has been making. I'm even hoping to eventually implement a version of CoffeeScript on PyPy. Given my Python background and interest in PyPy, Clojure now seems much more approachable thanks to this implementation. I'll probably wait until it's a little more mature, but I look forward to trying clojure-py out!
I'm currently learning Haskell too. My ideal functional language would be one similar to Haskell which runs on the Python VM and has good interoperability with Python.
Immutable? Could you explain this a bit more? (As far as I know, "x += 1" will modify the block of memory that x points to)
As a pythonista myself, I used to feel overcome with nausea just by looking at Clojure/Lisp code. However, Erlang was my gateway drug into the functional/bizarre-syntax world and now, after a few weeks (and two books) with Clojure I'm having a bit of an identity crisis: my brain simply refuses to touch messy-non-Lisp code ever again.
> Joxa (pronounced 'jocksah') isn't Erlang, though its very compatible. Its not Clojure though there is plenty of shared syntax. It's not Common Lisp though that is the source of the macro system. While Joxa shares elements of many languages, it is its own specific language. of all these languages, and knowing these languages will help you get up to speed with Joxa, but it is its own unique language.
I doubt it, unless either their code doesn't use any external libraries, or Clojure writes a library abstraction layer containing all the Java/Python/etc libraries.
I meant that things like ClojureScript One (if you don't know it, please take a look, it's worth it) will be possible across a variety of domains. Simple interoperability between platforms, same data structures, fewer context switches, Clojure all the way down.
[1] From the website: "[Joxa's] not Clojure though there is plenty of shared syntax."
So I backed up, practiced some (koans, 4clojure, Euler), read Stuart Sierra's Programming Clojure and then read TJoC. Both excellent books, btw.
All 100 of them (Clojurers)?
Do decorators and metaclasses not count as metaprogramming features? I'm sure that languages in the Lisp family might be better suited for metaprogramming than Python but the author's claim seems straightforwardly false.
Not when compared to macros in lisp dialects. The closest python comes is: http://docs.python.org/library/ast.html but lisp with it's simple structure is much less unwieldy.
Edit: Nevermind, just read the project readme[1] where they explicitly mention targeting PyPy as a goal.
[1] https://github.com/halgari/clojure-py
Considering you can run bytecode-only Python, it would be weird if Pypy's JIT only worked from source.
Beyond that, they're apparently implementing Clojure on top of (in) Python, so they won't get the JIT for free (the interpreter code will be JITed, but the Clojure code won't be unless their runtime compiles to Python bytecode which does not seem to be the case). They'd get it for free if they implemented a Clojure in RPython as well, but would leave the Python ecosystem behind.
> clojure-py is an implementation of the Clojure language in Python, compiling Clojure code to bytecode for Python’s virtual machine
Which means both the compiler (mostly an AST walk from the look of clojure/lang/compiler.py) and the Python bytecode it produces should benefit from PyPy's JIT.
Absent is too strong a word, surely.
http://bitshaq.com/2011/07/14/basic-intro-to-python-meta-pro...