RustConf 2019, and systems programming as a data scientist

This post, written by HRDAG data science fellow Camille Fassett, was originally published here

My technical work mostly consists of data analysis, predictive modeling, and visualizations and mapping. Python, R, and JavaScript are excellent languages for the things that I do, and nothing that I do particularly makes sense to do in a systems programming language instead. So, I never learned one.

One of the most powerful characteristics that Python has to offer is how quickly it is to build things, and get projects up and running. Its syntax is easy to read and generally intuitive, and when I began programming without a formal computer science background, it felt rewarding and motivating to get quick and positive feedback.

Python is a really powerful language, but I’ve also been diving into learning Rust recently. I’m so glad I did! Writing Rust has rapidly and drastically expanded my understanding of computer science and programming concepts in a supportive environment.

I attended RustConf this year in Portland, OR, and I learned a lot. I also came with a group of great friends, and left with a few more.

The best part of taking the train from Oakland, CA, to Portland, OR, was waking up in the Willamette National Forest.

Why learn Rust as a data scientist?

Learning a systems programming language is the best way to understand computer science concepts like type safety and memory allocation (which is obviously hidden in languages like Python and R), and it seems clear to me that Rust is the most interesting and empowering systems language.

I also think it could make sense to use Rust as a data journalist for in-browser computations, so I’m looking forward to trying that out sometime.

RustBridge

I spent the first day of RustConf at RustBridge, a workshop aimed at teaching people Rust who have experience with another programming language without making assumptions as to which one.

It was a great and very friendly deep dive into writing and debugging various Rust programs, and even putting together a small application.

The concepts of borrowing and ownership were new to me, and the benefits obfuscated at first to me as someone who hasn’t written C or C++. When the RustBridge presenters went over the topic of borrowing, there was an entertaining moment when one attendee paused to ask, “once a vector has been borrowed, can you give it back?”

Another attendee chimed in, “Well, it wouldn’t be borrowing if you couldn’t give it back! That would just be vector theft.”

fn main() {
let veccyvec: Vec<String> = vec![
String::from("Rust is cool"),
String::from("...but strings are so complicated")
];
let mut veccyboi: Vec<String> = Vec::new();
veccyboi.push(veccyvec.get(1).unwrap().to_string());
}

In Rust, a value can only be assigned to one owner at a time, which avoids invalid memory problems and the need for garbage collection. Here, this vector becomes privately owned by veccyboi. Sorry, but this vector does not belong to the collective.

Tracing

My friend Eliza Weisman gave a great talk about a crate she wrote, tracing (previously tokio-trace). The stabilization of Rust’s async/await is really exciting, and it’s great to see an async-aware logging library!

“tracing is more than a logging library: it implements scoped, contextual, and structured diagnostic instrumentation. This allows users to trace logical contexts in the application through time, even as the actual flow of execution moves between those contexts.”

You can check out Eliza’s blog post about tracing here.

The Rust community

Everyone I met at RustConf, and everyone I’ve talked to who writes Rust, has been kind, open, and welcoming! The language community alone makes me want to continue engaging with Rust – let alone the memory safety benefits, speed, cargo crate management, and more.