loading...

re: What do you dislike about your favorite language? VIEW POST

TOP OF THREAD FULL DISCUSSION
re: I really like Rust but let's be honest the syntax is pretty ugly 😅
 

why? I've worked with Python and a bit of C and C++, doesn't look ugly to me, looks kinda generic actually, nothing extravagant.

 

I think I'm not used to ' as a language feature (other than strings) so lifetimes specifically hurt my eyes in the beginning. Example from the book:

fn longest<'a>(x: &'a str, y: &'a str) -> &'a str {
    if x.len() > y.len() {
        x
    } else {
        y
    }
}

There is a lot of memory related stuff in rust as well so tbh you'd most likely use it in combination with more features like traits so it'll look more like this (also en example from the book).

use std::fmt::Display;

fn longest_with_an_announcement<'a, T>(
    x: &'a str,
    y: &'a str,
    ann: T,
) -> &'a str
where
    T: Display,
{
    println!("Announcement! {}", ann);
    if x.len() > y.len() {
        x
    } else {
        y
    }
}

It's not the worst but I understand jokes like these even though rust is nice 😂

I guess that lifetimes can be a lot to take in, but in my experience is not very often you have to make lifetimes explicit, the compiler usually infers them, I also used C in my university courses so I'm kinda used to pointers and their notation. I have to admit that when I started with Rust I just cloned everything and it moved it was a String, I've slowly started to replace clones and Strings with references so I'm seeing more references in my code, but also getting more used to them. I think is like the smell of your dog or the smell of garlic, you get used to it, the rest, not so much XD

code of conduct - report abuse