News for hackers. Stuff that matters.
Re:Zig: programming language designed for robustness optimal... by himom on Wednesday May 30, 2018 @05:04AM (#17186189)
Personal taste, not factual One-True-Way™

It looks on the surface like almost Rust meets JS with a sprinkling of Ruby/Smalltalk.

Semicolons in 2018, really? Indentation and line-oriented parsing makes code more beautiful. Heck, in general, enums, arrays and dictionary literals shouldn’t even need commas if there’s one tuple per line. Extra typing is a waste of time and clutters-up code with distracting, Christmas ornament “blink tags” that go “Ho, ho, ho” when anyone walks by.

    # package name is the same as the directory path
    # module name is the same as the filename sans extension
    # big modules can be broken up into separate include files

    con X: int = 6   # constant

    var M: int = 17  # module-public variable

    mix any          # module-private mixin
        λ   any? -> bool
            each {x| if (Block? ? yield(x) : x): return true}
            false

    ext []: mix any  # module-private type extension

    typ T: int[10][8]
        λ Zero? -> bool: any? {x| x.any? {y| y == 0}}

    typ S
        a, b: int
        x, y: float
        s[7..6], t[5], u[4..2], _[1], v[0]: byte

        λ   Good?  -> bool: xGood? & yGood?   # no & / && distinction, precedence by expression type
        λ   xGood? -> bool: x > 0
        λ   yGood? -> bool: y > 0

    uni Q        # union
        I: int
        F: float

    λ   thisIsPrivate(x: int) -> int
        x + M + 1

    λ   ThisIsPublic(x, y: float) -> float
        π * (x + y - X)
Re:Zig: programming language designed for robustness optimal... by flohofwoe on Wednesday May 30, 2018 @11:01AM (#17188206)
That's just your personal opinion, obviously. You need some sort of separators for putting several statements on the same line anyway, and requiring them everywhere is better than Javascript's or python's optional semicolons. Also I guess zig's main audience is C programmers, and semicolons are not one of the problems that need fixing in a "better C" language.