
A nice app on Elm street - andreascreten
https://madewithlove.be/using-elm-with-react-a-nice-app-on-elm-street/
======
thepratt
For anyone new trying to get into Elm (as a language/tool), I would look
elsewhere. ReasonML, PureScript, TypeScipt, etc are all better featured
solutions. Having said that, the article is well written and thorough for
anyone wanting to take a look into Elm.

But there are massive problems with Elm itself which make it impossible to
consider seriously. I have and still do use Elm in production, and went
through the nightmare upgrade from 0.18 to 0.19.

1\. Elm ports are not sound. Elm will tell you everything is good but doesn't
do simple checks - as say PureScript does - to see if your port code actually
exists or adheres to the defined contract. There are other tree-shaking
issues, but Elm does not know and does not care about the js you've written.

2\. Evan holds the naive view that everything can be rewritten in pure Elm and
there's no reason not to. An overwhelmingly common use-case is 3rd party
services or tracking libraries where it's impossible to re-implement; these
apparently don't exist.

3\. Elm applications, without a Redux-style (domain-specific to Translator)
pattern, end up being horrendous spaghetti code of everything knowing about
everything. Cmds and Tasks are a pain to work with when they should be
interoperable in some manner.

For small embeddable or personal projects Elm is a fun tool. I don't see it
being more than that until more community involvement is permitted - removing
the dictatorship.

~~~
hombre_fatal
> Evan holds the naive view that everything can be rewritten in pure Elm and
> there's no reason not to. An overwhelmingly common use-case is 3rd party
> services or tracking libraries where it's impossible to re-implement; these
> apparently don't exist.

He quite loudly holds the opposite view: instead of thinking you need to port
everything to Elm (very common urge for newcomers), keep it in JS and use it
over a port.

~~~
thepratt
All the wording in [https://discourse.elm-lang.org/t/native-code-
in-0-19/826](https://discourse.elm-lang.org/t/native-code-in-0-19/826) seems
to indicate the opposite. I'm not saying jQuery bindings are a good idea, but
saying no to _everything_ b/c you don't want jQuery bindings is.

------
jlengrand
I am a back-end developer, and I don't know front-end. I also know very little
of functional programming.

Elm is the only language that I like writing, and where I don't feel in a
state of frustration when I write. It might have a lot of limitations, bu tit
makes me happy. Given that our job is basically to be in a constant state of
half broken code, this makes me a huge fan of the language.

~~~
al2o3cr

        our job is basically to be in a constant state of half broken code
    

In my experience, Elm code is only ever in a state of "horribly broken, won't
compile" or "works". Whether that's a bug or a feature depends on what I'm
trying to do...

~~~
Touche
That's interesting. How does Elm statically know if the logic of your app is
correct? Since I don't know Elm I'll use some pseudocode:

    
    
      if condition
        pourCoffee()
      else
        pourTea()
    

Is Elm able to determine that this condition is flipped the wrong way?

~~~
jasim
Neither Elm, nor any language in the Typed FP family, can do that. What it can
do is to prevent us from making clerical mistakes. That's the surprising thing
I learned programming in Typed FP: we very rarely make logical mistakes. Our
programs are all broken, make no mistake, but they are broken not because we
accidentally swapped a conditional (logical mistake), but rather because we
passed in data of the wrong shape (clerical mistake).

A common clerical mistake which Elm, Reason etc. prevents, is when we grab
something from a list and pass it to another function. What if in a rare case
it is possible that the element doesn't exist? A function deeper in the stack
might crash, or if defensively built, substitute it with an empty value. Both
could be wrong.

By providing more information about our data and our functions to the
compiler, the compiler can ensure our code always follow those constraints.
These constraints are often in our head when using dynamically typed
languages, or even statically typed OO languages. Typed FP helps us make them
explicit in code so the compiler can track it instead of we tiring ourselves
mentally and making a mess of it.

~~~
toastal
Expanding slightly, Elm (as well as others in this family), can create
structures that assert certain rules. In the case of a list being empty, you
can also use ADTs to create nonempty version ala `type NonemptyList a =
NonemptyList a (List a)` where it's impossible to construct without that first
element even if the second list is empty. A lot of languages lack this sort of
feature. Then you can go about your code knowing you neither have to handle
empty nor write a bunch of tests because empty construction is impossible and
this is enforced by the compiler.

~~~
jasim
Sometimes I wonder whether Alan Perlis would mock at us for being Bible
salesmen for Typed FP languages.. yet it is such a quality-of-life upgrade and
a thinking tool that it feels justified to shout from the rooftops :)

------
fortran77
I love Elm, but this tutorial is based on Elm 0.18, and 0.19 is out. There are
some straighforwared but significant changes with how an application is set
up.

If you're just starting out, find a 0.19 tutorial.

~~~
a-saleh
T.b.h. this is the reason why I will probably stay messing around with either
PureScript or ReasonML but stay away from Elm.

~~~
k_bx
Why exactly? Elm 0.19 is out on August 2018, and the only thing that's
expected is 0.19.1 which barely changes anything (doesn't break any api).
Seems like 0.19 is quite settled at this point.

~~~
sacado2
Will my Elm code written today still be maintainable with an up-to-date elm
environment in 3 years? It certainly isn't the case with code written 3 years
ago.

~~~
jweir
Doubtful, but possible. What is highly likely is there will be 1 or 2 upgrades
between now and in 3 years. If history is any indicator these upgrades will be
relatively painless.

The next upgrade, 0.19.1, will be completely backwards compatible.

------
antouank
Been working with Elm on so many projects the last 2-3 years. I don't think
any other js-based framework can reach the benefits that Elm brings. Correct,
readable and sane code at scale. And, like others said, makes front-end coding
enjoyable and confident.

JS is a scripting language, good for small and quick scripts. Shouldn't be
used for anything more than a few hundred LOC.

------
CountVonGuetzli
First time in a long time I actually enjoyed using front-end tech.

Elm sparks joy, similar to Ruby/Rails did back in the day <3.

------
fistOfKross
Been working with Elm quite a lot. Every other web framework I've stumpled
upon in my career appear like utter crap compared to this beauty.

------
jxxcarlson
My own two cents worth on Elm.

I've worked with many languages, beginning with Fortran in my student days
that I had to punch my own cards, then doing Basic, Pascal, C, C++, Python,
Ruby, Javascript, Lisp, Scheme, some Haskell, not necessarily in that order.
I've never had more fun and felt more productive than with Elm. The ability to
do "extreme refactoring" and come out on the other side with everything
working is liberating, exhilarating, and makes code maintainable and growable
over the long term.

Been using it now for three years.

------
jamil7
I think the title should be edited. There is no section that combines Elm with
React, it's mostly used for comparison.

~~~
andreascreten
You are right! I updated the title.

------
k__
How does Elm compare to ReasonReact?

~~~
Anahkiasen
Oooh that's a very hard question :p I'd need to sit down a bit to answer it,
to be honest it could almost be its own article. They both try to accomplish
the same things through very different means with very different backings
(Facebook versus literally one person).

I can already tell you that ReasonML definitely has my preference these days
over Elm, for the simple fact that I can keep using React with it. I love
React, it's one of my favorite frameworks. If you're already familiar with it
you're 50% of the way there to learn ReasonReact, whereas with Elm it really
lives in its own little universe that you need to get familiar with from
scratch.

I find ReasonReact's underbelly a bit messier, and the compiler is not as good
nor as clear as Elm's though. And the whole OCaml layer brings some chaos too,
like the multiple standard libraries available in ReasonML (OCaml's,
ReasonML's, etc) which can all be very confusing when you begin.

So, I wouldn't really know what to tell you, it depends wildly of your
experience, what you like, what you're looking for in the language and so on.
I'd definitely recommend to give both a shot and see what you like as they're
both great languages to me, even if ReasonML has my preference.

~~~
purple_ducks
> the compiler is not as good nor as clear as Elm's though

in the article, you mentioned:

> the compiler is one of the best compilers I’ve ever seen and will not
> compile if it detects that your code is not sound.

It seems like your're judging the entirety of the compiler just on it's user
displayed error messages?

~~~
Anahkiasen
Indeed sorry that's badly worded, both compilers are very good, I meant more
the UX around compilation in general as I'm not apt to judge the compilers
themselves.

------
sacado2
I like Elm as a language, but the community is extremely toxic, and it's not
production-ready yet (version < 1.0, one-person project). Too bad, because
it's a great project.

~~~
crtlaltdel
can you site some sources for the “extremely toxic” community? genuinely
curious

~~~
zinclozenge
richard feldman, evan's colleague, is not exactly a nice person on the
internet. There are several times where he's ranted or had a temper tantrum
for no particularly good reason.

now he alone does not make up the "community", but he's certainly a prominent
member of it.

------
hackerbabz
If I have time off to learn a new language in order to get a new Job, would
Elm be a good choice?

I wonder if picking a niche language would give me an advantage or there would
be too few jobs.

~~~
sacado2
The biggest problem with elm in production right now is that there is no
backward compatibility yet (version < 1.0). Code written in Elm 0.18 is not
compatible with code written in Elm 0.19.

------
gdotdesign
I'm curious if you know about the language I created - Mint
([https://www.mint-lang.com](https://www.mint-lang.com))?

And if you do what is your impression? I created it because I was frustrated
with Elm (more the community than the language itself although the language
has some issues as well).

------
yakshaving_jgt
> But you will still hit regular road-blocks which learning it because of how
> alien some of its paradigms are when coming from Javascript.

I always found this to be a weird take. Elm is "Maybe Not As Good" because the
average JavaScript developer isn't immediately familiar with it?

Maybe we should just be less averse to learning new things, and I don't think
simple syntax swaps really count as new things.

Unrelated: your ToC doesn't work.

~~~
Anahkiasen
I didn't mean that only Javascript developers would be lost, more that Elm
kind of "does its own thing" and as such some of its errors or mechanics can
be a bit cryptic and require some more experience with the language.

It's not a language you can pick up and go as easily as Javascript is more
what I meant, _in my opinion_ at least unless, you're already familiar with
pure and strictly typed languages.

~~~
yakshaving_jgt
I don't think Elm does its own thing. The ideas used in Elm are more
"discovered" than "invented" (at least relative to JavaScript), if you're
familiar with that line of thinking.

I also don't think its errors are cryptic. Elm's error messages are best in
class.

> It's not a language you can pick up and go as easily as Javascript

I don't agree with this either. After having taught people Elm, and also
JavaScript as a first language, I don't think mutability is _more_ intuitive
to a beginner.

------
kryptiskt
Are mere users still not allowed to interface with JS from Elm? I lost all
interest when that came down.

~~~
neoberg
I don't think there will ever be a way to interface js directly from elm or
vise versa. Ports are the only way.

~~~
jlengrand
Ha, OP meant directly? Well AFAIK that is simply not possible, to keep the
purity of Elm programs. All has to go through the Elm architecture. Or am I
mistaken?

~~~
neoberg
Sorry for the late answer but yes it's not possible to keep elm's purity and
safety while having a direct interface to js.

------
m000
This is the only Elm I know:
[https://en.wikipedia.org/wiki/Elm_(email_client)](https://en.wikipedia.org/wiki/Elm_\(email_client\))

~~~
KurtMueller
Every post on Hacker News regarding Elm the language inevitably includes this
post about Elm the email client.

~~~
m000
TBH this is the first time I've heard about Elm, the language. I was wondering
why nobody else had made the joke, so I took a stab at it.

