Wychowaniec
10 JUL 2020

“Learning Rust was such a mind-blowing experience for me - it permanently shifted the way I approach thinking about data and the way it flows through the application,” said Patryk Wychowaniec who works at ANIXE as Software Engineer programming in RUST.

Why RUST? How did it all begin? Where did you learn RUST?

As far as my memory goes, I’ve always been a tinkering kinda guy - apart from my conventional 8-16 work, I’ve always tried to dig up some additional time for personal projects; one of them was a weather station. The history of my station starts about two~ish or so years ago with a clear, sincere thought (as some would say - a user story): when I wake up, I’d like to see the current date, time, and temperature. At the time I was a full-stack PHP programmer - knowing that PHP won’t do in this case, I started to explore other languages and platforms, more suited for building free-standing internet-of-things gadgets. Initially, I tried coding my station in C++ (on Arduino), then Python (on Omega2), and Go (on Raspberry Pi), but eventually I found myself having no “chemistry” with them; for me, programming in those languages just wasn’t as much enjoyable as I thought it should be. Having heard a thing or two about Rust on the internet, I decided to give it a go - it took me a while to understand the basic concepts (picky borrow checker, I’m talking about you!), but eventually, as I rolled out my driver for HD44780 and cross-compiled the binaries for Raspberry Pi Zero, I had my gadget working & standing on my windowsill:https://github.com/Patryk27/home-station-1 (photo included in the readme!)(by the way, last year I re-did the entire thing, implementing support for colorful LCD screens: https://github.com/Patryk27/home-station-2 - it’s also been a rather pleasant journey) With time, I started to see more of the advantages in which Rust excels over other languages - from wonderful and human-friendly error messages to well-thought, swiftly-evolving tooling (e.g. cargo, rustfix, rustfmt). Rust has learned a lot from its predecessors, and it shows.

Why developers should learn RUST, and how they can master it?

There are a few languages that fundamentally affect the way one sees and approaches programming - Haskell (as an example of the functional paradigm), Erlang (which emphasizes concurrency) or Whitespace, to name a few. Learning Rust, too, was such a mind-blowing experience for me - it permanently shifted the way I approach thinking about data and the way it flows through the application. With garbage-collecting languages, for instance, you don’t care whether you own an object or just barely keep a reference to it - that’s radically different to the situation in Rust, where you have to annotate lifetimes of shared objects to persuade the compiler that you don’t accidentally e.g. overwrite a thing another part of your code is currently reading. Rust’s newcomers frequently find this concept of lifetimes baffling and confusing (quite justly though, because none of the other mainstream languages implement lifetimes), but understanding it opens the adjacent possiblefor a deeper comprehension of how the program is working and what happens to the data inside it. Also, just for reference: 70% of all security bugs are memory-safety issues [^1]; most of them are impossible to invoke in Rust (unless you start doing fancy unsafe twirls).[^1] https://www.zdnet.com/article/microsoft-70-percent-of-all-security-bugs-are-memory-safety-issues/

Can you tell us about your last speech? What was the topic, and why did you choose it?

Since Rust is quite a complex language with a rather sophisticated (Turing-complete, even!) type-system, sometimes (especially while learning the basics) it just happens that one gets frustrated at the sheer inability to convince the compiler that “my code is fine, leave me alone!”. Granted, it also happens for other languages, but it’s particularly painful for Rust’s newcomers, because the borrow checker makes doing “quick hacks I’ll surely figure out later” now and then just fundamentally not possible, requiring one to re-think some parts of the program’s dataflow. That’s why for my recent presentation, for the Rust Wrocław’s group, I gathered a list of a few common acronyms one might stumble upon while writing Rust code. They are mostly type-system mechanisms like - dragons ahead - “OIBIT” or “HRTB”, usually hidden from the programmer sight (i.e. because of syntactic sugar one can write lots of Rust code not knowing a thing about HRTBs, until one day you end up scratching your head, thinking “how can I express this dependency to satisfy the type-checker?”). Knowing that such mechanisms exist - or at least are planned to be implemented, as I talked about work-in-progress features too - helps one to become a better programmer with a more thorough understanding of the language’s philosophy, and just generally increases one’s toolbox. For reference, the presentation and slides are all available online: - https://www.youtube.com/watch?v=6Qi5-VU-kS0 - https://github.com/Rust-Wroclaw/rust-wroclaw/blob/master/talk-archive/2020-05-scary-acronyms-and-super-creeps.pdf

You use RUST in your daily professional life at ANIXE. What are the challenges you had to face? What is the difference between working with RUST and other programming languages (C#)?

Like I’ve said before, I switched from being a PHP programmer into a Rust one - the greatest leap I had to overcome was a change in mindset: from a garbage-collecting fire-and-forget language to one which cares where and how you allocate data. Pragmatically, PHP is used in places where you don’t care about performance that much - not once have I seen applications happily launching tons of database queries straight from their views, with no one batting an eyelid (mainly because “the performance is fine enough, anyway”). So the most of a switch for me was to focus more not only on delivering the data but also delivering it on time, or even faster. Sometimes it’s a matter of tweaking a few database knobs or adding fancy indices, but sometimes you have to entirely re-think the way your application fetches and works on the data, be it database rows or classic files. And I love it.

For what type of projects is the RUST language perfect?

There are certain traits (stereotypes) commonly attributed to each language - for instance Go is said to be the best for monolithic microservices, Java is said to be the best for enterprise fizz-buzzes, and JavaScript is best forgotten. Jokes aside though: by overall standards, Rust fits somewhere in-between C++ and C#, TypeScript and PHP, Go and Ruby. Thanks to its battle-tested highly-optimizing backend (LLVM), Rust allows one to - and I mean it in the best of possible ways - carelessly focus on code. Having grasped the basics, one doesn’t have to think “can I afford to use a closure here?” or “how do I model this structure?” (happened to me before!), because one of Rust’s core principles are zero-cost abstractions; and Rust’s nailing it. Closures, algebraic data types, traits, asynchronous functions, generics, and lots of other syntactic features all work together, allowing programmers to neatly express their intents, and letting the compiler ensure all the constraints are met at the compile-time. For instance, not once have I wished PHP had algebraic data types paired with irrefutable match bindings - it would make my code so much more readable, and so much safer. Answering the question directly, without “marketing yadda yadda” though: there are some classes of applications in which Rust excels at (e.g. CLI tools, high-performance databases & HTTP servers), and - of course - there are ones for which Rust is a rather poor choice (e.g. GUI applications and some microcontrollers). Since Rust’s ecosystem is still relatively immature (remember, Rust was born in 2010!), many people - especially the ones accustomed to re-using existing libraries - find it perplexing that they have to either re-invent the wheel from time to time or use a half-baked already-existing solution. Fortunately, since more and more companies are deciding to give Rust a chance, that’s rapidly changing - more and more well-tested libraries are being ported to (and coded in) Rust, so both the language and ecosystem are constantly gaining traction.

What do you do in your free time?

I’m a programmer by heart, so I’m mostly programming! Currently, I’m trying to be more involved in the open-source software community - mainly the ones for Rust and Nix - both by fixing active bugs and helping people on the internet. Apart from all the programming stuff, I and my girlfriend also host a modest temporary home for animals - as I’m writing this, behind my back lays Avocado: a young crow with a broken leg who came to us a few days ago. We’re feeding her (or him, hard to tell!) until it gets better, and then it’ll be released. Before Avocado, we had a baby marten named Kuniś - also cutesy!

How you starting working at ANIXE?

It’s a bit of a funny story because I landed a PHP job by a hair! Having relocated from Kraków to Wrocław last year, I gave myself some time to take it easy and take a breath (two-monthly gap, let’s say). One night, as I was going through the latest posts on r/rust on Reddit, I noticed a job offer from Anixe looking for a Rust programmer. I had heard about Anixe before (not that many companies recruit Rust programmers in Poland, after all), so I decided to give it a whirl - and now I’m doing Rust for a living :-) If the offer had been posted a few days later, I’d have probably already been back in PHP - which isn’t bad (love all the languages!), but thanks to Anixe I’m able to learn & use this new, shiny, and promising language on a daily basis.

Find out more about work in ANIXE »

Read more news »