Funded! This project was successfully funded on June 1, 2012.

Photo-main

Rewrite the CoffeeScript compiler with proper compiler design principles and a focus on robustness and versatility.

Many businesses and individuals rely on CoffeeScript for development of JavaScript applications both large and small. These users are designing their projects with a heavy dependence on the CoffeeScript language and the compiler that defines it. While the compiler has served its purpose so far, the increasingly advanced and important projects that depend on it deserve a compiler that makes use of proper compiler design principles. The goal of this project is to design and build that compiler while preserving the current compiler's exposed interfaces, allowing for a near seamless upgrade for our users. The result will be more robust and easier to maintain because of its straightforward design, and more versatile because of its modularity.

Benefits

  • Don't want your output compensating for a platform you don't care about? No problem. Define multiple sets of (CS)AST -> (JS)AST transformation rules for multiple compilation targets.
  • Hate semicolons in your JS output? Prefer to use tabs for indentation? No problem. Define an alternative grammar for AST->CST transformations to fit whatever output style you prefer.
  • Less prone to bugs like those caused by the various kinds of special-casing in the compiler (which is in turn due to the current compilation strategy).
  • Line number mappings for free!
  • The errors reported by the generated PEG parser will show you exactly what it was looking for and didn't see. No more "Unexpected `{`" errors when you don't even use a `{`. These errors occur currently because the rewriter already transformed your implicit object before the error was produced.
  • Less likely to introduce bugs later, as the components should be less interdependent.
  • Uses standardised intermediate data structures, so integrating with your favourite tools should be effortless.

Improved Compilation Strategy Details

Currently, the compiler consists of a parser, generated by Jison, that builds a CoffeeScript abstract syntax tree (AST). These AST nodes then produce strings by working inward from the leaves.

The improved strategy creates a similar CS AST (though, with more consistent and minimal nodes), and through a series of rewrite and transformation rule applications, produces a JS AST. This JS AST is then transformed into a concrete syntax tree (CST) using either predefined or user-defined rules. The output string can then be easily derived from this CST. I plan on using either PEG.js or language to generate a parser from a provided parsing expression grammar, generating standard JS ASTs that conform to the Mozilla Parser API, and using escodegen to generate a CST or string from the JS AST.

Qualifications

I am a very active member of the CoffeeScript community, participating in language design decisions, bug reports, and, obviously, development. I am also a student at Worcester Polytechnic institute about to receive my MS in computer science, a collaborator for most of the life of the project, and a technical editor on the PragProg CoffeeScript book by Trevor Burnham and Peepcode's CoffeeScript screencast. I am fairly confident that no other person is more qualified to take on this task.

Funding

The funding goal of $12,000 will fund 4 months of full-time development, what I feel is a minimum for completing the majority of the project. The $3,000 per month will be put toward my living expenses and the student loan bills that I will need to start paying off during the project. Additional funding will be put toward additional time if the project is not sufficiently finished in 4 months.

Project Phases

  • Research related technologies, make decisions about what tools to use, and formalise the compilation process
  • Design internal data representations (coffee AST nodes)
  • Define a reasonable subset of CS; extract those tests from the current CS test suite
  • Define transformation rules from (a subset of) CS AST to JS AST
  • Woohoo, time to parse: define a PEG for CoffeeScript
  • Work on escodegen until it can accept grammars for generating CSTs
  • Gradually expand the rules and the set of tests
  • Beta: start using it to compile popular projects, and see if they continue to pass their test suites; prioritise the failing features
  • Pass the current CS compiler's entire test suite
  • Documentation

Free and Open Source

This project will be developed openly. The resultant piece of software will be licensed under the permissive 3-clause BSD license so that it may benefit the entire CoffeeScript community.

More About CoffeeScript

CoffeeScript is a programming language that adds a thin syntactic layer and some higher level features to JavaScript, preserving its semantics when possible, but hiding the ugly parts. Jeremy Ashkenas wrote the original compiler in Ruby, though it is now self-hosted. Since then, CoffeeScript has exploded, becoming the #10 most popular language on Github and one of the most watched repositories of all time.

FAQ

277
Backers
$13,785
pledged of $12,000 goal
0
seconds to go
  • Pledge $1 or more
    You selected

    128 backers

    Everyone gets access to the project, both during development and at the completion of my full-time work.

    Estimated delivery:
  • Pledge $25 or more
    You selected

    110 backers

    Receive a bi-weekly email update that includes project status, goals, and progress.

    Estimated delivery:
  • Pledge $200 or more
    You selected

    15 backers

    Your name (or company name) will be permanently listed in the README.

    Estimated delivery:
  • Pledge $1,000 or more
    You selected

    7 backers

    Your name (or company name) and a URL of your choosing will be permanently listed in the README.

    Estimated delivery:
  • Pledge $3,000 or more
    You selected

    0 backers

    Thanks for funding an entire month of development! Your name (or company name) and a URL of your choosing will be permanently listed in the README. In addition, I will provide 8 hours of consultation on any of your coffeescript or javascript projects. Consultation will be over phone/skype/IM or in person with travel at donor's expense.

    Estimated delivery:
  • Pledge $6,000 or more
    You selected

    0 backers Limited (8 left of 8)

    Wow, thanks for funding two whole months of development! Your name (or company name) and a URL of your choosing will be permanently listed in the README. If desired, I will spend 10 hours over 2 days helping you during your transition to the new compiler from either JS or the old CS compiler. Consultation will be over phone/skype/IM or in person with travel at donor's expense.

    Estimated delivery:
  • Pledge $10,000 or more
    You selected

    0 backers Limited (4 left of 4)

    I'm assuming you are a business. Your company name and a URL of your choosing will be permanently listed in the README. I will come to your place of business (assuming my country isn't at war with yours...) and train your employees to use CoffeeScript. I will then spend the rest of the work week aiding in translating your current code base to CoffeeScript, making sure the current semantics are being preserved. This will serve as an excellent opportunity for your employees to learn how to write idiomatic, correct CoffeeScript code. Travel and hospitality expenses must be paid by donor.

    Estimated delivery:
Funding period

- (48 days)