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 in the Building a Simple Page with Elm section.

$ elm make src/HomePage.elm --output elm.js

We asked elm make to compile the code in our Elm file to JavaScript. 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.

Note: 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 is one of the reasons why 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