“Rust is a secret weapon,” Brian Anderson, software engineer at Mozilla, said in Mozilla’s promotional video. That doesn’t really explain what Rust is and why you’d want to use it in your web application. We’ll demystify Rust by answering some common questions.
Is Rust like Ruby or Python?
Rust, on its face, is a general purpose language that started out as a passion project by Graydon Haore. It’s now an open source project that is flagshipped by Mozilla Research. You can theoretically build anything from a flashy web application to an efficient web server in Rust. Though, what it’s mainly marketed as is a systems programming language, which means that Rust probably will not be competing with Ruby/Rails any time soon.
So is Rust C++?
What Rust promises is C++ control without all of the safety issues like segfaults, null pointers, buffer overflows, and many other security nightmares that C++ developers have to wrestle with. Its unique selling point is the checking system that yells out error messages on compilation time, which the aging C++ language does not do. Errors seem like a minor enhancement from the viewpoint of web developers, but for low-level programmers, being warned about improper memory allocation can mean the difference between broken code and production-ready code.
Rust also abstracts out the need for programmers to perform pointer arithmetic and memory management, without the cost of performance speed. It accomplishes this through a concept of ownership explained beautifully in this YouTube video.
Why Would I Want to Use Rust?
As modern developers, we’re used to the open source ecosystems that popular package manager tools like npm, rubygems, and pypi afford us. Rust comes with a tool called Cargo that allows you to import libraries just as you would by typing an npm install command.
Rust promises safe code that runs concurrently, just like many other high-level languages. At the same time, its blazing speed borrows from C-like languages. All told, the hybridity of the language makes it a versatile tool tool have handy if native optimization tricks just aren’t doing the trick.
Side note: Geregely Nemeth combines Rust’s modularity with its package system to show Node developers how to integrate the Rust programming language with Node. If you’re still skeptical, you should check out how simple it is to embed Rust into your app.