News for hackers. Stuff that matters.
Re:How to use Elm at work by nilkn on Monday July 11, 2016 @03:42PM (#12073763)
Why not just use Haskell for the backend? It's really not much harder than Elm, and it's considerably more flexible and general. Of course, it's lazy, not strict, and you're totally right that records in Haskell suck. But my understanding is that strictness for Elm was chosen mainly to overcome issues with FRP, which it's now abandoned. So I'm not sure if that difference matters anymore.
Re:How to use Elm at work by david-given on Monday July 11, 2016 @04:01PM (#12073967)
There's several reasons, one of the simplest (but not the most trivial) being that I can't share code between the client and the server. For example, data validation. I did a tonne of programming on GWT back in the day, and this was something it actually did well.

Most of the other reasons boil down to Haskell not being Elm --- they work in different ways and solve problems differently. There's always going to be impedance mismatch between the two. (Do I solve this problem with monads or with state-mutation functions?) This is going to use up valuable problem-solving bandwidth which I'd rather spend making the project more awesome.

Re:How to use Elm at work by platz on Monday July 11, 2016 @04:55PM (#12074520)
> Can't share code between client and server

The question was about using haskell on the back end. Also, previous attempts at sharing client and server code in other langs are sophmoric at best. In reality, there will always be a boundary that requires differences in front end and back end code.

> Haskell is not Elm

Doesn't answer the question, circular reasoning at best.

Re:How to use Elm at work by bbcbasic on Monday July 11, 2016 @09:39PM (#12076162)
> Haskell is not Elm

A service isn't a client though. They work in different ways and solve problems differently

Re:How to use Elm at work by phamilton on Tuesday July 12, 2016 @12:43AM (#12076784)
They also, sometimes, solve the same problem. (Cited example: data validation)

There's value in sharing code between client and server. It may not outway the costs, but there's definitely value in doing so.

Re:How to use Elm at work by bbcbasic on Tuesday July 12, 2016 @05:35AM (#12077781)
Yes true. There is the option of ghcjs on the front end, so you can do both in Haskell. And ghcjs is very close to cbc. I think it even emulates the threading model.
Re:How to use Elm at work by moosingin3space on Monday July 11, 2016 @07:16PM (#12075541)
Elm seems to have a much stronger developer UX story than Haskell (just look at how much better its error messages are than ghc's), and the ability to share data models across the frontend-backend border would be awesome -- an end-to-end typechecked stack with easy sharing.

With Elm on the server too, you could easily implement server rendering to initialize the page for fast load times.

Re:How to use Elm at work by zimbatm on Monday July 11, 2016 @04:57PM (#12074534)
With Elm you don't have to import 80 things and active 10 language extension to get anything done. :p
Re:How to use Elm at work by wyager on Tuesday July 12, 2016 @12:21AM (#12076705)
Everything that Elm can do (and more) except structural typing is standard out-of-the-box Haskell.

Most Haskell language extensions just save you some typing or give you some extra verification; they're almost never actually necessary.

Re:How to use Elm at work by bbcbasic on Monday July 11, 2016 @09:41PM (#12076165)
But in Haskell you can get anything done :-)
Re:How to use Elm at work by tmptmp on Tuesday July 12, 2016 @12:03AM (#12076658)
>>But in Haskell you can get anything done :-)

Yeah, only if you are willing to spend anything (e.g. insanely large amounts of time) on it :(

Please correct me if I am wrong, but for any large project, Haskell actually adds more woes (e.g. laziness induced problems, no good debugging support) than the ones it addresses.

The Standard Chartered people had to invent a new language (mu) [1] which doesn't have laziness and the horrors associated with it.

BTW, you can get anything done even in (any Turing complete) assembly language too!

[1] http://anil.recoil.org/papers/2011-cufp-scribe-preprint.pdf

Edit: added the Standard Chartered example

Re:How to use Elm at work by caconym_ on Tuesday July 12, 2016 @02:14PM (#12081205)
> Please correct me if I am wrong, but for any large project, Haskell actually adds more woes (e.g. laziness induced problems, no good debugging support) than the ones it addresses.

If you want to make a blanket assertion like that, then the onus is on you to provide some evidence of it. The fact that a strict dialect of Haskell exists somewhere in the world and is being used for application X is interesting, but it does not support your claim about Haskell's viability as a general-purpose language.

Re:How to use Elm at work by wyager on Tuesday July 12, 2016 @12:32AM (#12076748)
>laziness induced problems

This is like saying that Java has "strictness induced problems". It's true, but probably disingenuous. Obviously large, well-funded strict object-oriented projects have memory leak problems as well (all browsers).

> no good debugging support

One generally doesn't require as much debugging support for Haskell, but it's actually quite nice if you follow a debugging process amenable to pure functional languages. People coming from a Java background want e.g. a breakpoint debugger, which doesn't really make any sense at all in a pure functional language; a vastly superior approach is to do e.g. quickcheck-style checking or input/output debugging on pure functions. If your code is impure, you can essentially debug like normal.

Bugs in Haskell also aren't the same as most of the bugs in other languages; you never get null pointers, for example. Every bug in Haskell is either a logic bug (which can often be debugged purely, and can be minimized by the careful application of types) or an atotality bug (which can be completely avoided by totality/completeness checking, and dynamic debugging of such bugs is getting much better with the new implicit callstack feature added to recent versions of GHC).

Re:How to use Elm at work by phamilton on Tuesday July 12, 2016 @12:50AM (#12076810)
> you never get null pointers

To me, head [] is basically a null pointer.

Re:How to use Elm at work by dllthomas on Wednesday July 13, 2016 @04:35PM (#12089467)
To my mind, it differs importantly in that `head []` is something you basically can't inspect, and so you don't wind up passing it as something meaningful expecting the other side to check for it.

While I think this is an important difference, `head` is still harmful.

Re:How to use Elm at work by bbcbasic on Tuesday July 12, 2016 @05:38AM (#12077787)
You don't need to do head [] but nulls are unavoidable in Java.
Re:How to use Elm at work by tmptmp on Tuesday July 12, 2016 @08:17AM (#12078396)
How can I be sure that some lazy code (may be from some library) may not encounter "head []" at all?

Of course, I can avoid that by avoiding all such libraries.

Another painful thing is the exception handling is also not as clean and clear as, say Java/Python exception handling, AFAIK.

Please correct me if I am wrong here, and I will be a happy camper. In fact, I love Haskell as it has taught me how to think clearly. But I am scary to use it in production, sorry for that.

Re:How to use Elm at work by wyager on Tuesday July 12, 2016 @09:58AM (#12078952)
It's actually quite easy. Enable the completeness checker. It won't let you use head, because it's incomplete. In other words, it will say "stop using head".

What this entails practically is something like a) using safe head, which has type [a] -> Maybe a, or b) using the non-empty list type, or c) using streams, which don't have an empty constructor. There are lots of things you can do, but the general approach is "use pattern matching to cover all cases". The compiler can tell you if you've done this or not, and it you do your program will never crash.

>Another painful thing is the exception handling is also not as clean and clear as, say Java/Python exception handling, AFAIK.

Monadic exception handling is 100x easier than in Java or Python. Java copied Haskell/ML's use of Maybe/Optional for avoiding null pointers in Java 8, but they haven't yet figured out Haskell's use of Either and friends for exception handling.

Handling true exceptions in Haskell outside of IO code is worse than in Java, which is probably what you're thinking of, but most code bases completely avoid it. It's not hard at all. Handling true exceptions in IO is often nicer than Java, because Haskell has well-thought-out primitives like bracket.

Re:How to use Elm at work by tome on Tuesday July 12, 2016 @04:14PM (#12081986)
> Enable the completeness checker.

What's this "completeness checker"?

Re:How to use Elm at work by wyager on Tuesday July 12, 2016 @07:18PM (#12082892)
The -fwarn-incomplete-patterns ghc option.
Re:How to use Elm at work by dllthomas on Wednesday July 13, 2016 @04:30PM (#12089427)
That does not warn about using `head`. It wouldn't even warn about an attempt to define `head`, so long as you do so with a call to `undefined` or `error` (which is effectively what's done in the base libraries).
Re:How to use Elm at work by wyager on Wednesday July 13, 2016 @09:25PM (#12091098)
>That does not warn about using `head`.

You're right, I didn't realize that. Thankfully, `head` is one of the few common functions that's incomplete, and it's usually pretty obvious what they are.

> It wouldn't even warn about an attempt to define `head`, so long as you do so with a call to `undefined` or `error`

1. It's syntactically quite simple to avoid these two.

2. If you're using these, you're obviously aware your program can fail.

3. fdefer-typed-holes was introduced as a better alternative to undefined that warns you when used.

Re:How to use Elm at work by dllthomas on Wednesday July 13, 2016 @10:14PM (#12091260)
It's syntactically quite simple to avoid those two in your own code. You're not necessarily aware that a library you're using is using these.

That said, the community is pretty good at nudging people toward total functions, particularly in commonly used libraries (Prelude notwithstanding). And as you say, it helps that it is generally obvious when non-totality is newly introduced - infinite loops being the biggest exception, but that's unavoidable anywhere you don't have an actual totality checker.

Re:How to use Elm at work by tome on Tuesday July 12, 2016 @02:30PM (#12081319)
> The Standard Chartered people had to invent a new language (mu) [1] which doesn't have laziness and the horrors associated with it.

This is a terrible myth that needs to die. Mu is strict because it was designed to target a pre-existing strict runtime. Nothing at all to do with any perceived downsides of laziness, including space leaks.

Re:How to use Elm at work by bbcbasic on Tuesday July 12, 2016 @12:05AM (#12076667)
Was just jokingly comparing Haskell which is general purpose to elm which is for the web only.
Re:How to use Elm at work by mahyarm on Monday July 11, 2016 @05:31PM (#12074861)
Haskell has compile time problems when used in real project (tm) codebase scales and is hard to predict memory or cpu usage due to it's lazy nature sometimes.

I have no idea if elm is any better in that case, but both things make me scared to use it in production systems.

Re:How to use Elm at work by ruslan_talpa on Tuesday July 12, 2016 @03:48AM (#12077407)
This is a way to introduce space leak detection in your tests http://neilmitchell.blogspot.ro/2015/09/detecting-space-leak... so that you can sleep well and not be afraid of using Haskell in big projects :)
Re:How to use Elm at work by bjz_ on Monday July 11, 2016 @05:51PM (#12075014)
> But my understanding is that strictness for Elm was chosen mainly to overcome issues with FRP, which it's now abandoned

Laziness also requires you to ship a runtime, which is annoying on the web. Plus it's hard to debug performance problems, and you need more language complexity to allow you to opt-out of it. There are ways to opt-in to laziness in Elm via libraries, which seems to be becoming accepted as the right way to do things these days.