[Mobile-sig] Experiments with Dalvik
david at boddie.org.uk
Tue May 17 12:05:51 EDT 2016
In a belated attempt to jump on the Android bandwagon I started to look
into learning Java and the Android APIs. I realised very quickly that I
couldn't face writing a lot of code in that language. Looking around for
other languages running on the Dalvik VM, I found a few that might be nicer
than Java, but I wasn't so sure that I wanted to write in any of those,
In the end, I decided to try an experiment to see how much I could learn
about Dalvik and Java by creating tools to handle some of the file formats
used in Android packaging, and by trying to implement a compiler for a subset
The result can be found in this repository:
It should be noted that the source language isn't really Python. The parser
from the standard library is used to parse it, but the semantics of the
generated code are different to those of Python. That's why I gave the
language a different name.
How is this relevant to a mailing list about Python on mobile platforms?
Firstly, the language may be close enough to Python for people to find it
more familiar than Java, even if there are places where the differences may
trip them up. Writing code to fit into a framework designed for a statically
typed language requires a slightly different mindset to the one you might
have when writing regular Python code, so it may not seem so strange to
developers once they've accepted that.
Secondly, it makes it possible to write a more faithful implementation of
Python using code that looks a lot like Python, instead of Java. You could
use it to write support code for a compiler, or perhaps write an interpreter
It's all very experimental at the moment. I've been uncomfortable about
publishing it before now because I keep finding things I've overlooked,
though it's been a good learning experience. Maybe there will be things in
there that people find useful.
More information about the Mobile-sig