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?

  • CrypticCoffee@lemmy.ml
    link
    fedilink
    arrow-up
    13
    arrow-down
    6
    ·
    1 year ago

    I don’t agree. Many languages differentiate in terms of standards. In Java, your objects start lowercase, so if you see uppercase, its a static call.

    :: looks nice, I guess, but many languages and standards improve clarity of code.

      • Ephera@lemmy.ml
        link
        fedilink
        arrow-up
        6
        ·
        1 year ago

        Yeah, but does that matter? I don’t think, I’ve ever accidentally broken these conventions, where compiler assistance would have been helpful.

      • CrypticCoffee@lemmy.ml
        link
        fedilink
        arrow-up
        3
        arrow-down
        9
        ·
        edit-2
        1 year ago

        It don’t get past review if it doesn’t follow standards. I’m yet to see a deviation.

        If a language is bad because devs do stupid things, they’re all bad.

    • huginn@feddit.it
      link
      fedilink
      arrow-up
      9
      arrow-down
      1
      ·
      1 year ago

      Also: :: in Java is method reference. In Kotlin it’s reflection.

      I’d say if you care a lot about distinguishing contexts it’s really the job of the IDE to highlight syntax.

      Don’t write code as though you’re going to read it in plain text imo.

    • Ephera@lemmy.ml
      link
      fedilink
      arrow-up
      3
      ·
      1 year ago

      Yeah, kind of curious what Go does here then / what the actual experience is like.
      It abuses casing for public/private, so presumably there’s no way to see whether a given sequence of letters is a variable or a type.

    • lysdexic@programming.dev
      link
      fedilink
      English
      arrow-up
      4
      arrow-down
      2
      ·
      edit-2
      1 year ago

      In Java, your objects start lowercase, so if you see uppercase, its a static call.

      Not really, that’s just the way a specific coding style was specified. You’re free to refactor all your projects to follow any other coding style if you really want to, and your programs will continue to work just fine.