logoalt Hacker News

julesrms • today at 4:19 PM • 2 replies • view on HN

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


Replies

hnlmorg • today at 4:33 PM

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.

➕ show 1 reply
masklinn • today at 4:27 PM

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.