

Introducing Elm to a JavaScript Web App - Keats
http://noredinktech.tumblr.com/post/126978281075/walkthrough-introducing-elm-to-a-js-web-app

======
dominotw
Elm

Pros:

\- All the Joys of functional programming .

\- Once you satisfy the compiler you can be fairly sure that code will just
work.

\- FRP saves you from callback hell.

\- Fairly easy Javascript Integration via Ports( also see con on this)

\- Time traveling debugger ( see con about this)

\- Active mailing list.

\- Automatic package versioning which more or less works for the most part

\- Pure render function ( popularized by ReactJS), makes writing/debugging
UI's trivial and painless.

\- "Concurrent" FRP

Cons:

\- Javascript integration is very and tedious. You have to declare all your
ports in main which breaks abstractions. There is "secret" way of integration
via Native modules but this will break if compiler changes ( which does quite
often ).

\- Debugger/reactor won't work if you have ports, basically all non trivial
apps.

\- All the ui components have to be reimplemented since stuff like
jqueryui/webcomponents don't work ( react suffers from this also)

\- No support for isomorphic apps, its a client side only tech.

\- Can't do code splitting. Compiler generates one big blob of js.

\- Constantly changing terminology ( eg: mailbox)

\- IDE's/code editors are on the same level as dynamic languages i.e no code
completion, refactoring ect.

~~~
arianvanp
I think PureScript[0] is a great contender:

\- It generates beautiful javascript code

\- It can separate PureScript modules into nodejs modules

\- It has an even stronger type system than elm . For example, typeclasses

\- has great interop with javascript

\- Because it can compile to node.js modules, and can use node.js libraries,
it's actually possible to write a Universal app (I tend to avoid isomorphic,
as it means something totall different in pure functional programming
languages like PureScript. ([https://github.com/paf31/purescript-
isomorphisms)](https://github.com/paf31/purescript-isomorphisms\))).

One issue I have had so far is that once your project gets big, the compile
times are pretty annoying. But apart from that; a great language!

[0] -[http://www.purescript.org/](http://www.purescript.org/)

~~~
Keats
How big are we talking about for the compile times?

Is there any in-depth recent comparison of elm and purescript somewhere? I
found some links from almost a year ago but I assume it changed a lot since
then.

~~~
purescript
The largest all-PureScript application I know of is SlamData[0], which takes
about 12s for a rebuild, but SlamData uses a _lot_ of modules. For smaller
projects it's much less. It's not great, but performance is one of three main
goals for the current milestone. There is an alternative front-end called psc-
compile[1] which reduces the incremental build times considerably. I hope to
be able to integrate it soon.

    
    
      [0] slamdata.com
      [1] github.com/bitc/purescript/tree/psc-compile/psc-compile

------
Theiceman
I have used Elm for a couple projects recently and the main benefit is it
forces you to program in a maintainable and correct fashion. The community is
active and tries to find the right patterns to use without compromising these
core principles. I think the potential of a language like this for testable
UI's could revolutionize and simplify client side development if it gains
enough momentum.

------
JuanSoto
How would one compare Elm to ClojureScript? I've been learning Clojure for web
development and I really enjoy it. Where does Elm fit into the picture?

~~~
bstrom
This may just give you more questions but you might be interested in this:
[https://github.com/Day8/re-frame](https://github.com/Day8/re-frame)

The readme.md is wonderful.

~~~
Keats
Thanks for that link, I'm planning to learn elm this week and while I really
don't like lips syntax clojurescript seems to be a big player too.

------
unboxed_type
My personal impression is that the language infrastructure is not mature
enough. As of version 2.0 you cant install Elm on Linux platform from npm
because of broken repo link or something (it is known bug but looks like no
one cares to fix it). But even you managed to install it, Elm itself does not
work behind corporate firewall because it rely on Haskell HTTP library which
suck (they fixed this bug in the library but please wait for another Elm
release for this to work).

The language looks very interesting and promising, I am very pissed by the
fact that I had no chance to try it in our latest project because of those
miserable bugs.

------
Cshelton
That's really sweet, I have never checked out elm before. I've been
contemplating going to TypeScript as it has a good amount of es6 support now,
I'll look more at elm though.

I fear something like this though will make it more difficult to hire and on
board new people. I'm currently trying to hire 3 senior/very experienced JS
developers and that's hard enough.

~~~
bjz_
I would jump at the chance. Also be sure to look into Purescript.

------
obilgic
That switch statement and type declaration look beautiful in [0] and seems
like what we try to achieve with babel + flow + jsx... spaghetti

[0]: [https://github.com/evancz/elm-
todomvc/blob/master/Todo.elm](https://github.com/evancz/elm-
todomvc/blob/master/Todo.elm)

~~~
efnx
That's Haskell for you ^

I'm excited that Elm could bring front end web developers to Haskell.

~~~
wheatBread
That's Standard ML for you ^

I'm excited that Haskell could bring more developers to ML-family languages.

~~~
efnx
I'm sure we could keep going, but the point I'm making is that Elm is very
close to Haskell, and if you like Elm you will definitely like Haskell. I
don't know if the same can be said about going from Haskell to Standard ML
because I haven't... yet.

------
federalemployee
I thought this was going to be the Elm email client in a JavaScript app. I'm
getting old.

Elm (lang) looks interesting though.

------
wooby
If you're interested in bringing functional/reactive style code to an existing
application, you might also be interested in splint.js:
[https://github.com/adzerk-oss/splint.js](https://github.com/adzerk-
oss/splint.js)

I wrote a blog post about it recently: [http://adzerk.com/blog/2015/06/splint-
functional-first-aid-j...](http://adzerk.com/blog/2015/06/splint-functional-
first-aid-jquery/)

In a nutshell, it's a jQuery-friendly packaging of the ClojureScript runtime
and the Javelin cell library, usable in existing applications. You basically
write ClojureScript in JavaScript syntax.

~~~
yogthos
>You basically write ClojureScript in JavaScript syntax.

Why?

~~~
wooby
Legacy code remains accessible to cheaper contractors, expense of overhauling
build/deploy in sunsetting legacy app not justifiable. Gives us the ability to
direct most of our effort toward the (Hoplon) all-Clojure/Script replacement.

~~~
yogthos
I suppose that's one reason. :)

------
joshuakarjala
Dan Abramov's Redux (Flux'ish implementation) takes a lot of ideas from Elm -
[https://github.com/rackt/redux](https://github.com/rackt/redux)

