What does Brendan Eich mean when he speaks about adding sugar and macros to JavaScript?
I'm currently reading Coders at Work, and I'm at the chapter interviewing Brendan Eich. It's a little dense compared to the preceding chapters, to say the least. Around page 144, he talks about adding sugar and macros to JavaScript. What do these ter开发者_运维问答ms mean? Why is there backlash against adding them?
Syntactic sugar is additional syntax added to a language in order to make it easier to read/write (see http://en.wikipedia.org/wiki/Syntactic_sugar).
My recollection of what Eich was discussing is that he wanted to add syntactic sugar to the language now so it would be easier to use in the near term but do so in a way that would allow that new syntax to be replaceable with macros in the future.
Macros are basically code that you write which take code for input and emit code as output. They often look similar to functions but differ in that they are performing transformations on the code itself. Reading about Lisp macros here for example would provide a more in-depth explanation.
精彩评论