Podcast Development

Is Rust the perfect programming language?

Categories: Development
Posted 15 February 2022

Rust was yet again awarded the ‘most loved’ programming language in the Stack Overflow 2021 Developer Survey. Completing its sixth year at the top of that particular chart.

The programming language developed as an alternative to C++ however still only sits 16th in the overall list of ‘most commonly used programming languages’, so why is Rust so universally loved and why does that love not translate into a more prominent place on the main list?

Join us, as we take a little look at Rust’s history, its evolution and answer the much asked (and hyperbolic) question “Is Rust the perfect programming language?”.

A potted history of Rust

Rust was developed by Mozilla employee Graydon Hoare, who describes himself as “Middle-aged…white guy (who) enjoys napping, reading history books, hanging out with friends and watching the same dozen bad 80s movies over and over”.

What’s not to love so far?

Hoare started working on Rust in 2006 and the project was sponsored by Mozilla from 2009 onwards, through to it’s first stable release (Rust 1.0) in January 2014, at which point technology journal Dr Dobb’s spoke favourably of Rust saying it was “widely viewed as a remarkably elegant programming language”.

Others agreed… and the language continued to grow in popularity until last year (2021), when the Rust Foundation was incorporated with the purpose of “supporting the maintenance and development of the language, whilst cultivating the Rust project team and user communities”, cementing its place in the pantheon of ‘elegant languages’ were five founding corporate members… Mozilla, Microsoft, Google, Amazon Web Services and Huawei.

Rust Foundation logo

So Rust is not only the most loved (according to Stack Overflow), it is also gathering support from some of the largest technology companies in the world. But what is so special about Rust?

What’s so special about Rust?

Rust was developed initially to address commonly experienced issues with C/C++ .

It was primarily created (and developed) to address both performance and safety. 

Its syntax is similar to that of C++ (in the most basic sense – e.g. it doesn’t use spaces for indentation), however as a language it differs quite a lot, in that it isn’t object oriented at all.

Its main benefits are considered to be in solving problems surrounding memory errors (both in Safety & Management) and concurrent programming.

In Rust there are two modes of writing code: Safe Rust and Unsafe Rust. Safe Rust imposes additional restrictions on the programmer ensuring that the code works properly, whilst Unsafe Rust gives the programmer much more autonomy and flexibility.

In Safe Rust, the compiler can do more work to ensure that the code you’ve written handles memory in the way it expects. However, if you’re writing code that needs to interoperate with C or C++, Rust provides an escape hatch of Unsafe. 

Writing Unsafe code means it’s up to the developer to verify that it’s correct, as the compiler can’t verify it independently.

Rust’s dual-mode model is one of its biggest advantages over C++, as when programming in C++ you never know you’ve written unsafe code until somewhere down the line your software crashes or a security breach is identified.

One of the key elements that distinguishes Rust from other programming languages is that it tracks all ownership of states and will tell you at compile time if something is incorrect. When you hear developers complaining about the “borrow checker” this is probably what they are referring to.

Many developers comment on Rust as being ‘both fast and flexible’, but what is it that makes it so?

  • It is statically typed and compiled
  • It offers static dispatch of traits
  • It offers zero cost abstraction
  • It tracks ownership of variables
  • It offers algebraic data types
  • It stores data without any overheads

It all sounds great, but adoption is the barrier for any programming language, so who is using this fast and flexible language?

Who uses Rust now & who will in the future?

From nearly 60,000 professional developers, the Stack Overflow survey suggested that just 6.4% of respondents were actively using the language, with 17% using C & 20% using C++.

So why hasn’t Rust overtaken C++ and will it in the future?

While professional Rust developers regularly cite that the language is ‘better than C++’ due to well-defined semantics and the prevention of unwanted behaviour, many also suggested that if they were looking for a well-supported and framework-rich language, they might well still choose C++. 

So the jury is still out on whether Rust as a pretender to C++’s throne will actually overthrow it at some point! 

That being said, there is a range of evidence that suggests that ever since Rust support has made it to the Linux kernel (so that drivers can be written in Rust to help catch whole new classes of error) many large tech businesses are using the programming language. To name but a few of those businesses actively recruiting for Rust developer talent:

  • Microsoft
  • Sentry
  • Dropbox
  • Amazon
  • Mozilla

And whilst Rust is still considered a relatively young language, it has also become a big favourite of the emerging cryptocurrency class of projects, programmes and businesses, building on layer one solutions like:

  • Near
  • Polkadot
  • Cardano
  • Solana

So whilst the growth of the programming language is still in its infancy, Rust certainly seems to have the wind in its sails.

Is Rust the perfect programming language?

Well. There are a number of people who think so.

Jack Dorsey being one of them:

When he was challenged by a developer with the comment “Perfect for what?”. He retorted “System/Real Time”, which is concise and to the point… but not a particularly detailed response for such a hyperbolic statement.

If, for a moment, we return back to the Stack Overflow survey, when 83,000 professional developers were asked which language they had an interest in developing in… Rust came out sixth. So exposure like the tweet above from a man who has 6.1M followers worldwide, will most likely create a ground swell of developers interested in learning Rust.

Will more developers mean more justification for adoption? Possibly.

Of course, there is no such thing as a perfect programming language but by evaluating the benefits Rust can offer, it is no surprise that the language’s popularity and use is only going to grow. 

Rust has completed its objective of solving some commonly experienced problems that have caused many a headache in the developers’ community, whilst ensuring a level of performance that is as good as (or better!) than other, more well-known programming languages. 

So maybe when we look back at this article in ten years time, we will think we were prophetic, when Rust is one of the most widely used programming languages on earth…

Or maybe programming will have a similar paradigm shift that Maths got from calculus where there is a fundamental change in the underlying model (i.e. SSI – Sequence, Selection & Iteration) to support different structures and in turn different models of abstraction.

Until then all new programming languages will be slightly more ‘elegant’ forms of SSI sprinkled liberally in syntactical sugar.

_

Waracle are a developer-led organisation that create innovative software products in collaboration with our strategic partners.

If you are a developer that thrives when working on vertical-specific challenges across finance and healthcare, and you want to collaborate with some of the most experienced teams in the UK, then get in touch with our careers team to find out more about working for Waracle.