Write your next C extension in Rust

It’s a good time to learn about the Rust programming language. It’s seen some serious production use, gathered from hundreds of companies that are using Rust every day. It’s received some extremely positive endorsements from experienced, influential software developers. But rather than ask you, “Have you considered rewriting it in Rust?”, I would like to ask you a slightly different question: “Have you considered writing your next C extension module in Rust?”

Experimenting with a new language at work requires lots of courage - from you and your team. Every language makes promises about performance and/or productivity. Yet you’re still reading a blog post about another programming language.

The ideal project for gaining that courage is an experimental project that’s low risk, yet has the potential to speed up your app. Writing an extension means there is no need to jump into a hot bath, you can see how the language fits within your organization before undertaking any migrations.

Why use Rust to build C extensions?

  • You can’t accidentally create a segfault that will destroy your application - Rust is memory safe. C is not. If you are primarily a Ruby/Erlang/Java/Python/Perl/PHP/… programmer, then you’re probably not a C expert. And even C experts cause (avoidable!) catastrophic errors.
  • Your application will be cheaper to run and will run faster - Rust code is lean, fast code.
  • Rust supports incrementalism - using Rust does not require your team to rewrite an application to derive benefit. You won’t need to sink 3 months of development time into a failed project.
  • Rust is genuinely well made software - you’ll come to expect more of your compiler after working with rustc. Its error messages are genuinely helpful.
  • Rust has an excellent package manager, cargo - that means that’s easy to draw from the open source community. Figuring out dependencies (& dependencies of dependencies) isn’t fun.
  • The Rust community cares about its members - help is close by. Observing other technical communities, I’ve noticed many people frowning upon those who are learning. When you spend time within the Rust community, that doesn’t happen. You’re welcomed as a peer. Your willingness to learn is the entry fee.

1 note

  1. tim-mcnamara posted this