codeblog

Rust: New Systems Programming Language

For those of you who don’t know what Rust is, here is a quick and short intro

Why Rust

In the world where C/C++ powers everything we know, what brings us to Rust? Well here is an example to consider:

Take a look at this graph:

70% of security issues that Microsoft encounter are due to memory unsafety. Why this happens? Because writing memory-safe code is hard. It’s not that these issues are left neglected at the time of production and testing, but due to the reason, it’s so difficult to write and catch errors. That’s why languages like Python and JavaScript were created, to abstract out these complexities and to empower more developers to create stuff. But they come with performance penalties and run-time overheads. This is a place where Rust comes in.

Why I love Rust

Here is a list of things that I love about Rust

  1. Syntax: Rust has a very sensible syntax, making it easy and fast to understand and while abstracting on a lot of things. Though, it’s not as easy as python but compared to C, it’s much cleaner. It shares a lot of similarities with modern programming languages.

Example:

Here are a few examples of compiler complaining: (source Google images)

source : google

source : google

source : google

Things I don’t like about Rust

  1. It’s hard to learn: As compared to other languages, it’s much difficult to get started with Rust. I’ve found that Rust has forced me to learn many of the things that Iwas slowly learning as ‘good practice’ in C/C++ before I could evencompile my code. I want to stress that Rust isn’t the kind of languageyou can learn in a couple days and just deal with thehard/technical/good-practice stuff later. You will be forced to learn strictsafety immediately and it will probably feel uncomfortable at first.The whole concept memory ownership and borrowing Rust focuses on, with features like Option and Result (kind of like promises in JavaScript) increases the learning curve for beginners.
  2. Compiler: Rust, being a language that provides a level of abstraction much more common to higher-level languages with little to no runtime performance cost, have to pay for that to some extent at compile time. It’s slow to compile.
  3. Framework and ecosystem : What comes to your mind when you think about system-level programming language like PASCAL, FORTRAN, C/C+, fast programming languages with old toolchain and software development workflows. Now think of Python, JavaScript, modern languages with great toolchain support. Rust combines the power of both worlds. it’s a fast system-level programming language with a modern toolchain. Cargo, Rust’s package manager is boon for developers to get started working on projects in Rust because now they don’t have to waste time linking libraries and adding environment variables which I believe is a hot mess.

Rust has a lot of amazing frameworks in all fields, from Web to ML to game engines, libraries and framework are bubbling up. Rocket, a web framework similar to flask and ruby, was put in production after 3 days of first public release, it was possible only because if your program compiles without any error or warning and pass all limit test case, then it’s pretty much battle proof and production-ready. The frameworks are evolving fast at a point extreme performance can be achieved with ease.

Industry adoption

It’s the systems programming language in the future where it will replace C/C++ first in the world of networking and embedded systems, providing high-performance applications.

I hope you like this article !