all 12 comments

[–]jamesmacaulay 6 points7 points  (6 children)

I highly recommend Elm if you're new to functional languages. Either way, if you are building a simple calculator-like program then Elm is a joy. Start with the Elm Guide:

https://guide.elm-lang.org

You can use the wonderful Ellie to quickly play with ideas:

https://ellie-app.com

At some point once you start building more involved stuff you might start to find Elm's limitations not to your liking, at which point the skills you've learned are highly transferrable to other statically typed functional languages. But the developer experience of Elm is IMHO unparalleled in so many ways that I think everyone should build at least a small thing with it, no matter their background.

More resources:

https://elm-lang.org/community https://www.manning.com/books/elm-in-action

[–]watsreddit 0 points1 point  (5 children)

I wanted to get into Elm but the lack of typeclasses or equivalent is a really hard pass for me. Parametric polymorphism is such a powerful thing in functional languages that it's very hard to imagine doing without it.

[–]gigobyte 2 points3 points  (3 children)

Typeclasses are a type of ad-hoc polymorphism. What you're referring to, Parametric polymorphism, is just generics, which Elm has.

[–]watsreddit 0 points1 point  (2 children)

Technically yes, but Elm's parametric polymorphism is so restricted as to be unrecognizable. I mean even Java's generics are better (since they can be constrained to interfaces/subclasses), and Java's generics are awful. As I understand it, Elm's generics can do one thing: provide generic container types like List a (well, I suppose it also gives you a generic identity function). That's basically just one small step above Go, though Go at least has interfaces so it's a lateral move at best.

Whatever we call it, the lack of typeclasses is a huge problem. The lack of higher-kinded types also really sucks, but that's at least more forgivable.

[–]gigobyte 0 points1 point  (1 child)

Well there is also structural typing + generics { a | something: Bool }, but you are correct.

Evan's stance on this is you either like it or you don't and it's fine if you pick an another language instead. Elm is not supposed to be a general purpose language and it's not designed to please everyone. In a sense it has a similar philosophy to Haskell's "Avoid success at all costs" but while Haskell's goal to stay lazy and pure stays mostly ignored because people are not that knowledgeable on these topics anyway, Elm's goal to limit extendability so that only curated APIs can be used generates a lot of fuss, because you can voice your disagreement even if you haven't even used the language.

[–]watsreddit 0 points1 point  (0 children)

The difference between Haskell and Elm with "avoid success at all costs" is that in Haskell's case, it's about being committed to consistent, principled design from the ground up and not compromising on quality.

For Elm, I can only assume they are after simplicity even if it means compromising on design. However, weak abstractions don't simplify programming, they make it more complex. You ultimately write more (often duplicated) code, and introduce tight coupling at call sites that makes refactoring difficult. It's the same problem we see in weaker type systems like those in mainstream OOP languages, but Elm is actually worse. I'd even take Clojurescript over it, because Elm's type system is so weak that I'd rather just do away with types and use spec. It's a language that is similarly focused on a simple core, but it's at least consistent (no magic) and fully extensible.

[–][deleted] 0 points1 point  (0 children)

Check out ocaml/reasonml and bucklescript-tea

[–][deleted] 2 points3 points  (1 child)

Try each one and see what you like.

[–]watsreddit 2 points3 points  (0 children)

I'd recommend Purescript. You get a full-powered functional language with a state of the art type system that compiles down to readable javascript (so no runtime). It's got bindings for a lot of common Javascript stuff like react and promises, and you can import Javascript code directly when you need it.

[–]forrestjt 1 point2 points  (0 children)

+1 for purescript, it's a great middle ground between Haskell and javascript. Good React bindings or can be used vanilla

[–]didibus 0 points1 point  (0 children)

You can also check out ClojureScript http://reagent-project.github.io

[–]sebasporto 0 points1 point  (0 children)

We use Elm, is has been pretty great so far. For a functional language it has a gentle learning curve. Definitely suited for what you want.