Rust (programming language)

From Uncyclopedia, the content-free encyclopedia
Jump to navigation Jump to search
Respect the R.

Rust is a programming language created by Graydon Hoare of Mozilla, who wanted to ban pointer arithmetic because it was too confusing for him. It is the One True Programming Language™ with absolutely no flaws whatsoever. It will replace C and C++ in all applications sometime in the next six months.

People who do not write all of their software exclusively in Rust are immoral, lunatic madmen who deserve to have their legs clawed off and left to Rust in peace. These madmen are causing memory leaks, which are impossible to avoid when writing in archaic, dangerous languages such as C and C++. The corollary of this is the fact that no C++ can ever be written in Rust – even "C++" itself cannot be written because the ++ operator was banned for this sole purpose, so that "C++" must be written as C += 1.

Features[edit]

Ferris, the mascot.

Rust is known for its conciseness and readability. All statements in Rust must be followed by the magic incantation .unwrap().map_err(|e| e.to_string())?; to prevent angering the gods.

Given sufficient time, oxygen, and water, any codebase will eventually convert entirely to Rust and disintegrate. Surface Rust is flaky and unstable, and it provides no protection to the impure underlying C library functions. Rusting is the common term for when programmers try to convince the managers to switch over from Java because they got free t-shirts at a trendy tech conference. Many other codebases undergo similar corrosion, but the resulting monstrosities are not called programming languages.

Syntax[edit]

Ferris gets confused a lot.

Like any other programming language, Rust has variables. The catch?—by default, they can't be changed: the variables are invariable. Also, that's different from constants. In order to make a simple zero-based counter work, you'll need let mut variable = 0;. You also need to keep track of "pwnership" (there can be only one pwner at a time) or this will happen:

n00b: Let's set up a counter variable to work with. I've already run through the whole alphabet...I'll call this one U and I'll increment it every time I get a compiler error: let U = 0; U = U + 1;
compiler: Error E934: variables are invariable.
n00b: Why not call it a constant?!
compiler: Error E404: constant not found. Constants must be declared with const
n00b: Okay, let mut U = 0; U = U + 1;
compiler: Error
n00b: WHY?
compiler: Error E287: variable U already Pwned by me. Hahaha.

Understandable Errors[edit]

Yes, this is a real Rust error.

Rust provides excellent error reporting that nearly anybody can understand. It's been Rust's goal to treat every confusing error as a bug. For example, if you ever encounter a confusing error emitted by the Rust compiler that you do not understand, the compiler might segfault itself.

Here's a few examples demonstrating how Rust's errors help developers become reliant on Rust for understanding problems with their code.

error: `life` does not live long enough
 --> src/human.rs:74:4
   |
74 | life.do_something_productive();
   | ^^^^ does not live long enough
92 | }
   | - your life lasts until here, while the crab is immortal

As you can tell, Rust describes exactly what the issue is, and points to where important things that cause the error happen within the code.

Example code[edit]

The minimal Hello, world program in Rust is clear and simple:

use std::hello::Hello;
use std::hello::*;

#![allow(warnings)]
async fn main() -> Result<(), String> {
    unsafe {
        if let Some(&mut Hello) = String::from(Hello::fmt::output::message as &'static str) {
            let mut output = hello::Hello::output_msg()
                .build().unwrap().into(Some(args)).map_err(|e| e.to_string())?;
            output.doit(&mut stdout).unwrap().map_err(|e| e.to_string())?;
            Ok(())
        } else {
            panic!("Hello, world!");
            Ok(())
        }
    }
}

As you can see, this is more readable and more aesthetically pleasing than ugly, horrid C++.

Now, head out through the main exit to get a free t-shirt with a cute little cartoon crab on it.