paint-brush
Why Rust is Meant to Replace Cby@iurii-gurzhii
2,648 reads
2,648 reads

Why Rust is Meant to Replace C

by Iurii GurzhiiMarch 12th, 2020
Read on Terminal Reader
Read this story w/o Javascript
tldt arrow

Too Long; Didn't Read

The Rust programming language is an ambitious project of the Mozilla Foundation. It claims to be the next step in evolution of C and C++. Rust was created to solve these problems while improving security and performance. The language supports the main programming paradigms: object-oriented, parallel, functional and procedural. It provides enough control over memory and is secure enough to become a popular tool for OS and key application development. Rust can be used for creating web projects: the language’s SDK can be utilized for both the frontend and the backend sides of the application.

Companies Mentioned

Mention Thumbnail
Mention Thumbnail

Coins Mentioned

Mention Thumbnail
Mention Thumbnail
featured image - Why Rust is Meant to Replace C
Iurii Gurzhii HackerNoon profile picture

The Rust programming language is an ambitious project of the Mozilla Foundation – a language that claims to be the next step in evolution of C and C++. Over the years of existence of these languages some of their basic flaws still haven’t been fixed, like segmentation errors, manual memory control, risks of memory leaks and unpredictable compiler behavior. Rust was created to solve these problems while improving security and performance along the way.

Evrone has found use of Rust in a lot of projects, and our engineers have amassed substantial experience with the language. In this article we’ll tell you about the main features of Rust.

Feature rundown

  • Strong static typization
  • Lack of garbage collection and an ability to manually control where data is stored through pointers
  • A powerful built-in static code analyzer that helps to avoid memory control and multi-threading issues
  • C-like syntax with brief keywords

History of Rust

Work on Rust was started in 2008 by enthusiast Graydon Hore. In 2009 Mozilla expressed interest in the project, and just a year later the project was announced publicly. 2012 saw the release of the first alpha version of Rust. A year later, developers of the Servo web engine that is based on Rust announced that they had received support from Samsung. Thanks to that the engine was ported to the ARM architecture.

Rust 1.0 was released in May 2015. The same year, the language was placed third in Stack Overflow’s poll of favorite developer tools. Starting from 2016 and to this day, Rust tops these rankings.

Reasons to use Rust

Pros

  • A uniform compiler from Rust developers with a built-in package builder and manager, test system and documentation generator
  • Safe memory management that helps to avoid segmentation errors
  • An ability to use abstractions, which makes manual memory control easier
  • Fix suggestions for most common compile errors, plus clear and concise pattern errors
  • Pointers could only be used in unsafe code – safe code only includes links to objects guaranteed to exist
  • Great compatibility with Mac and Unix-like systems

Cons

  • Lack of classes and succession, which makes writing object-oriented code harder
  • Very strict compiler that sometimes polices memory addresses too much

Use cases of Rust

The language supports the main programming paradigms: object-oriented, parallel, functional and procedural. It provides enough control over memory and is secure enough to become a popular tool for OS and key application development. Its main drawback, however, is insufficient support from hardware manufacturers who prefer using more ubiquitous C and C++. Here are some of the successful software projects written in Rust:

  • Redox, a Unix-like OS based on a micro-kernel, and most of the software for this OS is also written on Rust
  • Servo, multithread-optimized web engine
  • Firecracker, a micro-virtualization system created primarily for serverless environments

Blockchain in Rust

Distributed ledger-based systems have to be able to quickly process requests within the network with minimal computing load for the device. C++ tools are very well-suited for this task, so developing blockchain architecture using Rust will prove even more effective. Those are the notable examples:

  • Parity.io – an alternative client for Ethereum and Bitcoin
  • Polkadot.network – heterogeneous blockchain networks
  • Exonum, a framework for blockchain-based projects
  • MaidSafe, a distributed data processing and storage system
  • Solana, a platform for creating blockchain-based applicationsRust in web development

Rust can be used for creating web projects: the language’s SDK can be utilized for both the frontend and the backend sides of the application. For example, the client side is done via Yew – a framework inspired by React and Angular. Web servers can be easily created using Actix-web – a very performance-oriented framework with support for WebSockets, TLS and HTTP/2.0.

Other tools enabling the use of Rust for the web are also available: rocket, conduit, gotham, pencil.

Some of the successful Rust projects:

  • Dropbox, a cloud storage service OpenDNS, a web service for creating public DNS servers
  • Coursera, an education portal created by IT professors at Stanford University
  • Machine learning in Rust

Rust-based neural networks look like a very prospective venture. The Rust API can become a popular tool for this purpose thanks to its performance and a low-level memory control using high-level abstractions.

But at the present moment, machine learning applications using Rust are only at an experimental stage. The Rust ecosystem lacks proven and reliable libraries to develop neural networks similar in features to Python-based ones.

Future of Rust

C++ has been dominating the programming language landscape for almost 40 years, becoming an industry standard and rightly holding onto that title to this day. Rust is being actively developed and refined trying to solve the most critical flaws of C++ and other programming languages.

Among Evrone projects built with Rust we can point out at a large ERP system for a restaurant chain. Within it, Rust handles micro services serving the users data about the nearest restaurant. It is also the base of self-service information kiosks.

Another notable use of Rust is Vexor – our continuous integration service. There, Rust is responsible for managing and scheduling tasks, the automatic computing power purchaser and the logging system, as well as serves as the basis of an agent handling isolated executions of tasks on workstations.