Skip to main content

Interview with Rust and operating system Developer Andy Python

Summary: #

This is an interview with the 15 year old Austrailian Rust developer Anhad “Andy Python” Singh. The last two years, Andy has been working on AERO which is one of the most mature operating system that is written in Rust. Interview conducted by Filip from Rust.Careers Team.

Andy Python Ferris Rust Crab

F: It’s a pleasure to have you here! How was your journey, getting into Rust? #

A: Thank you for having me, My first programming language I learned was Python, and that’s where my name “Andy-Python” comes from.

It was really cool that I was able to instruct computers on what to do. Each time I learn a new language or framework I go down deep into it the stack. I started with Python and then went over to C, in order to get lower down the stack.
While I was into low-level programming, I ran into Rust, and the rest is history.

F: How was the move from Python to C? That could be a pretty big jump. #

A: It took some time to understand the basics, but overall it wasn’t that bad.

F: How was it in the beginning when you first discovered Rust? #

A: I was more interested in doing low-level development in order to talk directly and tell it what to do. In comparison with C there are a lot of nice things you can do. For example Traits in Rust. In my case where I’m interested in writing an operating system, we can take the network stack for example: You can represent the packet hierarchy using Traits in Rust. So you can have like an upward hierarchy trait implemented for such as an ethernet packet, so you have a hierarchy track for ethernet and represent the packet with the trait. It also has a lot of nice asynchronous support, so you can implement asynchronous in the network stack.

F: Why do you have an interest in Redox Os and what is it? #

Redox OS

A: My interest in Redox is because it’s one of the most mature operating system written in Rust.

I have recently working on this project for Redox Summer of Code. My project was to write virtual I/O drivers(VirtIO) For Redox, Virtio is a standardized interface that lets you access virtualized devices such as network adapters and graphic cards. Hypervisors such as qemu do a resource-heavy virtualization of these devices. Since I’m developing Redox in a virtual machine, it just made sense to work on VirtIO.

F: How was it to port VirtIO over to Redox? #

A: Before I started working on this there was no support for any virtualized I/O support on Redox. But now we have support for:
VirtioBlock
VirtioNet
VirtioGpu

So we only support 2D rendering at the moment, I’m looking into adding 3D rendering as well.

F: How was it to work on VirtIO? Any pain points, porting it into Redox? #

A: The VirtualI/O spec is pretty straightforward, there are two versions v1 and v2. The only big compatibility issue is that legacy transport uses PortIo and PCI standard transport uses memorymap InputI/O. That’s the biggest compatibility issue that you will have. It took the most time to create a standardized interface that can communicate with all devices. If you have a GPU for example, you need a way to communicate with it and now you have the input “scheme” in Redox.

F: What is your previous experience with VirtIO? #

A: I have written drivers for My own operating system AERO before it, so I was familiar with it.

F: What is AERO, can you tell me more about it? #

Aero OS Desktop view

A: I started the project AERO because I wanted to know more about how the operating system works. So I started it for educational purposes, After a while people started to take notice of what I was working on and the progress that was made. Now it has
become one of the most mature operating systems that are written in Rust. AERO can currently run dwm, Xorg, and Aliacritty which is an amazing terminal(written in Rust). One of my goals is to target modern 64-bit architectures and maintain good source-level compatibility with Linux so I can port programs very easily. I want to make it a usable operating system that runs on real hardware and not just as virtual machines.

F: It’s not every day I run by an operating system that is written in Rust, The Linux kernel, a lot of CoreOS, most of the BSD kernels, and Windows kernel are all written in C. Do you think we are shifting from C? #

The Rust space is changing and becoming better and better, especially now when you have Rust for Linux where you can write kernel modules in Rust for Linux. The support for Rust in Linux is added upstream. There are a lot of experiments with AsyncIO as well.

F: Is AsyncIO stable? #

A: If you want to write an executor, you can do it. Some of the helpful traits are available in the future crates. Something that is not very stable is having async functions in Traits. There are some workarounds where you can return a future Object wrapped in a Box. But that is something to look into.

F: How did you start AERO? Did you fork another project or roll up your Sleeves and start from scratch? #

A: I just started from scratch. There was this blog post that was pretty insightful. He wrote a blog about writing an operating system in Rust, and how to get started.

F: How long have you been working on AERO? #

A: I started two years ago when the COVID lockdown started. I found myself with a lot of free time on my hands.

F: Oh cool, it’s a Covid Project? #

A: Yeah, Covid Project.

F: How was it to start working on AERO? #

It was pretty painful, a lot of sleepless nights but It was during lockdown so I didn’t have much else going on. But I
think it paid off.

There were a lot of things I learned such as debugging with GDB and working with Qemu. Back then the Rust backtraces weren’t that good so debugging with GDB was better.

F: What are you currently working on in AERO? #

A: I’m working on the Network stack for AERO at the moment, it’s pretty cool what Rust offers for low-level projects like this.

F: Do you have any goals for porting certain packages over? #

A: I want to port over Chrome or Firefox. Right now I have only ported over the Lynk browser. So getting a proper browser in.

F: How is it to port a package to AERO? #

A: It depends on the package, if we take Xorg for example, it’s very portable since previous projects have written a lot of good documentation for porting it.

F: It’s crazy to see libc being rewritten in Rust. #

A: Yeah, I’m currently using mlibc(https://github.com/managarm/mlibc). It’s a very nice C library written in C++.

F: What advice do you have for other people who want to create an operating system? #

A: Depends on your goal, if you just want to write a simple operating system that boots up into a shell, the blog is great for that. If you want to do it in Rust.

F: Let’s talk about your game “Call of Ferris”, It its a fun take on Ferris the crab, how did that end up? #

Call of Ferris Game

A: That’s a fun project that I did to kind of get to learn Rust, I did it together with my mate who did all the assets for it. A fun project to learn rust with.

F: You should port it to AERO. #

A: Yeah, I should do that.

F: What different programming languages do you use on a weekly basis? #

A: Mostly Rust and Assembler.

But sometimes I work on a bootloader in C and sometimes I work with C++. But I try to focus on Rust.

F: Why do you like Rust? Why does it appeal to you? #

A: I think it’s the syntax and the compiler errors. it literally tells you where you are wrong, Cargo is great.

F: Cargo is amazing, a great packet manager and compiler! #

A: And the formatting as well, so wherever you read rust code, you see the same style guidelines being used, and it’s very visually appealing, unlike several C projects where you have different syntax in the code base. Also, the GnuC is very hard to read.

Dependency management with cargo is really great as well. Unlike C or C++ where it’s much harder and more steps to take.

Also, the Rust community is very welcoming.

F: What are your favorite crates? #

Can I choose between any categories?

F: Of course! #

I would then say serde is a good one and proc_macro crates.

F: Writing macros is really useful. #

A: Yeah, one of the things I love about Rust as well is writing macros it helps you refactor the code in a nice way. The code looks cleaner.

F: Have you worked on any macros recently? #

A: Yes, I have recently working on the CPU local macro. It’s basically like a thread local macro, but instead of storing the data in fs segment, it stores it in the base js segment instead, because fs is reserved userspace. It’s easy to switch as well. It has refactored a lot of my code.

F: What have you used Serde for? #

A: I use serde jsons a lot because in AERO the procfile system if you take any inode the result is in JSON. So if you for example view proc cpuinfo it will return a JSON file instead of the standard file you find on Linux-based systems.

It’s easier to parse as well, unlike Linux which just spits out the raw text when you cat /proc/cpuinfo. The only problem is if you have a Linux program that uses the other file format, you have to patch it up.

F: What does your setup look like? how do you program? Which IDE do you use? #

A: I have been using VScode with vi bindings but now I have switched to Neovim because I use emulators VSCode eats all my memory. So I can not really have VSCode running at the same time as my virtual machines. Neovim is pretty
tweakable and it has LSP support so I can use Rust-analyzer.

I also use dwm and Alacritty as my terminal.

F: What advice do you have for people who want to get into Rust? #

A: The Rust book is a great starting point. I think you should read the rust nomicon, as it’s something you see often when you look into library code and you should know why they are implemented the way they are. Also the Rust API guidelines are pretty good, so you can have a standard for your API.
Learning Rust takes time, but in the end, it does pay off.

F: Does AERO use unsafe Rust? #

A: Yeah, because you have inline assembly a bit here and there.

https://github.com/Andy-Python-Programmer
AERO Operating system
Virtio
Redox OS
The Rustonomicon
The Rust book
Procmacro crates
Writing an OS in Rust Blog
https://en.wikipedia.org/wiki/Rust_for_Linux
https://alacritty.org/