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?

  • 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.

    • eluvatar
      link
      fedilink
      arrow-up
      6
      ·
      1 year ago

      I like how Java uses it. As a C# dev I wish for it sometimes.