News for hackers. Stuff that matters.
Re:Compiling JSX with Sweet.js using Readtables by jannes on Wednesday July 02, 2014 @04:16PM (#7979436)
Isn't Facebook's own jstransform library (which is used by their JSX compiler) supposed to be composable already? They have various ES6 transforms in their repository. Plus, there are JSX transforms in the React repository. There are also some third-party transforms on Github – for example es6-destructuring-jstransform.

Could anyone highlight what the differences between jstransform and sweet.js are?

jstransform: https://github.com/facebook/jstransform/

es6-visitors: https://github.com/facebook/jstransform/tree/master/visitors

jsx-visitors: https://github.com/facebook/react/tree/master/vendor/fbtrans...

es6-destructuring-jstransform: https://github.com/andreypopp/es6-destructuring-jstransform

Re:Compiling JSX with Sweet.js using Readtables by jlongster on Wednesday July 02, 2014 @04:40PM (#7979595)
There's a big difference: that's basically just a pipeline for AST tranforms. That's not very hard. Basically just a bunch of different JS libraries that you hand an AST through.

That's not actually that useful. In my post, I mentioned adding syntax for literal persistent objects, using something like Mori data structures. The syntax could look like this:

* #[1, 2, 3] <- persistent vector

* #{x: 1, y: 2} <- persistent map

An AST pipeline makes the "analyze" phase extensible, but it doesn't do anything to the parser. You can't actually add syntax, ever. So it's just not that useful for extending the language. It's good for something like implementing various parts of ES6.

Actually, it's even better for something like types or modules, which really need the whole AST. But in my opinion, everything else is better as macros.

sweet.js works on a tree of tokens, and it allows extending actual syntax. It's also way easier to transform code because it has a pattern matching language and you don't have to manually wrangle AST nodes.

Lastly, sweet.js keeps track of scoping, and in the future it will have modules, so you will be able to do something like:

``` import JSX from "jsx-reader";

import # from "mori";

// code ... ```

And those language extensions are only available inside the module. Everything is scoped.

Re:Compiling JSX with Sweet.js using Readtables by davedx on Thursday July 03, 2014 @04:29AM (#7982077)
"Reliable source maps" - going to give this a try. If it works I'll buy you a beer.
Re:Compiling JSX with Sweet.js using Readtables by modarts on Monday July 07, 2014 @04:15AM (#7997647)
Where can I check out the macros for persistent data structures? That sounds awesome
Re:Compiling JSX with Sweet.js using Readtables by chc on Wednesday July 02, 2014 @04:32PM (#7979550)
To my understanding, JSTransform is essentially a toolchain for writing transpilers, while Sweet.js is a macro system for JavaScript. They both fall into the "things that allow you to output JavaScript from a file with user-defined constructs," but JSTransform is more "tool"-oriented while Sweet.js is essentially a language that's a superset of JavaScript with Scheme-ish macros.