lainchan / λ

(untitled)

Project 2501 · 2017-07-30 20:56
Elm thread? I guess it overlaps a bit with the advanced webdev thread but I find it interesting enough to warrant its own thread. The Elm architecture is a really nice and simple way to make functional GUI's, and I'm seeing frameworks in a lot of other languages emulating it. Moreso than FRP which still seems to be mostly confined to Haskell and Typescript. The language itself is nothing too spectacular feature-wise, but it is a nice minimalistic ML dialect with a somewhat Haskell-inspired syntax. Its feature-set is basically the minimal skeleton that lets it comfortably support a GUI application using the Elm architecture pattern. Similarly, the standard library is batteries included for the specific purpose of making web frontends. Syntactic sugar is minimized as much as possible. The most sugar you will ever see is custom infix operators. The language itself tries to make everything either a match expression or a function/constructor call. Even HTML uses function call syntax, which IIRC was borrowed from Clojurescripts idea of using sexpressions for the purpose.
Void · 2017-07-31 00:43
I dont understand how anyone can even learn Elm where there are no books out on it. So Elm is an ML dialect that gets transpiled to js? That sounds interesting but Id really be curious what the syntax advantages Elm holds over languages like Clojurescript, Dart, etc.
Von Neumann · 2017-07-31 01:30
>>2705 Because it's so minimalistic, it's one of the easiest languages to learn which is out there, it's kind of like the functional programming counterpart of Go. With prior experience in Haskell or an ML dialect you can pick it up and become productive in just a few hours. The big advantage over almost all other transpiling languages is the bulletproof type system that comes with that family of languages. To some extent you can basically design an application by just playing type tetris and just writing functions with the correct type signatures, with very little thinking required. Haskell/ML family syntax makes a number of operations very convenient and cut down on a lot of clutter. It's sort of like clojurescript's syntax, but where almost all parentheses can be omitted because the arity of all functions is fixed. Unlike lisp syntax, it also lets you define custom binary operators with any precedence, and it cuts down a lot on Lambdas thanks to partial application. Finding a better syntax for a statically typed functional language is rather difficult to say the least.
Batou · 2017-07-31 04:21
I've used Elm for a few projects and even in production, and I kind of like the language, but its minimalism starts hurting after a while. It's missing a few features that in my opinion make it very hard to write stuff at scale, and while they should be coming in the future, discussion on them has been slow, almost grinded to a halt. First of all, it needs something akin to type classes. Elm already has them as "compiler magic", for example "comparable". This hurts your project, because you'll have to remember to use List.map instead of Array.map, and you'll have to play a cat-and-mouse game with the compiler to change them all if you ever decide to switch for performance reason, and it hurts the language because user-defined data structures are second class citizens. The second is modules that manage their own effects. This also is already in the compiler, in the form of effect modules, and they're another example of "compiler magic" because they're horrible to use and you're not supposed to use them either. I get the whole concerns about the single tree Elm architecture, but writing more complex pages becomes incredibly painful after a while, and you'll have to have a lot of discipline in how you split your project (and isn't the compiler's/type system's job to enforce discipline?). I personally think that an Erlang-like model, with multiple processes for each component of your Elm app communicating through specialized ports, would be very interesting, and this is my third problem with the lanauge. Any discussion suggesting something similar to what I've said is often quickly dismissed, because it is not "the Elm way". I really hate languages like Python that try to get you to do things the "pythonic" way, and Elm is really striving to be like that. And if Evan says something, it's certainly correct. I dislike that he decided to kill off a few features such as a syntax for adding or removing record fields, or a multi-branch if statement similar to case ... of pattern matching which was probably the nicest notation for a conditional I've ever seen in a language, or even stuff like backticks for using prefix functions as infix, just because they were poorly documented and thus "nobody used them". I'm eagerly waiting new releases that address these concerns, but honestly I'm not so hopeful anymore. I'm seeing myself learning Clojurescript or Purescript or figuring out Ur/Web more eagerly than using Elm again, and it's such a shame.
Hagbard Celine · 2017-08-02 11:06
The Elm architecture is really nice and worthy of being copied everywhere. The tooling that comes with Elm is also great. The language itself is less interesting to me than Purescript, though I like the |> ,<|, >>, << syntax borrowed from F#, which is way clearer than Haskell's Perl-like $ and . mess. But the abstractions available are sort of annoying in terms of what isn't inluded when you are used to Haskell. I like Elm, and I might pick it up again at some point if it gets ad-hoc polymorphism. If I just want to make a simple webpage it would probably be among my top choices because of how easy it is to use. I'm just hesitant about using it for nontrivial projects. Purescript has much more powerful abstractions available, and it has simpler (but somewhat unsafe) Javascript interop. It also has the potential to be a more useful language to know in the long term since it's also getting a compiler to native code through a C++ backend which lets you use QT directly for desktop apps.
Unidentified · 2017-08-02 13:46
>>2750 Since we're discussing the various frontend options that are similar to Elm (ML/Haskell family languages transpiled to JS), I think I'll link this comparison which I found very useful: http://mutanatum.com/posts/2017-01-12-Browser-FP-Head-to-Head.html
Zhora · 2017-10-23 08:45
>>2705 Learned the language or "Core" from: http://elmprogramming.com I then headed back to the elm site to learn the architecture: https://guide.elm-lang.org/architecture/ There are a few others popping up. Though it is worth nothing that one wont find much help through searches on problems, at least I didn't. I have been using elm for only about 3 months. I am a recent grad, didn't know much about web and decided to go straight to elm without knowing js. I have two clients currently. Small contracts where the pages aren't very complex. Perhaps that is why I find elm easy to work with at the moment.
Chan Siu Ming · 2017-11-04 05:58
Is Elm good for not intelligent people who want to become one with functional programming? Learning Elm and also as a stepping stone into Haskell or Clean or Agda or Scheme or any ordering of anything
Neo · 2017-11-04 19:21
>>4764 As of now, the Elm language can only be used as a frontend web framework. Elm has very minimalist syntax, so yes I think its a good language for learning functional programming. Its sort of like Elixir with static typing. There is not too much different from Elm to Elixir other than the static typing so I dont think you are gaining anything by learning Elm if you are not doing web programming.
Void · 2017-11-04 19:25
>>4764 Elm is probably the best language for initially learning FP imho. It has good fundamentals, a nearly perfect simple syntax, and no abstract nonsense. You do end up craving advanced features after a while though. It's like the functional programming equivalent of Golang.
x<->y · 2017-11-04 19:26
Also it enforces purity very well, possibly to an even greater degree than Haskell, so it does force you to learn the functional style unlike multiparadigm languages like say Scala.
Mentat · 2017-11-04 22:49
>>4780 Im not sure if this is a joke or a troll or what, but I'll respond anyway. Elm is a great language, I do recommend learning it, it does make the perfect first functional language. The fact that its statically typed and type inferred means that large programs will run on the first try. In fact the people who maintain Elm like to brag that it never has any runtime failures. Just know that it can only be used to make frontend web apps. I would like to see Elm made as a standalone compiler, Im surprised no one has expanded on the use of Elm outside of the browser yet.
Marly Krushkhova · 2017-11-05 08:04
Sorry if this is obvious but finding elm resources is kind of hard how can i convert a bool to a string? like I have True and want to make that "True" is this possible?
Unspecified · 2017-11-05 13:33
>>4785 toString? It works on all types, as far as I remember. But even if it didn't, you could do it like this: boolToString x = case x of True -> "True" False -> "False"
Meddler · 2017-11-05 16:18
>>4788 I feel stupid As you can see I'm new to this.
drop · 2017-11-05 16:54
>>4782 I think the author is holding Elm back by cutting back on interesting features, right now it just feels like a toy language to make toy applications. At a certain point your applications grow and you start wanting better means of abstractions, and when Elm fails to provide them you feel like you've "outgrown" the language.
John Titor · 2017-11-06 14:28
>>4782 because haskell and ocaml which are basically better elms outside of the frontend webapp sector exist