Hacker News new | ask | show | jobs
by shrugger 3650 days ago
Scala.js is a lot of fun, have you considered using it? It's quite further along than Elm at this point.
2 comments

The reason I personally haven't looked at Scala (or Scala.js) is the OOP + FP approach.

<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. :)

Well, Scala was originally designed to complement a platform that encourages mutable data structures. When Scala was first getting started, Java didn't have anonymous functions yet, and it was a different time.

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.

<opinion> OOP+FP is the wrong approach, and I'm putting that kindly. (This is also why I nixed Clojure, btw.) Having worked on large OO codebases, dependency hell, side effects, runaway state, and mutable data bugs (not to mention concurrency bugs) eventually become a serious problem, and out of the box, OOP does nothing to discourage these things (but functional languages do). As soon as you give developers access to "impurity" along with their "purity," you start earnestly down the path to massive technical debt. You could code the most functional Scala code ever, but as soon as you incorporate any library at all, you are right back to "zero concurrency guarantees" square 1.

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>

I develop in Scala and I honestly have never experienced the concerns you are raising.

"OOP" implies none of things you are worried about and Scala is a great example of that.

I wished people tried the language before making assumptions based on emotions that are not supported by reality.

What's the largest Scala codebase you've worked on, and what kinds of challenges have you run into?
10000s to 100000s roughly.

I think the important part is to think about how to properly modularize your codebase and not overdoing it. That gets you an "internal" library ecosystem and not only ensures that incremental builds are fast (not really a concern anymore on nowadays) but also fast parallel compiles and deploys.

Code reviews are of course important so that developers are on the same page, but Scala is really great about isolating parts that have to be complicated from the rest (not like Java's " oh, you used a wildcard over there, let's infect the whole codebase with it").

So life is pretty good and I don't think there are huge issues you have to keep in mind compared to other languages, despite the goodness Scala provides you with.

I think most outside concerns are largely overblown: E. g. some people coming from Java might be excited in the first week bring able to define some operators, but it doesn't really matter. Most of the symbols you see in practice are pretty standard (+, -, ... for arithmetic, a few collection things like + (add one thing), ++ (add multiple things) etc.). Going overboard with it is considered bad style, so most libraries out there just don't do it anymore.

Tooling is pretty great overall, although IDEs could always be a bit better.

Compatibility is great and releases are rock-solid, even things like Scala.js which hasn't even reached 1.0 yet.

Does Scala.js also include similar "UI toolkit" as Elm? So no need to fall back to other frameworks.
Scala.js has react[1] which combined with diode[2] (influenced by elm) creates a powerful framework for developing new generation of web apps. There's also a GraphQL implementation called Sangria[3].

1. https://github.com/japgolly/scalajs-react

2. https://github.com/ochrons/diode

3. http://sangria-graphql.org