Evan Czaplicki decided about a year and a half ago that his senior thesis at Harvard would be about creating a functional programming language with secure theoretical underpinnings, that is statically typed yet compiles down to JavaScript for use with Web applications.
Today, Czaplicki works at a company called Prezi, which, as the name implies, is creating presentation software it hopes will become an alternative to Microsoft’s PowerPoint—and the language is called Elm. It is an open-source project hosted on GitHub and licensed via BSD3. Elm, which he said he wants to see become both an alternative and a complement to JavaScript, can be found at elm-lang.org.
“The project actually got started at Google,” said Czaplicki, who spent some time there. The company wanted a solution that kept the flexibility of JavaScript by eliminating the weaknesses in the language associated with the building of large applications. “Elm introduced type safety, but you keep the flexibility,” he said. “You can grow code that’s not frail and you can add features to it.”
But Czaplicki said he wanted something that was visible across platforms, and JavaScript is best for that. “Plus, the browser does some work too,” he noted, adding that he did not have to write his own garbage collector, for instance.
The fact that Elm is statically typed “gives you a guarantee that you won’t get runtime errors,” said Czaplicki. “If there’s a bug, it’s because you didn’t understand how to write that piece of code. It’s not a typo.” In JavaScript, you get errors, such as trying to access a field that no longer exists or never existed, he explained. “JavaScript tries, and then moves on. When the bug finally manifests itself, you’re far from where it is. With type safety, the bug is apparent at compile time,” he said.
Using a statically typed functional language makes changing and refactoring code easier, Czaplicki added. It defines things such as, “This object has a certain shape and cannot be mixed with an object of a different shape.” He said this is a core principle in Elm.
It is also why the project is such a good fit for Prezi. “The approach Elm uses is well-suited to presentations. They’re most declarative. ‘Here’s what my frame looks like, and here’s how we step through it.’ It’s a natural fit,” he said.
The elm-lang.org website currently has an interactive compiler through which people can contribute to the project. “Right now, it’s great for experimenting,” Czaplicki said. “In two or three years, it’ll be more ready for a professional project.”
One area that has to catch up is tooling. “There’s been tooling for imperative languages for 20 or 30 years,” he said. “For functional languages, it’s just emerging.”
Czaplicki said people want an online editor, and the project has added the ability to do live coding and hot-swapping, so you can see the change immediately on the other side. “People want type information on all functions as they show up in the editor. It’s getting there,” he said.