Elm Compiler

The Elm compiler is a program that transforms the code written in Elm programming language into JavaScript.

Notice the two JavaScript files in the final build box above. Generally, Elm takes in multiple .elm files in our project and compiles them into a single .js file. So why do we have multiple .js files in the final build? The code for our application doesn’t need to be written 100% in Elm. Once you realize what a delightful language Elm is, you will be hard-pressed to write your code in anything else. But even then you can write only a portion of your application in Elm if you choose to do so. In fact, this approach is recommended if you are trying to introduce Elm to an existing project. You can pick a less risky area of your application and write it in Elm. Find out if the Elm code is more fun to write, performs better, and easier to maintain than the existing code. If yes, continue to write more features in Elm. Otherwise, perhaps Elm is not the right fit for your project.

Elm is designed to build reliable web apps that run on a browser. And browsers understand only JavaScript. Therefore, the Elm code has to be compiled to JavaScript. However, in the future if the Web moves away from JavaScript to something else, Elm code will need to be compiled to that instead. As of this writing, we can’t build server applications with Elm. Hopefully, someday we will be able to. When that day comes, Elm code will need to be compiled to multiple targets.

Back to top

New chapters are coming soon!

Sign up for the Elm Programming newsletter to get notified!

* indicates required