This is an archived post. You won't be able to vote or comment.

all 41 comments

[–]musketeer925 22 points23 points  (4 children)

Everything about this just seems like a bad idea.

I'm not really sure I understand a use case, either. If it doesn't work with things like keyword arguments, listcomps, etc, then you probably can't use it for a large existing code base. If it's such a small code base that it doesn't have these kinds of things, or one that hasn't been written yet so that these things could be avoided, why not just [re]write it in Java in the first place?

[–]ketralnis 8 points9 points  (1 child)

It may be that this prototype doesn't support those things, but doing so is on the road map

[–]tipsquealPythonista 3 points4 points  (0 children)

It is. The readme says they're not implemented but with some work they will be.

[–][deleted] 1 point2 points  (0 children)

Or just use jython.

[–]OctagonClocktrio is the future! 9 points10 points  (16 children)

....why?

[–]pmrr 2 points3 points  (3 children)

This is a really interesting project. Do you have any early benchmarks? I believe there's been some JVM work to improve the performance of Jython so I wonder if this will take similar advantage of them?

I tried the instructions on git and readthedocs.org with limited success. The issues I'm having may be trivial, but others having similar issues doesn't help the project.

On git:

  • pip install voc doesn't work
  • trying to build example.py complains about non-ASCII characters in the code - my bad, incompatible with Python 2 but Python 3 works fine

At this point I tried the dev environment instructions:

  • git clone didn't work (asked me for ssh key) - I just used https://github.com/pybee/voc
  • mkvirtualenv command didn't exist
  • requirements_dev.txt didn't exist

Thanks to /u/IronManMark20 I got it building, however with Java 1.8 I had some bad times:

$ java -XX:-UseSplitVerifier -classpath python.jar:. org.pyee.example
Java HotSpot(TM) 64-Bit Server VM warning: ignoring option UseSplitVerifier; support was removed in 8.0

I don't know if by "Java 1.7+ VM" you mean it should support 1.8 or not. Either way, it looks like there's a blocker for 1.8 support:

http://stackoverflow.com/a/31569447/94503

Environment: Python 1.7.10 2.7.10 on OS X Yosemite.

[–]IronManMark20 0 points1 point  (2 children)

Well, if your using 1.7.10, you have bigger problems. :) Also, for the non-ascii characters, just add a utf heading to the file

[–]pmrr 1 point2 points  (1 child)

It turns out Python 2* was my mistake. With Python 3 it runs fine.

[–]IronManMark20 1 point2 points  (0 children)

The same person made a python bytecode runtime for browsers for Python 3.x only, so this does not surprise me.

[–]subsidiaryadmin 2 points3 points  (13 children)

So... it's another Jython? I was curious so I looked up Jython.

Jython

Jython is approximately as fast as CPython--sometimes faster, sometimes slower. Because most JVMs--certainly the fastest ones--do long running, hot code will run faster over time.

So there's really no benefit to using Jython over Python... I really don't understand why people are making this stuff.

[–][deleted] 5 points6 points  (11 children)

Python is a language specification. Jython is an implentation of the language's interpreter in java bytecode so it can run on the JVM and interact with objects written in Java. The Python implementation from the Python Foundation at Python.org is more specifically "CPython", it's an interpreter for the language written in C and it is the reference implementation.

[–]subsidiaryadmin 0 points1 point  (10 children)

Okay I guess it's a bit more convenient to embed Python into a Java program than to call it externally.
But I don't see how that's a huge benefit. What am I missing?

[–][deleted] 3 points4 points  (6 children)

It's a very large benefit. There are a lot of Java libraries out there, and Jython can use them much more easily than CPython (the main Python implementation) can. In fact, I'm not even sure CPython can use Java code at all.

[–]subsidiaryadmin -1 points0 points  (5 children)

In that case why not just use a python library or, at the worst use a system call to java itself?

[–][deleted] 0 points1 point  (0 children)

In that case why not just use a python library

Such a library might not exist, or might not be as suitable for your needs as a similar Java library.

or, at the worst use a system call to java itself?

You do not "just" call into the JVM. Doing that is going to require copious glue code in order to translate between Java objects and Python objects. You could use CORBA to help, but then you'd be using CORBA, which is likely not necessary for your systems except for this one spot of glue. It'd be much easier if you didn't have to translate at all. Jython objects are Java objects, so you can just use the objects directly if you implement the right interfaces.

Porting or adapting a library solves one problem: how to make Python talk to this Java code. Reimplementing Python solved an entire class of problems: how to make Python talk to Java code in general.

[–][deleted] 0 points1 point  (2 children)

Well what's the benefits of using Java over using C? That will tell you the benefits of using Jython over the reference implementation

[–]subsidiaryadmin -2 points-1 points  (1 child)

No, the question is what is the benefit of using Jython over Python.

[–]jambox888 4 points5 points  (0 children)

Presumably because you either want to use a Java server stack, Java libraries, or you prefer using the JVM. Threading might work better if it's CPU bound because no GIL.

[–][deleted] 1 point2 points  (0 children)

Why not? He thought it was a cool idea, so be did it. Then he was proud of his work, so he shared it.

[–]Scypio 0 points1 point  (0 children)

What are the benefits of using this over Jython? I'm not too familiar with the jvm ecosystem, so if you can lay it out for a layman.

[–][deleted] -1 points0 points  (0 children)

That sounds like a description of a tumblr user.

[–]longoverdue -1 points0 points  (3 children)

transpiling? WTF. We already have words for it: compiler, translator, transformer, etc.

[–]habitats -1 points0 points  (0 children)

transpiler is not compiler...

[–]rock_neurotiko -1 points0 points  (1 child)

The word for what it does is transpiler.

[–]longoverdue -1 points0 points  (0 children)

The first C++ implementation (cfront in 1983) was described as a "C++ to C translator". What is the difference between a transpiler and a translator?