Whiley gets Rusty!
I’ve been learning Rust for a while now but, at the same time, trying to continue developing Whiley. Since Whiley was written entirely in Java, these activities were mutually exclusive and it was frustrating trying to balance things! One day I’d had enough … so I decided to rewrite part of the Whiley compiler in Rust. This is not as dramatic as it sounds, and I’m not planning to rewrite the whole compiler in Rust (yet). That would be a lot of work. However, bringing these things together means I can learn Rust and work on Whiley at the same time. Its actually working out pretty well!
An unexpected benefit of working with Rust is that it makes distributing Whiley quite easy. Installing Whiley through Cargo is really simple:
cargo install whiley
Assuming you have Java installed, you can just run
wy --help and see
the options for building Whiley programs. For example, we can
initialise and then build a new project like so:
> wy init > wy build > wy run Hello World!
This is pretty neat!
What we see in the diagram is that the
orchestrates the plugins, and it is this component that I have
rewritten in Rust. Roughly speaking, the build tool downloads the
jar files representing the plugins from Maven central as needed and
fires up a JVM instance to run them. Its pretty simple, and it works
Another interesting opportunity here is that I can incrementally rewrite the compiler in Rust by rewriting the plugins one by one. Whilst none of the plugins is written in Rust yet, I plan to implement a simple one in the near future as a proof-of-concept.