by not-much-io · 10y ago · 0 comments
I didn't think I needed types, until I tried Elm, now I am seriously having an identity crisis..
All my backend Python code is also riddled with type hints to help out with the cognitive load.
Elm - Simple, friendly, helpful
Just wish Elm was more mature, but loving it anyway!
Everyone talks about higher order functions and generic types but lots of languages have that.... the really good ones have ADTs.
Oh what I would give to have ADTs in Java. I would stop using Exceptions for errors (not all exceptions are bad just most of them). I would stop using the annoying visitor pattern... That reminds me that I need to rexamine Derive4J
No typeclasses, no monads, more primitive pattern matching, no guards, use of massive nested elseif considered idiomatic ...
Simple tasks wind up feeling tedious because so many of the standard tools and patterns of any other ML language are simple missing completely. The result feels like trying to work with one of those random toy Lisps people make in a weekend and throw up on Github.
It frustrates me, because in theory I do like the concept of the Elm architecture, I love ML-style type systems, and I work with reactive programming every day in ClojureScript. But the language it's attached to is so incomplete that it quickly just becomes a pain.
I'm currently using it in production with purescript-thermite, a thin wrapper over React, and it's worked out great.
Elm is great for people coming from JS, but not so much for people coming from Haskell.
On the other hand, OCaml also targets JavaScript coding in the browser, via js_of_ocaml or the newer bucklescript.
I would be very interested in a comparison of client-side development with OCaml+js_of_ocaml (or OCaml+bucklescript) versus Elm.
You'd think Beam would be a very different compile target than JS, and it seems weird to make such a huge change without very good reason.
I'd just looove to try and put Elm on the JVM, but I just can't at the moment.
http://learnyousomeerlang.com/dialyzer
But is still optional to compile. The more precise and better the type annotations, the more helpful it is. If it can deduce that some inconsistency or type error occurring it will let user know. If it is not sure, it won't say anything.
Another point is because of isolated process heaps and extra fault tolerance, it is possible to get a high degree of assurance from a system built in Erlang or Elixir even with dynamic typing. And there are certainly many examples of that.
I kind of like to think of it as the Java to late 90s' C++, where "less is more" made it popular.
<personal understanding> Scala seems to want to please everyone, having all the tools at hand - Immutable and Mutable collections, Objects and enforced Pure Functions etc.
That to me seems like a call for trouble in the community, a split between approaches to problem solving at a fundamental level. </personal understanding>
And well one of the things that I love about Elm is the lack of needing to make too many choices because the language doesn't have too many complicated features and prioritises "One good lib over 5 decent libs" (though at this young stage what other option does it have).
Clojurescript, Javascript and I'm betting Scala.js offer a lot of solutions to the same problem and/or have fancy language features that I am looking for an escape from. Just personally want to try going back to "less is more", to see what it is like. :)
Currently, Scala-Native is working on off-JVM Scala, Scala.js is already plenty capable of compiling to efficient JS, and when wasm lands, it'll probably manage that rather easily.
Elm is a neat language, but I think it sort of presents too wide a divide. I have the same problem with Elm as I do with Typescript, Dart, and all of the other languages that recognize JS is a shit language, but just compile to it anyways.
Scala is a VERY well-designed language, and FP/OOP isn't nearly as polarizing as it might seem. I'd recommend LearnXinY Scala, read a little bit and you might see how natural it actually is (excluding the obnoxious syntax for certain things)
But yeah, JS has always been the crucial problem that needs to be solved. *.js is never going to solve it.
What I'm getting at is that OOP+FP is, ultimately, simply OOP, providing none of the guarantees and encouraging none of the best practices that purely FP langs do. It's like the worst of both worlds lol
</opinion>
1. https://github.com/japgolly/scalajs-react