DEV Community

Discussion on: What do you dislike about your favorite language?

Collapse
 
maniflames profile image
Maniflames

I really like Rust but let's be honest the syntax is pretty ugly 😅

Collapse
 
ghost profile image
Ghost

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.

Collapse
 
maniflames profile image
Maniflames • Edited

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 😂

Thread Thread
 
ghost profile image
Ghost

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

Collapse
 
bryanchance profile image
Bryan Chance • Edited

I've been playing with Rust in the last 5 days and getting frustrated with the syntax. I thought maybe it's just me. It is difficult to understand what a piece of code is doing. I want to use Rust but dammit I'll stick with C/C++ for now. The manual is pretty confusing at many places. I read the whole manual more than twice! I feel the same about Go too. It's the worst.