Tern: intelligent JavaScript editing

Tern is a type inference engine and set of editor plug-ins that aims to dramatically improve JavaScript programmers' productivity. Help make Tern open source.

Tern in flight

What is Tern?

Tern is our ticket to cross-editor, deep JavaScript integration. It is a code analysis engine that can be hooked up to relative thin, simple, editor-specific plug-ins in order to provide autocompletion, function argument hintsjump-to-definition, and various automatic refactoring operations.

There is a live demo on the project website, as well as some more technical information. If this crowd-funding campaign reaches its goal, I will make Tern open source, and deliver Tern plug-ins for Emacs and Vim.

[Update: The main goal was reached. The code has been open-sourced, and work is ongoing on the editor plug-ins.]

[Update: The campaign is finished. Smashing success. I've removed some perks, as further backers won't be able to receive them.]

Stretch goals

Now that 12,000 € has been raised, I will add built-in support for node.js. This involves making the system understand the require function and exports variable, and writing descriptions of all the built-in types and functions in node's standard packages.

If 15,000 € is raised, I'll write plug-ins for two additional editors. Which editors these are will be determined by a vote among the sponsors. Voting is in progress here, if you want to see which editors are likely to be chosen.

Who am I?

I am Marijn Haverbeke, the author and maintainer of Eloquent JavaScript (a book) and CodeMirror (a code editor). I've been hacking on programming languages and programmer tools for most of my career. Whenever possible, I've released this work as open source software.

And I'd like to continue that way—open-sourcing my hacks so that the maximum number of people can benefit from them and contribute to them. But bills have to be paid, so I'm trying an intermediate model: I write software, the crowd pays me once, and the software remains open forever after.


Type inference in a dynamic language like JavaScript is not an exact science. Many things don't have an unambiguous type, and it is possible to construct types at run-time using the whole complexity of the language. Thus, though Tern's output is usually correct and useful, there are programs where it will fail to find a type for some expressions, or even come up with the wrong type.

In short, though I think Tern is already a huge help in its current half-finished form, and you can check out the demo to see for yourself, I am not claiming that it will ever fully understand all possible JavaScript programs.

The goal

The funding goal is computed to allow me to work for three months at about half the income I make with my usual consulting work. (The other half is made up in the satisfaction of building the thing I want to build.) In addition, I'll spend some of it to engage a Vim expert to help me build the Vim plug-in in a way that fits the culture for that editor.

About half of the work has already been done—the core inference engine is solid enough to give good results on some big, complicated codebases, and the server component—which runs queries and caches inference results in order to be able to respond quickly—is mature enough for use in a demo. The work ahead is to finish the server, write editor plug-ins, and keep improving the inference engine as it is tested on new code and new blind spots are found.

The campaign is set as an all-or-nothing (fixed funding) campaign. That means that if it does not reach its goal, everybody gets their money back. When this happens, I will keep Tern closed and sell it as commercial software.



Image credit for bird used as campaign logo: Kersi Nebelsiek, page header: Alan Vernon

Created By: