Elm Runtime

The Elm runtime is a system designed to support the execution of programs written in the Elm programming language. The runtime is part of what makes Elm so powerful. It’s all the code that Elm runs behind the scenes, so that we can write programs describing what we want to accomplish and not worry about how Elm executes them. You can see it in action by looking at the output of the command we ran earlier:

elm-make HomePage.elm --output elm.js

We asked the Elm compiler to compile the code in our Elm file (HomePage.elm) to JavaScript (elm.js).

elm-make is a build tool that uses the Elm compiler behind the scenes. More on this later.

If you look inside the elm.js file, you will realize that it contains thousands of lines of JavaScript code. But, wait a second – we didn’t write a ton of Elm code when we built our simple home page. It was barely fifteen lines of code. What’s going on here?

That’s where the Elm runtime comes in. The elm.js file contains not only the code we wrote, but also the entire Elm runtime and all the other Elm packages we installed. The browser understands only JavaScript. So every piece of Elm code must be transformed to it including the code for the runtime itself. The end users of our application won’t even know that Elm was ever involved in its creation.

This book won’t cover any of the code inside the Elm runtime. We don’t have to drop down to this level at all to understand how to build complex applications in Elm. That’s one of the reasons Elm is such an easy-to-use language: the creators of Elm have done a lot of the hard work for us. We just build on top of all the features that are already written for us in the runtime.

Back to top

New chapters are coming soon!

Sign up for the Elm Programming newsletter to get notified!

* indicates required