BT

Reduce the Risk of Failure With Elm

| by David Iffland Follow 4 Followers on Sep 29, 2015. Estimated reading time: 1 minute |

In a practical, try-it-for-yourself session at Strange Loop 2015, Richard Feldman showed how his team started using the Elm language to reduce the risk of failure and iterate faster on their web app.

JavaScript developers everywhere have likely encountered the error undefined is not a function. Feldman used this pain point to drive home Elm's ability to improve the developer experience. The Elm compiler will catch many errors that plague raw JavaScript developers. According to Feldman, in an Elm app, "once it compiles, it typically works on the first try with no regressions or runtime exceptions".

When I think about why I like using Elm and why it's such a nice user experience, it's just the little details, the little polish, the little pieces of user experience that make you feel great on a daily basis.

For those unfamiliar with Elm, it's a functional programming language created by Evan Czaplicki, designed to make it easy to build web UIs. It compiles to JavaScript and, like React, uses a virtual DOM to manipulate the interface. According to the Elm Blog, in one benchmark, it's dramatically faster than React.

Bar Graph of Runtime Speeds for TodoMVC app in various languages. Shows Elm as very performant.

Here's what the simplest example of Elm code looks like:

import Html exposing (span, text)
import Html.Attributes exposing (class)


main =
  span [class "welcome-message"] [text "Hello, World!"]

"Everything in Elm is one of two things: immutable data or stateless functions," says Feldman. This funtionalty purity (where the functions have no side effects) is nice in theory, but web developers often have to interact with many other systems. To get around this, Elm has what it calls "Tasks". Feldman says a task is "a data representation of stuff you want done; it's a list of instructions".

Elm can interact with existing JavaScript libraries using "ports". Developers can tip-toe into the Elm waters by swapping out pieces of their app with Elm code, connecting the two with a port.

A video of Feldman's talk is available on YouTube along with the rest of the sessions. Additionally, Feldman has written a tutorial post on using Elm to build a sign-up form.

Rate this Article

Adoption Stage
Style

Hello stranger!

You need to Register an InfoQ account or or login to post comments. But there's so much more behind being registered.

Get the most out of the InfoQ experience.

Tell us what you think

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread
Community comments

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Discuss

Login to InfoQ to interact with what matters most to you.


Recover your password...

Follow

Follow your favorite topics and editors

Quick overview of most important highlights in the industry and on the site.

Like

More signal, less noise

Build your own feed by choosing topics you want to read about and editors you want to hear from.

Notifications

Stay up-to-date

Set up your notifications and don't miss out on content that matters to you

BT