News for hackers. Stuff that matters.
Re:Elm in Production: 25K Lines Later by iamwil on Monday July 31, 2017 @03:11AM (#14890048)
Having started using Elm for side projects over 3 years ago, the article is pretty much spot on.

Programming in Elm had been a delight, especially when you let go of OOP and embrace functional concepts and practices. On one hand, you lose mental tools that you've relied on, but you gain the other tools you didn't even know existed before.

Where I really disliked about Elm is when I had to encode or decode JSON. It's a giant royal pain in the ass. Also, when you find you have to break out to JS often for libraries you don't want to write yourself, it's not a good fit--as I found out when write a toy interactive notebook to render markdown in Elm.

But for most SPA that just manipulate form data and communicate with the server, it's a pretty great fit.

Re:Elm in Production: 25K Lines Later by kristianp on Monday July 31, 2017 @03:47AM (#14890168)
Isn't decoding JSON a big part of an SPA though? How do you deal with data from the server?
Re:Elm in Production: 25K Lines Later by enalicho on Monday July 31, 2017 @04:41AM (#14890376)
There exist multiple tools to aid you with writing decoders:

- json-to-elm http://json2elm.com

- swagger-elm https://github.com/ahultgren/swagger-elm/

- elm-graphql https://github.com/jahewson/elm-graphql, https://github.com/jamesmacaulay/elm-graphql

- elm-export https://hackage.haskell.org/package/elm-export

Once you've got the hang of it, it's not that hard either. Just time consuming. That's where json2elm comes in :)

Re:Elm in Production: 25K Lines Later by antouank on Monday July 31, 2017 @03:53AM (#14890186)
Once you handle a couple of complicated cases, you're ready to solve any JSON decoding within minutes. It's just a small learning curve to go through.

Also, once you get the hang of it, you can use it as your safety layer for incoming data. To guard the app from any invalid response.

I've even used GraphQL for one of my projects, decoding worked fine as well.