Reading about Sweet.js made me really, really want such a thing in Python. I recognise that such a thing would run completely counter to Python's 'no magic' cultural values, but structural search-and-replace seems such an intoxicatingly powerful tool, I'd like to at least have the option to abuse it.
Sweet.js - Sweeten your Javascript (by Mozilla)
21–30 of 30 posts
Re: Sweet.js - Sweeten your Javascript (by Mozilla)
#22Re: Sweet.js - Sweeten your Javascript (by Mozilla)
#23Re: Sweet.js - Sweeten your Javascript (by Mozilla)
#24What are "hygenic macros" and why we should import them from Scheme and Rust?
Hygenic macros are limited to 'safe' operations. They let you extend the language without creating opportunities for incredibly complex and hard to debug stuff like you can do with un-hygenic macros, for example C macros.
Re: Sweet.js - Sweeten your Javascript (by Mozilla)
#25A technical question: how do they get require()ing .sjs files to work, as opposed to compiling and require()ing the output? Is there some way to add hooks that change the behavior of require() to insert a compilation step?
http://nodejs.org/api/globals.html#globals_require_extension...
Re: Sweet.js - Sweeten your Javascript (by Mozilla)
#26A technical question: how do they get require()ing .sjs files to work, as opposed to compiling and require()ing the output? Is there some way to add hooks that change the behavior of require() to insert a compilation step?
There is indeed. Take a look at require.extensions: http://nodejs.org/api/globals.html#globals_require_extension...
Now I'm looking at the sweet.js source where they register the extension, and there's some additional magic I don't recognize; is module._compile documented somewhere that I just can't find, or is that getting added somewhere in the sweet.js code?
Re: Sweet.js - Sweeten your Javascript (by Mozilla)
#27Earlier quoted context omitted.
There is indeed. Take a look at require.extensions: http://nodejs.org/api/globals.html#globals_require_extension...
Neat! With a little bit of googling, it seems CoffeeScript can do the same thing. That lowers the barrier-to-usage of compile-to-js languages enormously! Now I'm looking at the sweet.js source where they register the extension, and there's some additional magic I don't recognize; is module._compile documented somewhere that I just can't find, or is that getting added somewhere in the sweet.js code?
As an aside, here's the relevant bit of code that loads the (already compiled) source as a module: https://github.com/joyent/node/blob/master/lib/module.js#L40...
Re: Sweet.js - Sweeten your Javascript (by Mozilla)
#28Earlier quoted context omitted.
So use Perl :) The thing about Perl is that there is supposed to be more than one way to do it. Which enables you to mix-and-match different paradigms in a way that the Python philosophy doesn't seem to welcome. Or just use a Lisp.
Perl 6 even comes with hygienic macros, I believe. That should be much nicer than source filters in Perl 5.
Re: Sweet.js - Sweeten your Javascript (by Mozilla)
#29LLJS and Now Sweet JS Seems like mozilla is trying to answer TypeScript. Which is really good.
But they are not solving the same problem at all! This should be a superset of TypeScript. Since TypeScript is a superset of JavaScript, you would not be forced to use TypeScript if you didn't want to. But how can I use this with TypeScript currently?
Re: Sweet.js - Sweeten your Javascript (by Mozilla)
#30Earlier quoted context omitted.
That not correct -- no new features are being added to ES6 now. Macros are possible for subsequent versions, though.
Ah ok, I think I first heard of it here and thought it would be included in the spec: http://brendaneich.github.com/Strange-Loop-2012/#/41
http://brendaneich.github.com/Strange-Loop-2012/#/41