Both zig and go use the dot operator, but I find the ‘::’ operator much more readable.

Vec::new();

Makes it clear that were accessing a static method belonging to the Vec struct/namespace.

Vec.new()

Makes it seem like Vec is an object with a ‘new’ method.

Am I alone in thinking this?

  • Pyro@lemmy.world
    link
    fedilink
    English
    arrow-up
    22
    ·
    11 months ago

    I used to only use C#, and I liked the simplicity of only using one symbol to access any prop/field/method. But now I’ve used Rust for a while I do prefer separating the two for the same reasons you mentioned.

    So no, you’re not alone. Even cross-lang!

  • ono@lemmy.ca
    link
    fedilink
    English
    arrow-up
    9
    arrow-down
    1
    ·
    11 months ago

    C++ was my language of choice for a long time, but I can’t say I’m with you on this one. If I’m going to use Vec, I had better know what it is already. Littering the code with a special double-glyph operator when a dot would do is just needless noise to me.

    (I won’t criticize you for liking it, though. Cheers.)

  • BmeBenji@lemm.ee
    link
    fedilink
    arrow-up
    1
    ·
    11 months ago

    I don’t understand the C++ hate. I’m definitely biased since I learned it before anything else, but the flow of the code and the object-oriented principles just make sense to me. And yeah, I appreciate the scope resolution operator a lot.