
VOC: A transpiler that converts Python bytecode into Java bytecode - Lofkin
https://github.com/pybee/voc
======
skrebbel
> _The Vereenigde Oostindische Compagnie (VOC), or Dutch East India Company,
> is often considered the be the world 's first multinational corporation.
> ..._

Ah, trivia time! The VOC also had the world's first entirely privatized army.
The "monopoly" cited in the README basically included a license to kill. Think
"Google Armed Forces", but then scarier. The army was mostly used to keep a
grumpy unpaid workforce "motivated", to keep the spice coming, and thus to
keep that lovely 18% annual dividend payout reality.

Basically, the VOC made current evil multinational corps (e.g. the oil
companies, monsanto, blackwater, etc) look like cute cuddly charities.

That said, it's been centuries, not sure getting worked up about the name
makes sense now. It's a compiler, not a guidebook about how to traffic humans.
I just thought the README section made the VOC seem a "little" awesomer than
they were.

~~~
throwawayaway
Britain had an East India Company first:

[https://en.wikipedia.org/wiki/East_India_Company_%28disambig...](https://en.wikipedia.org/wiki/East_India_Company_%28disambiguation%29)

[http://www.newstatesman.com/politics/politics/2014/04/worlds...](http://www.newstatesman.com/politics/politics/2014/04/worlds-
first-multinational)

It's up for debate who was the first multinational. No doubt both set the bar
very high for those to follow, but I do think blackwater spinoff dyncorp with
child sex slaves will take some beating, particularly with respect to the
prevailing moral climate of the time:

[https://en.wikipedia.org/wiki/DynCorp#Bosnia_incidents](https://en.wikipedia.org/wiki/DynCorp#Bosnia_incidents)

~~~
pjmlp
> Britain had an East India Company first:

Actually the Portuguese one was founded in 1549, but I will leave out the
usual type of "products" that were traded in those days.

------
fijal
So well, one interesting question as to why this is at the top of hackernews
is - do people not know about jython? Jython does exactly that - it compiles
python into java (I think it emits bytecode and not Java source, but don't
call me on that) with a lot of runtime so it can support proper semantics. It
has been around for over a decade now too and it supports full python (with
usual caveats)

~~~
jestar_jokin
Jython is quite outdated and has stagnated for a long time; support for Python
2.7 was only finalised in May this year. Forget about support for v3.5.

Perhaps by compiling from the bytecode of the existing interpreter, instead
writing a whole new source code interpreter for the JVM, it will have some
benefits in supporting newer versions of the language. Or, maybe it will help
to decouple development of the standard library and the interpreter, possibly
letting more devs work on it. You can't really be sure what
benefits/deficiencies a different approach will bring until you actually try
it - see PyPy, a "silly" idea to implement Python in Python, which now yields
faster runtime performance than CPython.

~~~
techdragon
This is exactly why I spent a few hours trying to work out if I could perform
some advanced trickery to plumb the pypy tool chain into something that would
end up producing a pypy.jar or other JVM equivalent. Turns out it's not that
easy. C to JVM isn't a well trodden path.

Jython is awesome and all but its fighting an uphill war against rapid
progress in 3 with far too few resources.

~~~
pjmlp
> C to JVM isn't a well trodden path.

But it does exist.

[https://wiki.openjdk.java.net/display/Graal/Publications+and...](https://wiki.openjdk.java.net/display/Graal/Publications+and+Presentations)

Check "Truffle C: Dynamic Execution of C on the Java Virtual Machine."

------
Animats
How are the differences in the execution model handled? The defining quality
of Python execution is that anything can monkey-patch anything at any time,
using "setattr()". This means the obvious implementation has dictionaries for
everything, and optimizers, as in PyPi have to work very, very hard.

So what did they do here? Is every object a dictionary to the Java runtime?
That's easy enough to do, but no gain over CPython. Did they weaken the
ability to modify objects so they could map to Java objects? That gets a
performance win, as with Shed Skin, but a lot of Python code won't work.
They're probably not doing all the stuff PyPi does; that's hard and took a
decade of work by many people.

------
drxzcl
Did they really have to drag the Dutch east India company into this by using
that logo? It's going to make things... complicated around here.

~~~
ForHackernews
I'm kind of shocked that people here immediately recognize the logo for
company that (according to wikipedia) stopped existing in 1799.

~~~
DasIch
The VOC is important enough that you will learn about it in history classes in
school, at least in some countries.

------
pacala
This can be very useful. I wonder what the plans are for supporting C apis,
given that a lot of Python core libraries depend on C, in my neck of the woods
numpy and scipy being the first contenders. There are long running projects
[http://www.jython.org](http://www.jython.org) and
[http://www.jyni.org](http://www.jyni.org), which, to the best of my
knowledge, have not yet managed to fully support Python C extensions on the
JVM.

~~~
the8472
They could run the C extensions on the JVM too, like the experimental jruby
truffle backend does.

[http://chrisseaton.com/rubytruffle/cext/](http://chrisseaton.com/rubytruffle/cext/)

~~~
glibgil
A Python and Truffle implementation already exists
[https://bitbucket.org/ssllab/zippy](https://bitbucket.org/ssllab/zippy)

------
empyrical
They also have an in-browser bytecode runner:
[https://github.com/pybee/batavia](https://github.com/pybee/batavia)

------
hristov
That is called a compiler.

~~~
poizan42
Transpilers are compilers... The term is usually used for a compiler which
compiles between languages at about the same level of abstraction.

~~~
cwp
The term is usually used by people that don't know what compilers are.

Snark aside, I think this is actually the case. I bet there are a LOT of
CoffeeScript/Javascript developers who have never worked in a compiled
language.

------
alexanderdaw
Can someone give a valid reason for wanting this? I'm kind of confused as to
why mixing and matching python and java source with some central compiler
would be useful.

~~~
DasIch
Just for fun? To take advantage of the Java ecosystem similarly to Jython?

------
stuaxo
Cool does this work on android ?

~~~
stuaxo
[EDIT] - I should have wrote, can this generate code that will work on Android
? [/EDIT]

------
shuri
performance?

~~~
grhmc
question?

