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.
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.
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.
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.
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.
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.
> 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.
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.
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.
> 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.
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.
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.
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.
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.
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.
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).
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?
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).
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.
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]
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.
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.
> 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).
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.
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.
+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).
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?
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.
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!
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.
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.
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.
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.
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.
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.
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… :-(
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.
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.
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 :) ).
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.
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.
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.
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.
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.
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.
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.
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.
> 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.
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.
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.
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.
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.
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
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.
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.
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.
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.
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
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.
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.
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
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).
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.
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.
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.
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.
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.
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?
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.
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]
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.
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.
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.
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.
> 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.
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.
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.