Rust

From Soyjak Wiki, the free ensoyclopedia
Jump to navigationJump to search
Rust was created by or has connections to Der 'Cord

Don't DM any waifu (You) see. Verify for the self harm server's 18+ channel to get free nitro and hurtcore 'p.

THIS TOPIC ATTRACTS A LOT OF ASPIES FOR SOME REASON
Please remind those obsessed with this SNCA to breathe deeply from the toilet bowl.
(Almost all) Rust users are trans btw, if that matters.
Rust is rust.
This page is a Tranzanite Falsenvke.
>RUST IS MEMORY SA-ACK!
>Hey ChatGPT, troonspile this code into a single AI generated Rust file

Rust is a type of mineral that appears when iron oxidizes and also a rating that was popularized by Kuz. Because of the fact that rust is a lesser version of iron, it may possibly redeem itself and upgrade to iron (although this is rare).

It is also a programming language used by trannies or something even though all the claims of it being a tranny language are just from coping larper C niggers that have never written code beyond Hello World. It is extremely strict and particular making it highly popular among spergs. One of the most prominent claims of Rust's users is that it is as fast as C++ while being memory safe (but this is probably just glowie propaganda, as the US government has shilled Rust o algo). This is because Rust relies on a borrow checker and an ownership memory model to ensure that no invalid memory references exist, but it also allows the use of unsafe blocks to bypass the memory checker or something. It also cuts out (like trannies cutting off xheir cock) everything you need to use it and what a normal fucking language would have by fucking default, so you have to use a 'crate' (aka a library for normal people) maintained by a 'cord troon. Normal people do not understand how to use Rust for software development because it's just a powder or something. It is represented by a crab named Ferris and it was named after a kind of fungus that looks like rust and is "over-engineered for survival". The so-called Rust community is known for being composed of obnoxious ideological zealots and disproportionally transgender (according to Snopes Rust users are 41% more likely to be trans). You can also just use Java or C# for most applications which is simpler and memory safe.

Some operating systems have begun to be written in Rust which is definitely not caused by glowies. This includes Linux and Windows, which both have parts of the kernel written in Rust, due to it being a suitable language for systems programming. Also, Microsoft created George Droyd using the Rust programming language.

If you search "twitter" on the website lib.rs (an index of Rust libraries/applications like crates.io), it redirects you to a news article seething about Elon Musk doing a Nazi salute. It might do this for some other search heckin bigoted queries too.

Overview[edit | edit source]

WARNING: WORDSWORDSWORDS
This page or section is just one big wall of text.
You WILL fill this section with relevant information NOW
We have more in common than previously thought!

Comparison[edit | edit source]

Many will unfairly give Rust the "tranny language" reputation, but this analysis boils down to the fact that Rust has a disproportionately high rate of trannies in its community. While this is true, it does not discredit the redeeming qualities of Rust. These are:

  • Memory safety without using a garbage collector. The borrow checker is actually greatly superior when it comes to memory management. While it is strict, the rules it enforces are to prevent memory errors, such as memory leaks, segmentation faults, or undefined behaviour.
  • Rust allows for lifetime specification for increased control over when references to data are valid and ensure they do not outlive the data they point to. Similar to Rust, C++ has the Resource Acquisition is Initialisation (RAII) pattern for managing lifetimes.
  • Rust code can be equally as fast as C/C++, as it does not rely on any garbage collection or runtime, rather compiling directly to binaries like C/C++ that are executed directly on the operating system.
    • Unlike in C, undefined behaviour can only be invoked in unsafe blocks. Rust does not forbid the use of unsafe blocks, the only difference is that safety guarantees no longer exist within those blocks.
  • The borrow checker also prevents data races by ensuring that data is never simultaneously accessed or modified in unsafe ways.
  • Rust has a expressive and rich type system. Though some claim that type theory is for academia troons, the expressiveness of the type system allows for code and logic to be expressed much more succinctly. Rust uses algebraic enums and pattern matching allowing for less verbose code compared to C++ equivalents.
  • Iterators and smart pointers, and other abstractions are zero-cost in Rust. Error handling is also greatly simplified in Rust, and is not autistic like Go. Instead of using Exceptions, Rust instead uses Result<T, E> and can express absence of objects using Option<T>.
  • While object-oriented programming is not necessarily bad, Rust does not allow for inheritance. Instead, structs can only be composed upon each other, and methods are defined in impl blocks for methods. Rust has the equivalent of Java interfaces, called traits.
  • A single style of code formatting exists unlike the largely fragmented C++ code styles, which makes it much easier to just read anyone else's code or have a consistent style when using dependencies.
  • The ecosystem is much more centralised with a single distribution for the compiler (rustc) except for GCC Rust, formatter (rustfmt), package manager and build system (cargo), linter (clippy), and documentation generator (rustdoc). Meanwhile C++ has three different big compiler distributions (GCC, Clang, MSVC), many build systems (most ubiquitous is CMake, others are GNU Make, Ninja, Gradle for C++, Build2, XMake, etc.), language servers (the best is probably clangd), many package managers (vcpkg, conan, etc.) and documentation generators (most ubiquitous is Doxygen).
  • The standardisation process is much less bureaucratic than C++, it is much easier to propose an idea and get it into the language compared to C++. Also the Rust standard library is generally more comprehensive than the C++ standard library which includes a lot of crap no one wants.
  • C and (pre-C++20) C++ still heavily use the preprocessor, even for things like importing code. In C you can't even use modules and import code as modules, you have to use #include which verbatim copies the entire file contents into your source file which is extremely inefficient and wasteful. Also C macros are inferior to Rust macros which can be used for things like code generation, C macros only allow for text substitution which breaks type safety. Meanwhile Rust has things like modules built in directly to the language.
  • Some complain that Rust's package management heavily encourage using dependencies which causes dependency hell. This is partially true, but that's more of a critique of poor coding in Rust.

Some complain that Rust compiles much slower than C or C++. This might be true due to the higher amount of steps in compilation for Rust. If we analyse the steps of C/C++ compilation:

  • Preprocessing (expand all macros and preprocessor tokens, handle all file inclusions)
  • Compilation (compile code to assembly)
  • Assembling (assemble assembly code into machine code to object files)
  • Linking (link translation units to be able to reference other object files, combine all object files into single binary)

Meanwhile, the Rust pipeline of compilation is far more complex. It is as follows:

  • Parser-Expand-Resolve (parse the source code as an abstract syntax tree (AST), expand all macros, resolve all names)
  • Compilation (HIR) (convert the AST to a high-level intermediate representation (HIR) for type checking)
  • Type checking (check type safety, such as ensuring operations are valid, consistency of ownership, borrowing, lifetimes, memory safety)
  • Compilation (MIR) (translate the HIR to a mid-level intermediate representation (MIR), closer to machine code but abstracted from hardware details)
  • Borrow checking (verify that no data races, dangling references, mutable/immutable aliasing violations, invalid references, exist or violate guarantees of ownership)
  • Code generation (LLVM) (generate optimised code from the MIR using Low-Level Virtual Machine (LLVM), generating LLVM intermediate representation (LLVM IR) which is low-level and platform-agnostic, utilise the LLVM backend for inlining, loop unrolling, dead code elimination, etc. and ensure platform-specific optimisation and generate code for target architecture)
  • Assembling (LLVM) (convert the optimised intermediate representation into assembly code specific to target architecture)
  • Linking (combine all object files into a single binary, Rust by default uses static linking but dynamic linking is also possible)

Though, one should also take in to consideration that C++ uses code generation to generate specialised template code and is generally more complex, also the earlier mentioned header inclusion can slow C/C++ compilation significantly.

Meanwhile, there are valid reasons to use C and C++, such as specifically compiling code for very old systems. Also Rust is much younger than C/C++ so the amount of libraries that exist are far fewer. Also, unlike C++, Rust does not support variadic parameters in functions (instead you have to use macros for variadic functions), variadic template parameters, or function and operator overloading. Also to be honest you can just use Java if you are so worried about memory leaks and invalid memory access.

Though, at the end of the day a programming language is just a tool, not an ideology thoughbeit(erm snopes verified this and said this is untrue infact the language you use says a lot about you and can be used a way to identify where a person is from (shitskins using java or python , troons using rust etc)) . Just choose the right language to do the job o algo. Don't use a hammer when you aren't dealing with nails, or something. JUST LET PEOPLE ENJOY THINGS, OKAY???

Example[edit | edit source]

#![feature(random)]
use std::random;

/// Determines whether the tranny should ack based on a given probability.
///
/// # Parameters
/// - `ack_probability`: An integer between 0 and 100 representing the chance of acking.
///
/// # Returns
/// True if the random probability is less than the ackProbability; otherwise, False.
fn should_ack(ack_probability: i32) -> bool {
    let mut prob: f64 = random::random::<i32>() as f64 * 100.0; 
    prob < ack_probability.clamp(0, 100) as f64
}

/// Main function that decides whether to ack or scream TRANS RIGHTS ARE HUMAN RIGHTS!!!!!!!! based on probability.
fn main() {
    if should_ack(41) {
        panic!("ACK!!!!");
    } else {
        println!("TRANS RIGHTS ARE HUMAN RIGHTS!!!!!!!!");
    }
}

Here is another example using the unsafe block. unsafe does not necessarily mean the code within is unsafe, but rather that most guarantees of safety do not apply to that block. In other words, these blocks offer the same level of safety as C.

/// Represents a memory-mapped GPIO control register.
///
/// The `GpioControl` struct is laid out in memory to reflect the structure of the hardware register.
/// It contains a single field `value` that corresponds to the GPIO pin state.
#[repr(C)]
struct GpioControl {
    /// The value of the GPIO register.
    ///
    /// This field represents the state of the GPIO pin. It is a 32-bit unsigned integer where
    /// different bits may control or reflect the state of different GPIO pins.
    value: u32,
}

impl GpioControl {
    /// Creates a mutable reference to the GPIO control register.
    ///
    /// This method returns a mutable reference to the memory-mapped GPIO register. The address
    /// is defined by `GPIO_BASE_ADDR`, and accessing this register allows reading and writing
    /// to the GPIO state directly. Since this is raw memory access, the operation is marked as `unsafe`.
    ///
    /// # Returns
    /// A mutable reference to the `GpioControl` struct located at the specified memory address.
    fn new() -> &'static mut GpioControl {
        unsafe {
            &mut *(GPIO_BASE_ADDR as *mut GpioControl)
        }
    }
}

/// Main function that performs unsafe operations on a GPIO control register
fn main() {
    let gpio: &'static mut GpioControl = GpioControl::new();

    // Writing a value to the GPIO register.
    unsafe {
        gpio.value = 0x1u32;
    }

    // Reading the value from the GPIO register.
    unsafe {
        let gpio_state: u32 = gpio.value;
        println!("GPIO state: {:#X}", gpio_state);
    }
}


Rust is part of a series on
Language & Dialect
Visit the Soyspeak portal for more.

Soyspeak [-+]

Main article: Soyspeak

ThoughKeyedNamesNonsenseInsultsBumoWordfilter'oy

Phrases [-+]
Copypastas [-+]
Miscellaneous [-+]
IRC

Rust is part of a series on Computer Science.

Languages Low Level AssemblyCC++C#Holy CRust

High Level JavaGoPHPPythonSQLBashJavaScriptPowerShellActionScriptScratchRubyLua

Markup HTMLCSSSVGXML
Software Imageboards nusoiVichanYotsubaOpenYotsuba

OSes WindowsLinuxAndroidTempleOS

Other BabybotMcChallengeSystemdMS PaintJS PaintPhotoshopFlash
AI

ChatGPTGeminiGrokVibe codingGenerative AIStable Diffusion

More SoyGNUCGIDDoSGame developmentPiracyRegexDoxingMicrosoftAppleGoogleDataminingWebPArtificial soyduelRatio duelingCustomizationRicingFSLWindows debloating