Arc Forumnew | comments | leaders | submitlogin
3 points by manuelsimoni 1622 days ago | link | parent

As to using JSON source. Yeah, it's a bit ugly, and you have to type more than with S-expressions. BUT: the typing overhead is constant, so I don't really worry about it. After all, the real typing savings come from the macros that are enabled by this syntax.

What I really like about it is that by using JSON as syntax, Wat is JavaScript on a fundamental level. Wat can coexist within JS files, heck even within single JS functions. The ease of deployment enabled by this is immense.

2 points by shader 1622 days ago | link

Yes, that is a nice feature. I also like the fact that it results in an extremely small base, and more separation-of-concerns. Someone else can write an sexp to json parser rather easily.

I'm just lazy enough to wish that someone else had already done so :P


3 points by rocketnia 1622 days ago | link

"I'm just lazy enough to wish that someone else had already done so :P"

It's funny, I've done exactly that recently, with the same goal of getting away from JavaScript with as little cruft as possible. My goal was to make a hackish little language (nevertheless better than JS) and then make a better language on top of it.

Awkwardly, by the time I had a nice reader, I realized I didn't have any particular semantics in mind for the little language! So I decided to work on the semantics I really cared about instead. :-p Although this semantics is still incomplete, the reader is there whenever I'm ready for it. Maybe it could come in handy for Wat.

I've put up a demo so you can see the reader in action:

It's part of Era (, and specifically it depends on the two files era-misc.js and era-reader.js.

It's yet another read-table-based lisp reader. Every syntax, including lists, symbols, and whitespace, is a reader macro. My implementation of the symbol syntax is a bit nontraditional, because I also intend to use it for string literals.

(For future reference, this is the most recent Era commit as of this posting:


2 points by Pauan 1622 days ago | link

You could also use Nulan's parser:

I specifically designed it so it can run stand-alone, without any dependencies on the rest of Nulan. It takes a string and returns a JS array of strings, numbers, and Symbols. You can easily write a simple function to transform the output so that it's compatible with wat.

You're also free to modify it, though I'm not sure what license to use for Nulan. It'll probably be either the BSD/ISC license or Public Domain.