Remix.run Logo
▲ hnlmorg 3 hours ago

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 3 hours 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 36 minutes ago | parent | next [-]

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

▲masklinn 24 minutes ago | parent [-]

Yes?

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

▲SrslyJosh an hour ago | parent | prev [-]

[dead]

▲boxed 2 hours 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 2 hours 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/