News for hackers. Stuff that matters.
Re:Why Elm? [pdf] by mistersys on Monday May 08, 2017 @03:13PM (#14294634)
I've tried to use Elm and The Elm Architecture on a project before, but I gave up.

The Elm Architecture makes it very easy to create small type safe components, but it forces parent components to manage the state + structure all children components. This makes it hard to use a component and to separate concerns.

In order to create a list of stateful children, you must:

1. Add a list of the child states to the component state, event if the parent component doesn't care about the child's state.

2. Handle adding + removing child state's manually

3. Map all scoped child state updates through your reducer, adding a constructor to your action type

4. Finally, map each of the child state's to the component's view.

You end up big types and match expressions that just manipulate lists. I have yet to see a FRP library that allows you to just use a component without introducing boilerplate.

Re:Why Elm? [pdf] by rtfeldman on Monday May 08, 2017 @04:32PM (#14295331)
> In order to create a list of stateful children, you must:

This is trivially debunked: here is a 4,000 LoC open-source Elm SPA with small, type-safe reusable views that have state and don't do all this. :P

https://dev.to/rtfeldman/tour-of-an-open-source-elm-spa

Plenty of counterexamples in there.

Here's one. https://github.com/rtfeldman/elm-spa-example/blob/master/src...

Here's another. https://github.com/rtfeldman/elm-spa-example/blob/master/src...

Here's yet another. https://github.com/rtfeldman/elm-spa-example/blob/master/src...

Re:Why Elm? [pdf] by mistersys on Monday May 08, 2017 @06:32PM (#14296246)
The parents of each of these elements have to manually map the state changes, they have to be aware of the internal state of the components, just as I was saying.

Check this out: https://github.com/rtfeldman/elm-spa-example/blob/master/src...

Go to the bottom, see how it manually maps the child events of the feed update? You have to duplicate that code for every single child component. All the other steps I described are there also.

Re:Why Elm? [pdf] by rtfeldman on Tuesday May 09, 2017 @12:07AM (#14297669)
Again, there are lots of counterexamples to what you're claiming. The technique you're saying "must" be done in "every single" case came up a grand total of once in the entire code base: the file you linked to.
Re:Why Elm? [pdf] by boubiyeah on Monday May 08, 2017 @04:32PM (#14295328)
Yeah.

My top 3 complaints:

1) The crazy boilerplate, the Elm architecture forces you to store all your app state in a single atom. In my experience, this doesn't scale well and is bloody annoying (see, even the redux author say you should never store everything in the single atom/store); Also, when should state be cleaned up? When the component is shown again, but then you have stale state in the meantime; or when the component is removed? before or after it's being transitioned out? (you don't want to see a flash of empty data)

2) The snail pace at which Elm evolves. I will have delivered 3 or 4 apps for my clients by the time the single Elm maintainer added 5% of the WEB API as native Elm modules. By the time he's done, new WEB APIs will have to be covered. It's never going to end. That means, a complex Elm app always has javascript. In that case, I'd rather just use typescript and nothing else.

3) The religious focus on purity. The elm maintainer is an haskell user, and it shows. Can you believe that to read the current time or generate a random number, you must be within a component's update function, ask for one or the other and you will get your result later, asynchronously? I know some people love that their entire program are fully pure in a mathematical sense, but this always struck me as having way more cons than pros.

Also, there is always "just one way to do this or that, all the other ways are disapproved by the Elm creator" The environment/community is so closed! If the Elm maintainer did anticipate your very specific need (low chance, he can't do everything by himself), the answer is: "always use that, you should never use this other thing, it's very dirty", if not, "just use this JS hack instead". This is good for beginners seeking very strong guidance, not good for power users trying to deliver stuff fast.

You can tell Elm is still a beta product; it has lots of cool stuff, but even more rough edges.

Otherwise the language is kinda nice and simple (some would say too simple, I don't know If I agree; maybe) and is great for teaching FP to first timers.

Re:Why Elm? [pdf] by seagreen on Monday May 08, 2017 @04:59PM (#14295546)
> The religious focus on purity. The elm maintainer is an haskell user, and it shows. Can you believe that to read the current time or generate a random number, you must be within a component's update function, ask for one or the other and you will get your result later, asynchronously?

You say this like generating a random number is a small deal. In a sense this is very true! From the machine's perspective generating a random number is a quick operation. However, from the perspective of maintainers who come after you losing determinism is no small thing, and IMHO deserves to be marked clearly in the type system.

Re:Why Elm? [pdf] by boubiyeah on Monday May 08, 2017 @05:02PM (#14295573)
I also respect this view. On the frontend, as long as I have a decent type system, I never needed to also encode effects using the type system, so I'd rather not burden the team with this if the ROI is very small.
Re:Why Elm? [pdf] by Skinney on Tuesday May 09, 2017 @12:10AM (#14297675)
1) I don't see a problem with this. If you have stale state, but no one sees it, who cares? Same thing regarding cleaning it up, if no one notices when, who cares? The great thing about storing all the data in a top-level datastructure is that you could dump that entire thing into JSON, send it along in bug reports, and then you can see the same state the application was in when a bug happened. This is gold!

2) In my experience, with typescript/javascript you instead get to deal with the fact that in the same period of time the API for webpack has changed, the api for react-router has changed twice, etc. Slow is not necessarily bad, especially considering the reason things are slow is because of the focus on doing things right. Also, just because you can't escape a tiny amount of javascript, having the rest of the application in Elm isn't worth it? How strange.

3) I admit that it sometimes is a bit annoying that you can't get things like the current time --right now--, and instead have to thread that through the update chain. But overall I find this to be a good thing. It's great when learning new code bases to easily identify where side-effects can happen just by looking at the type signature.

> Also, there is always "just one way to do this or that...

As a power user, this is the best thing about Elm. The fact that javascript isn't like this, is why I never want to maintain another javascript project that I didn't personally create, ever again.

> You can tell Elm is still a beta product;

Elm is a alpha product, so this is really a great compliment.

Re:Why Elm? [pdf] by boubiyeah on Tuesday May 09, 2017 @02:29AM (#14298120)
Thanks for the different perspective.

And no, I wouldn't want to maintain a codebase written in a dynamic language ever again too :p

Re:Why Elm? [pdf] by acemarke on Monday May 08, 2017 @04:48PM (#14295459)
More specifically, to quote the Redux FAQ entry at http://redux.js.org/docs/faq/OrganizingState.html#organizing... :

> There is no “right” answer for this. Some users prefer to keep every single piece of data in Redux, to maintain a fully serializable and controlled version of their application at all times. Others prefer to keep non-critical or UI state, such as “is this dropdown currently open”, inside a component's internal state.

> Using local component state is fine. As a developer, it is your job to determine what kinds of state make up your application, and where each piece of state should live. Find a balance that works for you, and go with it.

Re:Why Elm? [pdf] by boubiyeah on Monday May 08, 2017 @04:57PM (#14295520)
Re:Why Elm? [pdf] by tikhonj on Monday May 08, 2017 @03:45PM (#14294907)
The Elm architecture is explicitly not FRP. With FRP, you could include a component that changes pretty easily; for example, with GHCJS and reflex, there is a function called dyn that takes a Dynamic widget (ie a signal of widgets) and turns it into a normal widget:

    dyn :: MonadWidget t m => Dynamic t (m a) -> m (Event t a) 
The types take a bit of getting used to (reflex-frp is not nearly as beginner friendly as Elm), but once you are used to them it's incredibly expressive. Being able to just wrap a changing widget into a normal widget without needing to change the rest of your code is a big part of why I ultimately like reflex's model far more than the Elm Architecture.
Re:Why Elm? [pdf] by polytypic on Tuesday May 09, 2017 @02:43AM (#14298170)
> I have yet to see a FRP library that allows you to just use a component without introducing boilerplate.

I'm the author of https://github.com/calmm-js.

I wouldn't necessarily describe it as (pure) FRP, but the combination of techniques used in Calmm pretty much eliminates all boilerplate: in the limit, a truly useful component can be just a single function with a body of a single line of code. Using that component then is just a matter of instantiating the component with desired parameters (no boilerplate). The lack of boilerplate makes it practical to eliminate even small scale repetition with local components.

Parameters to components in Calmm can represent read-only (Observable) or read-write (Atom :> Observable) state. RW state can be sliced with lenses and be used as RO state without glue. RO state can be arbitrarily combined to compute desired properties. Thanks to being able to effortlessly slice RW state, components can be easily made independent of the application state as a whole (IOW, a component can be made to take only just the state it needs as parameters) and be made truly reusable.

Calmm also makes it simple and easy to create both stateless components (consider #1) and components that can optionally use local state so that the user of the component can actually choose whether the component uses local state or a slice of global state.

Calmm also primarily guides you to use stateless, time independent, continuous, observable properties (combine) rather than streams of discrete events (merge + scan) (see #2) which actually introduce undesirable local state and force you to consider timing dependencies again.

#1) https://awelonblue.wordpress.com/2012/10/21/local-state-is-p... #2) https://awelonblue.wordpress.com/2012/07/01/why-not-events/

Re:Why Elm? [pdf] by KirinDave on Monday May 08, 2017 @03:31PM (#14294797)
I'm curious if you've ever looked at optics-based systems for component coupling?

Personally I think that the entire top-down state tree is a bad idea, but I'm willing to be convinced. I'd much prefer a modeling like the actor approach.

Re:Why Elm? [pdf] by modularfurnitur on Monday May 08, 2017 @04:20PM (#14295233)
Keeping all external state in a db like abstraction, and having any component, regardless of view tree depth, be able to query against it for data that it needs, and have it update when that data changes, is the way to go, and it's the future.

Applications developed this way are very easy to change and update. Deleting a completely self contained component, not having to update the parent by removing the wiring of the data, is a blessing.

Re:Why Elm? [pdf] by colordrops on Monday May 08, 2017 @03:59PM (#14295024)
Google isn't finding anything regarding component coupling and optics. Do you have any links that introduce the concept?
Re:Why Elm? [pdf] by pygy_ on Monday May 08, 2017 @04:26PM (#14295282)
A lens is an object that has both read and write access to a property of an object (or to a path into a tree of nested objects).

Rather than passing parts of the model to the children (as you'd do with React props), you pass lenses into said parts.

It enables child components to read/write to the global store without knowing its structure. As long as it receives an appropriate (set of) lens(es) it is happy.

So, for example, if you have a list of strings, rather than passing the nth string to the nth component, you'd pass a lens to the nth string. The component can then not only read but also write to its slot.

Lenses can also be composed, so you can create them on the go as you'd pass sub-props to grand-children.

https://github.com/calmm-js/partial.lenses <= a comprehensive lens library

http://ramdajs.com/ also has lenses.

These libs are strongly influenced by the FP world. The underlying data structures are immutable, writing to a lens creates a new version of the store (as efficiently as possible, by recycling intact objects).

Re:Why Elm? [pdf] by charlieflowers on Monday May 08, 2017 @09:07PM (#14296978)
So basically, it's like using dependency injection, and what you're injecting are higher order functions for the getters and setters for whatever properties you need. Is that right?
Re:Why Elm? [pdf] by harperlee on Tuesday May 09, 2017 @01:46AM (#14297979)
Do they need to be functions? Because this seems a lot like handling [:a :keyword :vector :for :navigating :trees] in Clojure and passing it to either update-in or get-in functions, which is a pattern ubiquitous in re-frame, but not sure is can be called a lens).
Re:Why Elm? [pdf] by charlieflowers on Tuesday May 09, 2017 @04:01PM (#14303335)
What you're saying sounds similar. But my question and your post are both missing the "composition" aspect. Somehow lenses are composable, and I guess to grok that we'd need to look deeper.
Re:Why Elm? [pdf] by pygy_ on Tuesday May 09, 2017 @03:27AM (#14298311)
Sounds about right.
Re:Why Elm? [pdf] by KirinDave on Tuesday May 09, 2017 @10:36AM (#14300344)
PureScript's thermite is what I had in mind, but yeah this is good.
Re:Why Elm? [pdf] by colordrops on Monday May 08, 2017 @04:56PM (#14295512)
Thank you.
Re:Why Elm? [pdf] by arianvanp on Monday May 08, 2017 @08:48PM (#14296885)
I wrote about this some time ago. https://arianvp.me/lenses-and-prisms-for-modular-clientside-...

However, recently I discovered Halogen [0]. It is very similar to Elm Architecture, however, every component has its own _internal_ state, so you do not have to thread all state changes to the top-level component. It does this by existentially quantifying over the State [1].

Halogen is written in Purescript, which is a transpiler for javascript (yes transpiler, not compiler). Which means you basically get javascript semantics with a haskell typesystem + very good interop with JS, and no runtime system. The code purescript generates is actually readable. [2]

[0] https://github.com/slamdata/purescript-halogen/tree/master/d... [1] https://wiki.haskell.org/Existential_type [2] https://purescript.org/ [3] http://try.purescript.org

Re:Why Elm? [pdf] by dragonwriter on Monday May 08, 2017 @08:58PM (#14296925)
> Halogen is written in Purescript, which is a transpiler for javascript (yes transpiler, not compiler).

Transpilers are a subset of compilers; it is impossible for "yes transpiler, not compiler" to be true.

Re:Why Elm? [pdf] by KirinDave on Tuesday May 09, 2017 @12:25PM (#14301367)
Thank you for being a force for sanity in the universe. "Transpiler" is a distinction without a difference to add yet more jargon to our already cryptic profession.
Re:Why Elm? [pdf] by boubiyeah on Monday May 08, 2017 @05:13PM (#14295661)
For what's it's worth, I never found a use for optics.

The idea is that you declare read/write optics than you then compose and reuse.

But on a web app, say, in how many places can you update a person's address?

Writing non generic code that update it in a non generic way (throw away code) is much less ceremony than defining an optic and only using it once.

Re:Why Elm? [pdf] by KirinDave on Tuesday May 09, 2017 @10:36AM (#14300353)
In this case the optics are used as a way to select state in the coupling construct. You don't use them to read values out of the form, you use them to explain to the components how to pull or update their state out of the shared construction.
Re:Why Elm? [pdf] by pka on Monday May 08, 2017 @09:14PM (#14297006)
Re:Why Elm? [pdf] by jadbox on Monday May 08, 2017 @03:41PM (#14294876)
I've seen optics for Cycle.js but I haven't found one yet for Elm.

https://github.com/staltz/cycle-onionify

Re:Why Elm? [pdf] by uryga on Monday May 08, 2017 @03:42PM (#14294890)
> optics-based systems for component coupling

Do you know of any good resources on that? Or projects using these concepts? Sounds interesting.

Re:Why Elm? [pdf] by yiransheng on Monday May 08, 2017 @04:52PM (#14295496)
Calmm-js is one of these: https://github.com/calmm-js
Re:Why Elm? [pdf] by crimsonalucard on Monday May 08, 2017 @07:26PM (#14296517)
This is exactly the react/redux/flux architecture everyone is raving about.
Re:Why Elm? [pdf] by Skinney on Tuesday May 09, 2017 @12:15AM (#14297695)
> I have yet to see a FRP library that allows you to just use a component without introducing boilerplate.

Given all the benefits of Elm, 6 lines of boiler plate (one line added in model, 5 lines added in update) is a small price to pay. Especially considering the small amount of components (in contrast to React, not everything is a component).

Re:Why Elm? [pdf] by StreamBright on Tuesday May 09, 2017 @03:21AM (#14298288)
Same here, any time we wanted to use Elm for a production system we gave up. It brought more problems to the table than solved. Maybe later it becomes something more usable.
Re:Why Elm? [pdf] by antouank on Monday May 08, 2017 @04:15PM (#14295185)
Been using Elm for a few months now. Both in small side projects, and in a production app for work.

Many benefits over using js, and basically no downsides apart from the initial learning curve. And even that could be equal to the learning you have to do every time your team decides to add/use a new foo.js library or framework to the project.

With Elm:

  - you are confident about your code 
  - others ( and your future self ) can actually read it and understand it
  - it pushes you to think before you write
  - refactoring is a breeze, not a nightmare
I hope I won't have to use js on my next gig.

edit: Also, I cannot speak highly enough about how helpful the compiler is, and the community in the slack channel. Makes the whole experience a joy.

Re:Why Elm? [pdf] by ChemicalWarfare on Monday May 08, 2017 @04:32PM (#14295329)
+1. Totally digging Elm as well. Learning curve is pretty minimal, although I've spent some time "playing around" with Haskell which helped.

Love how structured things are and even though Elm is an "in progress" kind of thing - still no left-pad or js fatigue type issues (unless you really try to make them happen).

Re:Why Elm? [pdf] by savanaly on Monday May 08, 2017 @04:49PM (#14295467)
Have you been using outside libraries that were written in javascript on these projects?

I always anticipated that would be a downside of using Elm. I know there must be hooks to let you integrate pure javascript (jQuery-type) libraries and widgets into your app, but wouldn't it be really annoying?

I'm writing Angular apps these days and one of the most time-consuming tasks is this sort of integration (for instance, right now I'm trying to add FullCalendar [0] to an app), and it doesn't work so nicely with the digest cycle of Angular, or play nicely with how data is passed around. And Elm is even more alien to javascript than a javascript app using Angular would be to javascript. So how is this area for you?

[0] https://fullcalendar.io/

Re:Why Elm? [pdf] by antouank on Monday May 08, 2017 @05:40PM (#14295872)
Not really.

I guess my approach is different. I only use a library when I have to, meaning that it's of "high quality" and it will save lots of time. Otherwise, I'd rather implement the feature myself, so I know the code and I can extend it later.

In that sense, Elm covers me completely. There are many small good utility libraries to use, but I only use 2-3 of them. And most of them, you can read the code, quickly understand what it does and pick the code you want to use in your app.

Re:Why Elm? [pdf] by minikomi on Monday May 08, 2017 @11:20PM (#14297499)
As an open question to yourself, or anyone else advocating elm heavily, can you show something cool you've built using the language? That would be the most convincing argument!
Re:Why Elm? [pdf] by _greim_ on Tuesday May 09, 2017 @12:41AM (#14297782)
I don't spend a lot of time advocating, but here are my first two attempts at building stuff in Elm.

https://greim.github.io/elmsweeper/

https://greim.github.io/electron-golf/

Honestly I think it would have been easier to build the first iterations of these in JS (React or something) but with the second->nth iterations, it became easier with Elm.

Re:Why Elm? [pdf] by minikomi on Tuesday May 09, 2017 @04:49AM (#14298560)
I'm seeing a lot of simple games on the built with elm site - do you think that's a sweet spot for using elm?
Re:Why Elm? [pdf] by _greim_ on Tuesday May 09, 2017 @10:29AM (#14300270)
Not sure, maybe.

A lot of it might be that simple games are fun and relatively easy, so well suited for learning new stuff in your spare time.

Then again, the electron golf game re-renders SVG DOM at 60fps. Building web apps that way hadn't occurred to me until React came along, and I didn't attempt it until Elm.

Re:Why Elm? [pdf] by nagyf on Tuesday May 09, 2017 @03:03AM (#14298240)
Very nice, thanks for posting
Re:Why Elm? [pdf] by antouank on Tuesday May 09, 2017 @02:53AM (#14298197)
Would this help?

http://builtwithelm.co/

Re:Why Elm? [pdf] by minikomi on Tuesday May 09, 2017 @04:36AM (#14298523)
Interesting. Almost every site with multiple pages I visited had a lot of weird behavior when using browser back/forward.

There's a lot of snake games, tic-tac-toes and 2048 clones -- I was looking for more along the lines of multiple page apps where elm made it a lot easier to build, and stories thereof.

Re:Why Elm? [pdf] by boubiyeah on Monday May 08, 2017 @04:33PM (#14295333)
That's just dynamic vs static typing though :p
Re:Why Elm? [pdf] by antouank on Monday May 08, 2017 @04:36PM (#14295355)
You can say that.

But, I also tried to learn and use OCaml and Haskell in actual projects. They are nowhere near as friendly and approachable as Elm to beginners.

Re:Why Elm? [pdf] by StreamBright on Tuesday May 09, 2017 @03:35AM (#14298335)
Well comparing Elm to OCaml or Haskell does not make too much sense. OCaml is a 20 years old multi-paradigm, general purpose language that is extremely useful for so many things (writing compilers for example) while Elm is a domain-specific programming language to be used in the browser. Apples and oranges.
Re:Why Elm? [pdf] by antouank on Tuesday May 09, 2017 @04:12PM (#14303429)
I didn't compare them in that sense. I only compared how easy it is to get started with. They share some concepts, like being functional languages and having good type systems.

Elm definitely helped me understand many concepts in OCaml and Haskell. But to go beyond that, it's difficult.

Re:Why Elm? [pdf] by KurtMueller on Monday May 08, 2017 @04:53PM (#14295500)
Elm is definitely in my future - in fact, many of the ML based languages are as well: Purescript, Haskell, F#, ReasonML, etc. Elm will be and is the gateway to all of that because it gives you only 1 path to traverse and tries to set up all the initial sign posts along the way.
Re:Why Elm? [pdf] by zellyn on Monday May 08, 2017 @03:12PM (#14294633)
I want to like and use Elm. However, unless things have changed recently, it seems the author hasn't learned to delegate. They also like to really get things right, which takes forever.

So it's really good at what it does, but for everything else, it's just incomplete. For instance, Elm seems like a natural fit for an offline-first ServiceWorker design. But I don't think it really covers much of the just-outside-of-core-Javascript browser APIs. You're likely to run into "I have some really interesting ideas about how to cover that a super elegant way, but I'm concentrating on rewriting the $WHATEVER right now" newsgroup posts, but that's it… :-(

Re:Why Elm? [pdf] by canadaduane on Monday May 08, 2017 @04:04PM (#14295073)
Yes, this is a problem IMO. I dedicated 9 months to learning Elm, but left frustrated by the tight control and lack of delegation that would have leveraged my skills and many others' skills to further the idea and language.
Re:Why Elm? [pdf] by skybrian on Monday May 08, 2017 @04:16PM (#14295192)
On the other hand, it's easier to wait patiently if you're not using the language yet :-)

I've been watching Elm for some time. I'll wait until it's done. So my reason for not using Elm is: I'd rather be patient.

Re:Why Elm? [pdf] by KurtMueller on Monday May 08, 2017 @05:16PM (#14295680)
I think you're going to be waiting indefinitely then :).
Re:Why Elm? [pdf] by boubiyeah on Monday May 08, 2017 @04:13PM (#14295166)
The elm language/framework designer is planning 10 years ahead. At least it's ambitious!

For everyone who need to write SPAs right now (or in 2 years) it's just meh.

Re:Why Elm? [pdf] by zellyn on Monday May 08, 2017 @04:47PM (#14295450)
In 10 years, the proverbial puck will have moved. Language ecosystems where the BDFL doesn't learn to delegate wither and die.
Re:Why Elm? [pdf] by boubiyeah on Monday May 08, 2017 @04:58PM (#14295529)
Yes it will.
Re:Why Elm? [pdf] by psibi on Tuesday May 09, 2017 @02:17AM (#14298075)
This is a big problem IMO and one of the major reason why I haven't used Elm in any serious projects yet
Re:Why Elm? [pdf] by ng12 on Monday May 08, 2017 @02:44PM (#14294363)
One thing I don't see addressed here is the biggest "Why Not Elm": you have to learn Elm. Elm is a beautiful language and in the last year or two the ecosystem has gotten much better. However I don't think I'll ever make progress adopting it at my day job. For all of it's flaws JavaScript is still quick, scrappy, and easy to pick up. Convincing a curmudgeonly back-end developer that React and webpack will make his life easier is hard enough. Convincing him to learn a seemingly esoteric functional language too is basically a non-starter.
Re:Why Elm? [pdf] by danyx on Monday May 08, 2017 @03:45PM (#14294905)
I'm actually surprised that so many teams have this view. We are a very small dev team working on scientific apps and I feel that the time it took us all to get comfortable with Elm was easily recouped by the constant development speed we had even as the app got bigger. In Javascript, projects just become harder and harder to refactor and so they accumulate cruft and development speed drops as the project ages. In Elm, with the help of a really decent type system and a helpful compile, we were able to keep going and just add features at a constant pace. I think it's worth taking a close look at Elm for this reason alone (or Purescript for that matter but there it is possible to get lost in rabbit holes of type complexity :) ).
Re:Why Elm? [pdf] by ng12 on Monday May 08, 2017 @03:52PM (#14294967)
> We are a very small dev team

That's the secret though, right? When you have teams of dozens of developers in a company of thousands the cost of adoption and the resistance you encounter increases exponentially. At least I can evangelize React/Redux/Typescript and get a sane development experience that's still just JavaScript.

Re:Why Elm? [pdf] by firethief on Monday May 08, 2017 @07:43PM (#14296586)
That's an interesting claim. Can you elaborate on the superlinear factors of the cost increase?
Re:Why Elm? [pdf] by mr_luc on Tuesday May 09, 2017 @10:12AM (#14300135)
In part, it's probably because ever since the os360 project we've known that communications overhead in programming projects does increase more-than-linearly with the number of collaborators.
Re:Why Elm? [pdf] by mikekchar on Monday May 08, 2017 @09:59PM (#14297223)
I'm not entirely sure that the cost is exponential as the parent stated, but it certainly is superlinear above a certain threshold in my experience.

There are a few issues you have to deal with. The first is how adoption happens. This is generally based on power structures and reputation. If you are in a position to mandate a change, the cost is potentially lower (see below, though), but if you are not then you have to influence enough people to make a change.

There are many ways to do this, but I will split it into 2 for simplicity. First, you can try to influence the rest of the group directly. As the group size grows, this becomes progressively more difficult because your message is lost in the noise of other people pressing their own agendas. Once you get above certain point (say about 8-10 people), your odds of success drops to near zero.

The other main way is to pilot a project and use its success to influence others. Setting up the pilot requires influencing a smaller group and therefore you have higher chances of success. The problem is that when you pilot a new way of doing things, you are intentionally breaking consensus. You now have a small group of individuals who have experience that nobody else in the group has. Whether the adoption of the new technique is successful or not, this leads to increased cost as attitudes change.

The bigger the group, growing out a pilot into a larger project becomes more expensive. This is essentially the same problem as before -- you may be in a position now to mandate a way of working, but if you are not, then you have to create another round of pilots to move the idea around the group. But now you have another problem -- the implementors of the new pilots are different than the implementors of the original pilot. So you will now have more than one message coming out. You now have to harmonise that message in order to drive adoption.

At every step, there is a chance of failure (sometimes quite high). The chance of failure grows as size of the group increases, because the external pressures to not change are higher. Again, there are several possible outcomes, but I will pick 2 for simplicity. You may find that your idea is rejected. You have now spent resources on your pilot that you will have to reimplement in another way. Another outcome is that your adoption is simply stalled -- you split your group permanently. This has cost implications ranging from staffing, to training, to tooling, to management, etc.

Now, assuming you don't fail, you may have organically grown the adoption in your group (which is ideal), but as your group size grows, the possibility of that decreases (because the risk of failure increases based on the size of the group). More likely is that you have gotten enough reputation to be able to mandate a change.

Mandating changes has costs as well. The first is that some people will be uncomfortable with the change and will quit. You now have to replace those individuals - which costs you both lost productivity, referral fees, and training costs. This is more likely as the group size increases because you are more likely to have diverse, strongly held opinions.

The next biggest cost would appear to be training, retooling, etc. However, there is a hidden cost -- compliance. Very good people who dislike the change will leave. Very poor people will not leave -- they will simply refuse to follow the new strategy competently. This may be because they are depressed over the change, scared of how the change affects their influence, and many other things. These people can often end up sabotaging your projects (mostly unintentionally, but as they are usually quite upset they also don't care if they do). As the size of the group increases, the chances of building an unshiftable group of discontents grows.

If you want to make a lot of money, become a consultant introducing new development techniques into large organisations like banks. It's a bit like siphoning all their operating capital into your pocket because you have no hope of success and can blame all your failure on other people.

Re:Why Elm? [pdf] by Rapzid on Monday May 08, 2017 @10:30PM (#14297331)
Sounds about right. Tons of work and can be very draining.
Re:Why Elm? [pdf] by KurtMueller on Monday May 08, 2017 @05:15PM (#14295676)
Elm seems like an excellent choice for a small or large dev team. There's only one way to structure your app - the Elm way. As your app grows, it must still follow the Elm way and the same circle of events. For developers transitioning on to the app or different parts of it, business logic is the major hurdle and not the app structure itself. The app structure is more or less the same be it a small or large app.
Re:Why Elm? [pdf] by splintercell on Monday May 08, 2017 @02:49PM (#14294399)
I have learned ELM and I have done React + Redux development, and I can say that I found learning and using former a lot easier than doing the latter. Probably because react redux were trying to make me learn a new concept over existing knowledge of JS was, while Elm was easier to pick up because I entered with a mindset of learning a new language.

For those who are new to any kind of development, learning Elm would be no more different/difficult than learning react redux.

Re:Why Elm? [pdf] by ng12 on Monday May 08, 2017 @03:01PM (#14294509)
I think that's only true if you're already familiar with Haskell-like languages. Elm-html is conceptually close to React/Redux so you basically have to learn it either way. Even knowing a few functional languages already it took a while for me achieve a basic level of competency with Elm. On the other hand someone who knows Java can pick up JS in an afternoon.
Re:Why Elm? [pdf] by Risord on Monday May 08, 2017 @04:15PM (#14295187)
I don't know. I felt sameway that elm was easier when I was learning Vue with all modern shiny stuff. I had done mostly C#/Java and some old school JS programming but none Haskell likes. It's hard to say which ones was easier since learning experiences were so different. Maybe learning took approximately same time but time was used with JS for googling and brute forcing things. On the other side Elm compiler just said "You probably did this common error ####. Try do ###" so learning was much more efficient since you know instantly what was wrong and why. I can certainly say that learning Elm was much more pleasant one for me.
Re:Why Elm? [pdf] by napsterbr on Monday May 08, 2017 @04:40PM (#14295384)
Before diving into elm, I had this fear too. But speaking from someone who never used haskell before (hell, I never used a statically typed language before), learning elm was quite simple. There's a lot of help from the compiler and the community as well. After two weeks I was quite confident on my work, and in one month I managed to create the entire architecture of our production app. Through the months I got a better grasp of elm and refactored the entire app several times (not nearly as painful as it sounds).

I've made the decision to use elm and put my two frontend devs to learn it. They managed to start contributing to the app in less than a week.

So if you have the chance, I think it's worth a shot. I thought I'd never learn elm, but so far my experience proved that it's much easier than it seems.

Re:Why Elm? [pdf] by KurtMueller on Monday May 08, 2017 @05:05PM (#14295607)
> Through the months I got a better grasp of elm and refactored the entire app several times (not nearly as painful as it sounds).

Refactoring Elm code isn't as painful for me as Javascript or Ruby - because it's statically compiled, it gets rid of a whole class of errors. The compiler does an excellent job at where compilation fails and suggestions to fix the error.

Additionally, I find in Elm (and other ML-typed languages) that it's easy to model states of your app (e.g. like a state machine) and events that change the state of your app. Adding/modifying states and events in Elm is one of its strong suits and it really forces you to logically think through how your app transitions from one state to another. Scott Wlaschin has an excellent talk on Domain Driven Design in F# that articulates this point quite well.

Re:Why Elm? [pdf] by allochthon on Monday May 08, 2017 @03:18PM (#14294688)
Wrapping my head around Elm took a little while. I was enjoying my progress until I attempted to abstract out some view render code into a separate module. I fought with the type system for a long time and had difficulty getting beyond an obscure compiler complaint.
Re:Why Elm? [pdf] by cel1ne on Monday May 08, 2017 @02:50PM (#14294410)
Why not Elm on google turns up this: http://reasonablypolymorphic.com/blog/elm-is-wrong

I think the basic gist was that it's type-system is far from complete.

Re:Why Elm? [pdf] by zeptomu on Monday May 08, 2017 @06:28PM (#14296221)
The main critics is that it does not support type classes, but maybe that is actually not a bad thing. The discussion is similar to the never ending Go discussion about generics and people do amazing stuff with Go (now I guess critics would say they would do even more amazing stuff with generics).

Not that I say type classes (or generics) are useless, but keeping a language simple (in the sense of keeping the feature list small) has benefits on its own. I did not to complicated projects in Elm, but I watch the language closely and really like what I have seen so far, so I hope Evan keeps up the good work, as I think he has pretty good taste for language design.

Re:Why Elm? [pdf] by 0xCMP on Monday May 08, 2017 @03:05PM (#14294552)
It's not that it is not complete, but not entirely as powerful as Haskell which inspires a lot of how Elm works and looks like. The creator/maintainer of elm doesn't believe they're required.
Re:Why Elm? [pdf] by commandertso on Monday May 08, 2017 @03:02PM (#14294525)
FWIW, when this was new it got a lot of pushback in a related Reddit thread. Might be worth digging in if you're seriously thinking about it.
Re:Why Elm? [pdf] by AlexCoventry on Monday May 08, 2017 @03:02PM (#14294527)
This was definitely a pain point for me when I experimented with Elm.
Re:Why Elm? [pdf] by boubiyeah on Monday May 08, 2017 @05:32PM (#14295801)
In my company, whenever a backend dev has to do frontend dev, it never ends well :(
Re:Why Elm? [pdf] by eweise on Monday May 08, 2017 @03:38PM (#14294860)
I'm using Elm for an internal customer service app and it is working out fairly well. My background is more server side programming so the ability to avoid javascript and its constantly changing ecosystem is a big plus. Elm the language is simple enough to understand in a day and the basic architecture is also straightforward. The biggest challenges are finding examples of how to architect larger apps but this example should help https://github.com/rtfeldman/elm-spa-example Also, I tried mentoring another coworker on Elm but they seemed to have a harder time than I did. I think it could be partly because they were an experienced Javascript developer who wanted to apply their existing patterns to Elm.
Re:Why Elm? [pdf] by jshute on Monday May 08, 2017 @06:27PM (#14296215)
Elm hasn't merged a trivial change to allow manipulation of UTC and timezones in 6 months:

https://github.com/elm-lang/core/pull/739

Basically, if you have to deal with local time, this isn't the language for you. If you expect to be able to add to the platform where you find it lacking, this isn't the language for you.

At this point, Typescript has the momentum to make it irrelevant

Re:Why Elm? [pdf] by zeptomu on Monday May 08, 2017 @06:42PM (#14296302)
Typescript is a completely different language advocating different paradigms so they are not comparable.

However I have to agree with you that the lack of support for local time is pretty unfortunate.

Re:Why Elm? [pdf] by jshute on Monday May 08, 2017 @07:39PM (#14296567)
I've used both heavily. I think paradigm is the key word if you're thinking mind-expanding properties. While immutable types and combinators are less used in Typescript (you've got me there) you can certainly get 80% of the value of strong typing, and there are several variants of Virtual DOM support.

Elm's error messages and semantic versioning are still a class above anything else, though. Sad to see it rotting on the vine like this.

Re:Why Elm? [pdf] by StreamBright on Tuesday May 09, 2017 @03:40AM (#14298364)
In this thread Elm was compared to OCaml and Haskell, comaparing it to Typescript is really not that bad. :)
Re:Why Elm? [pdf] by boubiyeah on Monday May 08, 2017 @06:45PM (#14296321)
The roadmap priorities always baffled me too. I mean, what elm needs now to be usable is surely not code splitting... Almost no one really need that, it's a late optimisation for top sites.
Re:Why Elm? [pdf] by derefr on Monday May 08, 2017 @06:50PM (#14296353)
It makes sense if their strategy is to try to get at least one of said "top sites" to adopt them—which might, after all, result in development being sponsored or supported by full-time employees of whichever bigcorp runs the site.
Re:Why Elm? [pdf] by sotojuan on Monday May 08, 2017 @06:51PM (#14296360)
They already have that. Evan literally gets paid a Bay Area salary to work on Elm.
Re:Why Elm? [pdf] by derefr on Monday May 08, 2017 @06:53PM (#14296370)
In that case—if at least one bigcorp is using Elm (which one?)—then their roadmap is probably being heavily steered by the needs of said bigcorp.
Re:Why Elm? [pdf] by sotojuan on Monday May 08, 2017 @06:55PM (#14296384)
No "big" corp is using Elm but NoRedInk is both Evan's employer and the company that uses Elm the most.
Re:Why Elm? [pdf] by azangru on Monday May 08, 2017 @03:21PM (#14294715)
I am surprized Elm gets talked about so much more than Purescript. Although Purescript is more of a general-purpose language and feels like Haskell that compiles to Javascript, and Elm is something that relies on its specific runtime to work.
Re:Why Elm? [pdf] by systems on Monday May 08, 2017 @04:14PM (#14295176)
Well, I think with so many language trying to replace javascript (purescript, coffeescript, livescript, clojurescript, bucklescript, dart, typescript .. probably there is more)

It is impossible that all of them will be popular, plus more general purpose, doesnt really seem to help with popularity ... look at sql or r ... very popular, and very domain specific

Re:Why Elm? [pdf] by boubiyeah on Monday May 08, 2017 @05:16PM (#14295687)
The barrier to entry is much higher for purescript.

Elm tries to protect new users: "here, use andThen to chain two computations"

Purescript: React bindings have literal mentions of monads and functors... I think they're useful as concepts; but I don't want to think about it everytime I write a component's render function.

Re:Why Elm? [pdf] by zem on Monday May 08, 2017 @04:13PM (#14295167)
same reason rails got so much more mindshare than any of the competing web frameworks of its day - there is considerable value in optimising for the common case, and indeed adding constraints in the name of safety and good architecture; most languages/frameworks try to optimise for flexibility and miss out on this fact.
Re:Why Elm? [pdf] by KurtMueller on Monday May 08, 2017 @05:24PM (#14295752)
I think this is one of the main selling points about Elm - it's got conventions and it's got opinions. There's only one way to structure your app and it's the Elm way. That's a good thing when you're

1) building & growing the app - there's only way to grow and it must follow the same conventions as every other Elm app 2) bringing on developers - their main hurdle is the business logic itself and not the structure of the app 3) finding resources in the community - most everybody is traveling down the same road and can teach one another the lessons they've learned

Re:Why Elm? [pdf] by crimsonalucard on Monday May 08, 2017 @05:03PM (#14295587)
Purescript is more powerful but harder to use.
Re:Why Elm? [pdf] by 0xCMP on Monday May 08, 2017 @03:08PM (#14294588)
I like Elm a lot. I also do a lot of React and I have worried about picking Elm to avoid killing a nice product written in it because no one is willing to learn it to maintain it after I'm gone. Better to pick React to avoid any rewrites just to continue maintaining the product.

However, if they could just be convinced to learn Elm I'm positive that Elm would be much easier to maintain and improve than just React by its self. React can definitely be maintained easily, but Elm does a lot of the work to check itself and also enforces discipline that React can't (although you could get a lot by just using Flow extensively and treating its errors as blockers).

Re:Why Elm? [pdf] by mistersys on Monday May 08, 2017 @03:23PM (#14294721)
The static types system is great, however, having used elm: elm unloads much of the work react does onto you. React automatically (with keys) manages state creation for lists and child components, but with elm you have to manage that manually.

Using a component isn't simply matter of importing and using, you have to integrate its state into your component, send all it's events back to its reducer, and then map each child state to the corresponding view. You end up with lots of boilerplate.

Re:Why Elm? [pdf] by fpoling on Monday May 08, 2017 @04:45PM (#14295421)
From my small experience with Elm all that boilerplate is nicely dealt by compression-oriented programming [1]. It is easy to move common code into helper function and Elm pure functional nature makes that rather maintainable. The hard part is to come up with good names for those helpers and avoid being too generic when refactoring code.

[1] https://mollyrocket.com/casey/stream_0019.html

Re:Why Elm? [pdf] by mistersys on Monday May 08, 2017 @07:17PM (#14296484)
I think the bigger problem here is the load it takes to change from stateless to stateful.

Let's say a create a stateless subscribe button component, that's part a of a stateless header component. It just accepts a listener that is called when the button is clicked.

Now, my designer wants me to add a dropdown menu to the subscribe button that allows people to enable email notifications. The dropdown menu needs state, so now I add a reducer and model to my subscribe button, I need to wire that up through the stateless header component making it stateful, then finally wire it into the the atom for the app. I ended up doing these chains of updates and adding parameters to add simple features.

Also, elm lacks typeclasses. Try making a modular form builder with elm that allows other authors to define fields with custom state, it's a mess.

Re:Why Elm? [pdf] by hathawsh on Monday May 08, 2017 @04:10PM (#14295133)
Would it be possible for Elm to evolve a way to let components keep internal state? The lack of component-local state is what ultimately drove me away from Elm for my last project. It seems like it should be possible, since Elm and Redux are vaguely similar and Redux can store component-local state if you need it to.
Re:Why Elm? [pdf] by boubiyeah on Monday May 08, 2017 @05:47PM (#14295920)
I don't see this happening.

local state would invalidate many things in the Elm ecosystem like the time travel debugger, all the tutorials, etc. It's not such an easy problem, you have to write a new reconciler that only renders the things that have changed instead of always rendering the entire tree.

btw, redux only deal with global state but encourages the use of local (setState based) state whenever it makes sense.

Re:Why Elm? [pdf] by bauerd on Monday May 08, 2017 @05:28PM (#14295772)
Off-topic, but here I go: Has anyone tried compiling Elm's compiler (written in Haskell) to JS (with ghcjs)? Are there any other small and approachable functional languages that are in-browser compilable and provide JS interop? I'd love to hack on a small Agent Based Modelling environment for the browser, comparable to what NetLogo[1] achieves in large on the desktop. Or maybe just make it a LISP?

[1] https://ccl.northwestern.edu/netlogo

Re:Why Elm? [pdf] by firethief on Monday May 08, 2017 @07:54PM (#14296639)
Since you don't seem set on a language, let me throw my hump in for OCaml. It's supports a functional style without forcing you to use it for everything; js_of_ocaml compiles OCaml's dense, high-performance bytecode to Javascript that apparently integrates well with web APIs.
Re:Why Elm? [pdf] by sjrd on Tuesday May 09, 2017 @01:42AM (#14297966)
Since you mention NetLogo, note that it has a Web version whose compiler is written in Scala.js.

(The Scala.js compiler itself does not run in the browser, though.)

Re:Why Elm? [pdf] by kureikain on Wednesday May 10, 2017 @12:56PM (#14309681)
I really like Elm. It makes writing code so easier. At first, it's bit hard to get into the habit. But once I got paste that state(that takes 1-2 days) and get into how to write Elm, everything become so clear.

I currently use Rails and this helper[1] to render an Elm component. Then I mount it like this: [2]

``` <%= elm_component('TeamPicker', {flags: { formAuthenticityToken: form_authenticity_token, domain: current.domain, teams: user.my_teams.map { |team| {id: team.id.to_s, name: team.name || ""} }, current_team: {id: current.team.id.to_s, name: current.team.name || ""} }}, {tag: 'div', class: "nav-item"}) %> ```

I think this is an easy way to get into Elm world step by step.

My site is still normal HTML but I used ELM here and there for some component require interaction/multi step form etc.

---

[1]: https://github.com/NotyIm/trinity/blob/master/app/helpers/el... [2]: https://github.com/NotyIm/trinity/blob/master/app/views/part...

Re:Why Elm? [pdf] by steinuil on Monday May 08, 2017 @09:38PM (#14297111)
I think the two things Elm lacks the most right now are some form of polymorphism and some way to make parts of an Elm application manage their local state.

At the moment there's only an internal API for the latter, and it's pretty ugly. I think what would be good for Elm would be to spin up a few separate Elm processes and provide an easy interface to make them communicate, sort of like in Erlang. You can do this using ports and binding them together with js right now, but it's kind of ugly.

Re:Why Elm? [pdf] by sandeepc24 on Monday May 08, 2017 @05:08PM (#14295626)
Also have a look at https://www.npmjs.com/package/fable-elmish with F# flavor.
Re:Why Elm? [pdf] by KurtMueller on Monday May 08, 2017 @05:19PM (#14295715)
Do you use Fable / Fable-Elmish? If so, how do you like it?
Re:Why Elm? [pdf] by sandeepc24 on Monday May 08, 2017 @10:52PM (#14297403)
I am working on a project using Fable Elmish and I am really happy with it. All I can say is give it a shot.
Re:Why Elm? [pdf] by KurtMueller on Monday May 08, 2017 @11:31PM (#14297547)
As a side project or at work? Thanks for any info.
Re:Why Elm? [pdf] by filoeleven on Tuesday May 09, 2017 @07:32PM (#14304775)
Late to the party, but someone posted in the Ableton "Get started making music" thread[0] that the components in their slick web app[1] were made with Elm. Pretty impressive.

[0] https://news.ycombinator.com/item?id=14299816 [1] https://learningmusic.ableton.com/

Re:Why Elm? [pdf] by Myrmornis on Tuesday May 09, 2017 @04:14AM (#14298449)
The string "haskell" doesn't seem to appear in the text at all. That seems silly and rather patronizing, since it seems to be a book about a language that is heavily based on haskell, with very similar syntax. It bothers me when authors take this sort of "oh you don't need to know about that" approach.
Re:Why Elm? [pdf] by snappyTertle on Monday May 08, 2017 @04:44PM (#14295412)
Is there an effort to bring elm on native mobile to compete/work with react-native?
Re:Why Elm? [pdf] by kuon on Monday May 08, 2017 @06:31PM (#14296239)
Re:Why Elm? [pdf] by pcvarmint on Friday May 12, 2017 @04:37AM (#14322317)
I used elm for a while after mailx, but finally settled on pine. I never got used to mutt's UI.

Oh, how tech names keep getting recycled!!!

Re:Why Elm? [pdf] by arrty88 on Monday May 08, 2017 @04:37PM (#14295370)
Is it good for server side NodeJS as well?
Re:Why Elm? [pdf] by agentultra on Monday May 08, 2017 @04:43PM (#14295405)
Don't know about Elm, but there's Bucklescript or Reason and they generate really great, readable JS for use on Node.

(And even on the front-end there's `bucklescript-tea`; a port of the Elm architecture to OCaml)

Re:Why Elm? [pdf] by daddykotex on Monday May 08, 2017 @06:12PM (#14296120)
Honestly, if you don't want to use JS on the server side then you should not. There are plenty of very good alternatives.

I think Elm is to address the issue that JS is the only thing that runs in a browser. With that said, I suppose you could use it with Node as well.

Re:Why Elm? [pdf] by boubiyeah on Monday May 08, 2017 @05:00PM (#14295553)
It's not designed for it.

Some people do it, but it's a rough ride that need you to understand Elm's internals.

Re:Why Elm? [pdf] by rcgorton on Monday May 08, 2017 @07:20PM (#14296493)
Elm (software): an interactive mail system Elm (physical): a tree Elm (this): "functional" software. While I do Knot No the language, any language which claims to be functional, but stateful behavior (such as network timeouts) is really not functional. AKA, pitching pretty/current buzzwords, rather than being a new/useful language.

As for a "useful SPA" - a useful SPA has at least 300 gal. capacity and seating for 4+.

Sigh - arbitrarily re-using names for pre-existing widgets is silly. Sort like claiming that Kleenex is actually a machine tool.

Re:Why Elm? [pdf] by jlebrech on Tuesday May 09, 2017 @04:24AM (#14298481)
Last time i tried Elm I couldn't figure out how simply modify this clock example to move the hand quicker than every second

http://elm-lang.org/examples/clock

Re:Why Elm? [pdf] by redka on Tuesday May 09, 2017 @04:32AM (#14298504)
Well this isn't _that_ hard.

  Time.every (second / 2) Tick
and to still move it the same amount:

  Tick newTime ->  
    (newTime * 2, Cmd.none)
Re:Why Elm? [pdf] by jlebrech on Tuesday May 09, 2017 @05:46AM (#14298729)
I tried to use millisecond, but I don't it has the same interface as second.
Re:Why Elm? [pdf] by bradknowles on Tuesday May 09, 2017 @03:09AM (#14298251)
Good question. For a CLI mail client, I prefer mutt or pine. But elm isn't too bad as an alternative, if those aren't available.
Re:Why Elm? [pdf] by mrbill on Monday May 08, 2017 @03:25PM (#14294738)
Too many products with conflicting names. I thought this was about the email client at first.

http://www.instinct.org/elm/

Re:Why Elm? [pdf] by ng12 on Monday May 08, 2017 @03:27PM (#14294765)
> Update 06th Jan 2000: elm 2.4 is not Y2K compliant.

I'd be really surprised if it were.

Re:Why Elm? [pdf] by richardwhiuk on Monday May 08, 2017 @04:50PM (#14295477)
> Sadly, most of the information about elm on the internet is badly out of date.* The program is still being slowly developed, and the release (March 24, 1999) of elm 2.5 is promising.

Awesome.

Re:Why Elm? [pdf] by ryandrake on Monday May 08, 2017 @10:53PM (#14297406)
No idea why you're getting down-voted. The mail client was the first thing I thought of too. Was a really confusing read until I realized it wasn't about E-mail.