Python and Rust are on a boat
Two great languages - you don't have to choose.

Python and Rust are on a boat

I have been coding in Python for almost as far as I can recall. Well, I'm not sure coding on an old Oric Atmos, my grand-father gave me, or a TO7, counts as I had no idea what I was typing was even called programming. I digress.

Python is a fantastic language. It allows you to grow into coding at your own pace and doesn't force its own philosophy onto you. It's a double edge sword though because you don't have the guardrails of the language to guide you towards whatever is the zeitgeist. For instance, when I started at university the paradigm à la mode was "object-oriented programming" so it was all class and the bunch. Then, functional programming came back with a vengeance which reminded me of my semesters learning Scheme or when I had to use erlang at work. Still, it took me years to actually really adopt some of the ideas of functional programming. There again, Python isn't particularly pure, but it allows to explore some concepts nonetheless and isn't too concerned that you do.

That was it. Somewhat-functional programming Python was where I landed and felt the most productive. I rarely design around OOP concepts these days and enjoy as close to native data structures as I can. My code is boring and it's bliss.

But, there is one of course, the Python ecosystem has left me with a problem. It doesn't do very well into generating native code. That's quite normal considering Python isn't targetting this. Sadly, as I released (and maintain) the Chaos Toolkit, I realised I had made the story of installing/deploying the project a challenge for its users. Sure, I used tools like pyinstaller to generate an executable bundle but this hasn't felt as good as I needed. There are other promising solutions like the PyOxidizer project as well.

So, when we considered the release of the Reliably CLI, we initially went for Go. For some reasons, I've never been attracted to that language at all. I have thought about it and tried to understand but it's just not a language that interests me. It says nothing of the language, just that it has left me indifferent. But the team had spoken and they were in charge so I was happy to go along (as a CTO, let your team drive as long as the direction you set is clear). It has succeeded well enough in that regards.

As a turn of event however, the Reliably API has had to change quite a bit in the past couple of months to solidify the Chaos Engineering features we have been working on. With that in mind, we hopped for a rewrite as we had a bit of legacy we didn't want to carry. I took my chances and suggested we switched to Rust. Funnily enough, there was excitment and we went for it.

Why Rust? Could it be just for the trend. Gosh, there is likely a bit of that. But, more specifically, Rust is a language that, to me anyway, has formalized a lot of features and functionnailities I was putting into my code but that Python didn't force you to understand. In other words, Python is great at letting you use a concept without pushing you to learn its theory. Rust is the opposite. You can use concepts but you better learn the why and how to use them well. Where Rust shines is that its compiler will be your guide most of the time.

Before coding anything, I spent some time reading Programming Rust from O'Reilly. A fantastic book that takes you on that journey. I highly recommend it. Yet, really, it's when I started writing some horrible Rust code that I saw the compiler looking after me. Within a few days, I progressed into something that worked. As the language really invites you to understand why you write a certain way, I have also spent quite some delightful hours digging into the design behind the implementation.

I'm clearly slower than I would be with Python and my productivity has declined. Yet what a treat to feel the tooling is looking after your back like this. Python has gained a lot over the last few years with typing annotation, new modern syntaxes and a more professionnal devex. But, this doesn't yet reach the quality of the compiler's help messages in Rust.

Things that surprised me however - perhaps I was naive:

  • The ecosystem is fast moving and feels a bit more like TypeScript land where a new library appears to do things "better". We also have something in Python whereby people don't contribute enough to existing projects but go and create their own package which does things a bit different. Leaving the community wondering if so much fragmentation is good for users. I think Rust should avoid such pitfall. Users can't spend hours wondering what's the best date-time, logging or config library...
  • I was also surprised that code and documentation don't always match, at least in libraries. While documentation has been quite great most of the time, one can tell the ecosystem is still young-ish. Mind you, this still happens in Python land too so not sure what to make of it.
  • I was concerned by many comments I could read on the Rust sub-reddit which can be so dismissive of other languages (notably Python strangely). It reflects poorly on some of the community as there is really enough space in our industry for many languages with different strengths.

Do I regret the choice we made to switch to Rust? Not at all, I think the benefits for our users will be tremendous with a simpler deployment story. A better memory management and a faster execution. Our productivity will rise again and soon it'll be as if we'd done it forever I'm sure.

It makes me tempted to re-rewrite the Chaos Toolkit in Rust though. Ha, maybe someday.

To view or add a comment, sign in

More articles by Sylvain Hellegouarch

Others also viewed

Explore content categories