Lately I've been doing some back and forth between JavaScript and Sugar source code. In some places I rewrote the JavaScript in Sugar as I was expanding the code, and found myself removing syntactic elements -- the result is quite interesing. Here is the original JavaScript code

$(".do-save").click(function(){var l=;$("li").each(function(){l.push($(this).text())});save(l)})

And then the Sugar version

$ ".do-save" click { var l= ; $ "li" each {l push ($(target) text ())} ; save (l) }



The exercise of removing unnecessary syntax (like function()) and replacing parens by spaces was quite satisfying, and I think the result speaks for itself.

However, there is still some room for syntax simplification to be done on this part of the expression

$ "li" each {l push ($(target) text ())}

where I would like to see something along the lines of

$ "li" each {l push ( $ `target text ! )}

The additions made to the syntax would be

Although these two syntactic forms are not common, the backquote is used in Lisp to escape interpretation, and the exclamation denotes a command (an invocation).

I guess some people will say that we can't simplify something by adding new elements, but for lack of a better word this is still how I would discribe my goal in evolving Sugar's syntax. Being a visual person, I try to use a "visual" approach to designing Sugar's syntax, and make use of whitespace and simple punctuation elements to add more rhythm to reading the code. I often think of programming languages as textual interfaces, and in this respect, syntax deserves as much design as user interfaces do nowadays.

Then again, there are the questions of style (some people like indentation, some people like braces) and references (some people know Java, some people know Smalltalk). For me, what's important despite the contextual elements is consistency -- the first users of vi may have not liked its style or its references, but making the small effort of using it for some time, even if it looks and feel weird is sufficient to give you a feel that there is an underlying consistency build by careful design.