|Mentor||Russell Keith-Magee (freakboy3742)|
|Suitable for Beginners?||yes|
|Tags||python java android|
|Applications (1st Choice)||7 (7 submitted | 0 in-progress)|
|Applications (2nd Choice)||3 (3 submitted | 0 in-progress)|
|Code of Conduct||/projects/85-voc|
VOC is a transpiler that takes Python 3.4 source code, and compile it into a Java class file that can then be executed on a Java Virtual Machine. It does this at the bytecode level, rather than the source code level.
You can use VOC anywhere that provides a Java runtime environment, but you want to write your logic in Python. For example:
- Writing Android applications
- Writing Lucene/ElasticSearch custom functions
- Writing Minecraft plugins
- Writing web applications to deploy in a J2EE container
In each of these cases, the project provides a Java (or Java-like, in the case of Android) environment. While some bridging might be possible by using JNI, or by writing a thin Java program that calls out to another language environment, these approaches mean you’re developing a plugin at arms length.
The VOC approach allows you to develop your Python application as if it were native. The class files even have references to the Python source code, so when a stack trace is generated, it will tell you the line of Python source that caused the problem.
Contributing to VOC is a task well suited to beginners. The core part of VOC is a standard library that reproduces the behavior of Python in a Java runtime environment. This means there is a clear test case (does the Java behavior match Python behavior), and in most cases, the implementation required is relatively simple. VOC currently has a test suite of over 3000 tests, most of which are currently failing awaiting implementation of some part of the standard library.
There is also a number of more complex problems that an experienced developer might be able to tackle.
The VOC project has a history of mentoring first-time contributors - there is an an open offer to mentor anyone who wants to be a contributor.
Tasks And Features
Some suggestions for possible projects, in rough order of complexity:
Implement operations on standard types: Every Python data type requires an implementation in Java, including an implementation of all basic operations. For example, Python allows multiplication of strings by integers to produce a repeated string; Java does not. Pick a data type, and implement all the basic mathematical operations for that type.
Implement methods on standard types: Each builtin Python data type has a set of standard operations - for example, you can use
str.upper()to turn a String into upper case. Pick a data type, and implement all the standard methods that Python provides on that type.
Implement the builtins module: Python has a number of builtin functions like
list(), and so on. These builtin methods need to be implemented.
Implement the Python standard library: Python has an extensive standard library; a Java-compatible version of this standard library must be written.
Use a single Java session for tests: The current test suite takes almost 40 minutes to run. This is mostly due to the startup time of the JVM - each test starts a fresh JVM. To speed up the test suite, a single JVM session should be used for the entire test suite.
Use a hidden name for python functions: The auto-generated names could potentially cause collisions in the Java namespace. This could be avoided by using hidden names for some symbols.
Use type information to optimize code paths: VOC currently uses a naive (and quite wasteful) approach to object management that results in a large number of objects being created and destroyed. It should be possible to use type information to
Add Stack Maps to generated Java classfiles: Java 6 introduced a new feature to the Java bytecode format - Stack Map Frames. These aren't required to run Java, but would be nice to have as they have optimization benefits for the JVM at runtime.
You must be logged in to comment on this project.
Laura RGSoC, Saturday, January 30, 13:31 UTC
thank you for your submission! We think this is a great (albeit challenging) project to have for our RGSoC. We're also very happy about the open offer for mentoring, and we think this aligns super well with our values :)
Really looking forward to having the project on board. 🎉