back to home

rust is a language

obviously just my opinion, please don't dox me

over the summer i got into rust
not of my own volition, but because my friends said it was a great tool for building CLIs
and i was thinking of building a CLI for automatically running, checking, and diffing usaco + cf solutions
so like an absolute buffoon, i went along with it for whatever reason

the very next day, they just disappeared and left me, the only one without any prior rust experience, to rot in backlog hell

"well piss", i thought, "but frick it, i made a goddamned commitment and i'm going to do this"

what a mistake that was

the bane of my existence

god, i hate this cheeky little crab with a vengeance

rust starts out pretty fine, actually
(btw if anyone's curious i learned it from here)

```rust fn main() { println!("hello world!"); } ```

alright, the exclamation mark seems a bit weird, but other than that it's just a standard language right?
right?

but anyways, rust does has some pretty neat qol stuff, like:

  1. no parenthesis for control flow statements
  2. builtin nice tuple support (ahem, c++, ahem)
  3. sick range syntax with inclusivity/exclusivity
  4. dynamic type inference with some exceptions, but still it's really good for a statically typed langauge like rust
```rust for i in 1..=10 { let nice_tuple = (1, 'c'); let x = nice_tuple.0; let y = nice_tuple.1; } ```

yeah, pretty cool!

but just as you think it's all fine & dandy, and think you're ready to take on functions:

```rust fn bruh_moment(x: String) { let y = x; } fn main() { let x = "bro...".to_string(); // <- also very stupid bruh_moment(x); dbg!(x); } ```

rust just punches you in the face with THIS:

```rust error[E0382]: use of moved value: `x` --> src/main.rs:8:10 | 6 | let x = "bro...".to_string(); | - move occurs because `x` has type `String`, which does not implement the `Copy` trait 7 | bruh_moment(x); | - value moved here 8 | dbg!(x); | ^ value used here after move For more information about this error, try `rustc --explain E0382`. ```

WHAT THE HECK??

TURNS OUT, if you just define a raw type (other than primitives), the function TAKES OWNERSHIP of the value and you just CAN'T USE IT AGAIN

but at least in this sample code snippet, you can fix it by doing this:

```rust fn bruh_moment(x: &String) { let y = x; } fn main() { let x = "bro...".to_string(); bruh_moment(&x); dbg!(x); } ```

thus embodies the essence of rust:

it's memory safe, but at what cost?

anyways, i decided to practice rust by redoing advent of code 2015, which i'd previously done in python
(you can find the src here)

and thus began a series of interactions with the rust compiler which mostly went like this:

american psycho

and i feel like that took away half my sanity

it's not just the ownership system- even simple stuff like converting to an integer is kinda convoluted

```rust let i = "1".parse::<i32>().unwrap(); // bruh just give us a global function or something ```

in fact, i've had so many problems with rust's "i'm not like other languages" style that i've compiled a list of grievances (very long!!!)

anyways, my main problem with rust is the sheer anxiety it gives you through how many things it makes you consider when writing your code

actually i wouldn't say problem, more like just it's different, and it's gonna take a hell of a long time for me to get used to it.