views:

104

answers:

1

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 terms mean? Why is there backlash against adding them?

+7  A: 

Syntactic sugar is additional syntax added to a language in order to make it easier 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.

(edited)

Evan
what exactly are macros? thanks btw!
Shawn Simon