Hacker News new | ask | show | jobs
by alrlroipsp 1318 days ago
> At first glance it looks a lot like Go

But, this is not at all how go looks:

    fn add(a: i32, b: i32) => i32 {
        return a+b
    }
It looks heavily inspired from the syntax used in rust or zig tho. (fn keyword, variable type syntax, return value)

> what are the differences or use case vs just using Go?

- go has a different syntax, different keywords, different ecosystem and so on.

- go is a general purpose programming language, while wa is explicit in targeting wasm.

I don't see any special similarities more than they are c-style family languages.

1 comments

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