Hacker News new | ask | show | jobs
by bentheklutz 1316 days ago
There is a six character difference discounting the fact that one calls the type i32 vs Golang's int32; four are punctuation that may or may not be required for ability to parse correctly and 2 are from "fn" -> "func." Each of the common tokens is arranged in the same order relative to one another. If one affords themselves the use of "type i32 int32" in Golang, then it is

    fn add(a: i32, b: i32) => i32 {
        return a + b;
    }
vs

    func add(a i32, b i32) i32 {
        return a + b;
    }
Compare with a syntax like C, C#, or Java where you have tokens in the declaration in almost the reverse order

    i32 add(i32 a, i32 b) {
        return a + b;
    }
The two (Golang and Wa) are certainly distinct, but I would say they are closer than simply both being C-style for this particular case at least.
1 comments

The ":" and "=>" are almost definitely superfluous, parsing "a: i32, b: 32" and "a, b: i32, c: i64" is no more difficult as parsing "a i32, b i32" and "a, b i32, c i64".

The same is true for colons in Python: they're not really necessary but provide slighlty better readability plus syntax highlighters can get away with using regexes, I guess.

Yep. In fact "a i32" is also legitimate, for now.