Ashkenas works for DocumentCloud, a Knight Foundation funded organization, producing several open source projects including backbone.js and Underscore.js. He is a two-time winner of the Apps for America contest for his applications Know Thy Congressman and Quakespotter. He also created Ruby-Processing.
Klint Finley: You work for DocumentCloud where you work on several open source projects. What made you decide to create yet another open source project in the form of create CoffeeScript on the side?
If the question is “why is CoffeeScript not a DocumentCloud project?” – it’s because I can’t justify using it for the main DocumentCloud development. Imagine trying to hire someone. “You’ll have to learn to use a new language that we made up…”
What is “literate-programming” and how did you get interested in it?
Literate Programming is an old (ancient) idea pioneered by Donald Knuth, who wrote a book with the same title. The idea is to write your source code as if it were an essay for a person to read, instead of a series of instructions for a machine to execute.
This involves trying to craft your code in a rhetorical style: introducing the big ideas, fleshing out the details in logical sections, referencing relevant portions… At the time, code was often written in a specific order of definition, and a large part of Knuth’s work involved “tangling” and “weaving” the code back into machine-order.
For an example of a Knuth-style program, check out his version of Adventure, in Fortran:
But the interesting thing about literate programming, especially these days, is the use of higher-level languages. Code is interesting as a form of written expression because it has a strange dual audience: you write text which is going to be read both by the machine, and the human reader. And you have to find a way to effectively address both at once.
The entire history of programming language evolution has been a story of being able to address the human reader more and more directly and the machine more and more indirectly as computers get faster and we’re able to get farther and farther away from machine code.
Literate programming is the explicit acknowledgement of this dual audience, and takes a stand on it: We’re going to address the human reader as best we can.
What’s next for CoffeeScript now that it’s passed the 1.0 mark?
Hopefully, stability and uptake. CoffeeScript has been very much a community effort. If you look at the contribution graph.
I’d like to see the language settle down, get all the edge cases in the syntax worked out, and see if we can shrink down and polish the compiler (although right now it’s only a bit over 2K lines of code).
There are a number of advantages (and disadvantages):
- You get to use a more succinct, consistent syntax – my CoffeeScript ports of JS libs often wind up with around 1/3 less code.
- The CoffeeScript you write ends up running as fast as (and often faster than) the JS you would have written.
- The main reason why CoffeeScript ends up being faster for many apps is that you can avoid slow forEach() statements, and get the speed of native for loops for many operations, without having to write it by hand.
- There are also a large number of helpful features in CoffeeScript: correct prototype-based-clases, comprehensions over arrays and objects, bound function literals, safe, lexical variables, destructuring assignment…
And the disadvantages?
So the same tricks, tips, and techniques largely apply.
Does it play nice with frameworks like JQuery?
What are some of the most interesting projects you’ve seen created in CoffeeScript?
There are a number to browse around here… but my favorites:
- riak-js is a lovely Riak client
- stephank’s orona is an amazing HTML5 port of an old tank game. Full game here.
- Coffee-resque is a nice port of the popular Reque background job system.
What programming languages influenced the design of CoffeeScript?
What is your favorite language besides CoffeeScript?
Awesome – that’s a wrap! Unless there’s anything else you’d like to say.
It’s totally not rocket science to try and work on a syntax for an existing language. A lot of folks who haven’t taken compiler classes in college think that trying to do a little language is impossible — and I’d like to disabuse them of that notion. The entire source code of CoffeeScript is annotated with explanations to try and make it easier for newcomers to see how the pieces fit together. I’m always encouraged to see lots of little languages sprouting up.