Remix.run Logo
▲ julesrms a day ago

Very nice.

Having done a bit of staring-at-WASM while building a compiler, I never stopped being annoyed by the question of who came up with that terrible parentheses syntax. I could never see how it made any sense for any use-case.

Obviously the very top-level parser for the parenthesis stuff is simpler than a parser for a more complex syntax like Wax's. But that is a tiny part of the parser's job, and the savings are marginal. Just because you start by parsing the text into a simple node tree, you still have to check that tree against the implicit syntax that you're expecting it to conform to, and a lot of that checking could have been avoided by pushing it into the actual syntax of a nicer language. They already have a binary format, so the whole point of this text format is to be human-readable, which it absolutely isn't. So the compromise it makes to make the parser very slightly simpler just seems mad to me. Anyway, end of rant..

▲hnlmorg a day ago | parent | next [-]

WAT is just Sexpr isn’t it?

There’s a lot of people, myself included, who quite like s-expressions. And it’s not all that surprising that WAT is LISPy given JavaScript was originally intended to be a LISP too.

▲masklinn a day ago | parent | next [-]

It's just sexpr but it's a rough sexpr since it's an exact translation of the bytecode:

    (func $add (export "add") (param $x i32) (param $y i32) (result i32)
      (i32.add (local.get $x) (local.get $y)))
In clojure using native annotations, that would be along the lines of

    (defn add ^int [^int x ^int y]
      (+ x y))
▲yawaramin a day ago | parent | next [-]

WAT was never intended to be a high-level language like Clojure, it's a text representation of WebAssembly.

▲masklinn a day ago | parent [-]

Yes?

The point is that while "WAT is just sexpr" it's not exactly a great lisp, or experience.

▲yawaramin 11 hours ago | parent [-]

Yes?

My point is that it was never designed to be. So measuring it against that standard doesn't make sense.

▲masklinn 6 hours ago | parent [-]

It makes complete sense given having something writeable is the entire point of wax and the person I replied to (and they’re not the only one) complains about the existence of wax because “wat is just sexps already“, missing the experience for the parens.

If you want to complain about the standard they set, complain to hnlmorg and the others sexp idiots.

▲hnlmorg an hour ago | parent [-]

That wasn’t what I said.

You’re getting angry at a conversation that only exists in your head.

▲SrslyJosh a day ago | parent | prev [-]

[dead]

▲gavmor a day ago | parent | prev | next [-]

Yeah, "user-friendly" here just means non-homoiconic, Algol-style.

▲boxed a day ago | parent | prev [-]

> given JavaScript was originally intended to be a LISP too.

Isn't that basically just apocryphal handwaving? Javascript doesn't look like a lisp in any way, not syntactically obviously, but not behaviorally either. To say that he aimed for a lisp with C ish syntax either means he failed extremely bad, or that he thought lisp was shit.

▲masklinn a day ago | parent [-]

It's a touch more complicated but according to Brendan Eich[0]

- he was originally hired to "do scheme", management believed they needed to embed a programming language and he was sold / believed that was an option

- by the time he got moved to the client and could work on scripting, Netscape was trying to get Java in Navigator (for the browser components), and management mandated a java-ish language for frontend scripting

- Eich got first-class functions from Scheme, and Self prototypes as an implementation detail to get an object model, as well as java's Date API and the primitive/object split

[0] https://brendaneich.com/2008/04/popularity/

▲masklinn a day ago | parent | prev [-]

As the essay notes, wat was mostly designed as a pretty printer, not necessarily a pretty one but one which would be clear to the compiler writer, such that they could cross-check and debug their codegen.

▲julesrms 6 hours ago | parent [-]

Sure, but I was that compiler writer, and it was a PITA to read!

My point is just that they could easily have chosen a more compact, readable format, and the extra effort that would have taken would have been really small, especially when you think just how widely used it was going to be.