3 ms·
I actually tried this route, considering that I was writing a backend in Scala, was familiar and comfortable with Scala, and I absolutely loathed the idea of le
by saosebastiao 11y ago
I actually tried this route, considering that I was writing a backend in Scala, was familiar and comfortable with Scala, and I absolutely loathed the idea of learning Javascript. As it turns out, without an ecosystem with more complete project support, documentation, stack overflow questions, and far more members, you still have to know javascript and even worse you have to know how Scalajs compiles down to javascript, along with how it is built and packaged. Having a problem with the scala version of the react library you want to use? Write up a question for stack overflow, post an issue on github, and then hunker down in the source code and try to find the answer on your own while waiting a few days for a response. I couldn't deal with the lag, at least not for a project that is more than a toy.
I honestly wish I could use Scala in the browser. I'm using Typescript instead. The compilation down to ES6 is so trivial that I don't have to try to guess what the compiler is doing. I can read javascript code and documentation and almost never have trouble figuring out how I would write the same thing in TS. I get the primary benefit of static types, even though I don't get all of the ADT and pattern matching goodness. IDE support in Atom is excellent. Compilation is fast. And the community is large enough that I can usually find an answer quickly through the normal SO, IRC, email list channels.
- maxaf 11y agoI'm tempted to rewrite your comment using s/Scala/JavaScript/g and then wager it would still make perfect sense. I've recently had to bootstrap an Angular project using nothing but pure JS and some Sass. This isn't my first in-browser UI, but the first after a long break from heavy front-end development. My impression is that the quality of tools in the JS world is so damn low, that they're more of a hindrance than help. Gluing together Grunt, Sass, Bower, NPM, Browserify, Uglify and a bunch of internal libraries was a titanic task. By contrast, in the Scala world tools are easier to reason about, fail more cleanly and usually surface problems at compile/build time.
- saosebastiao 11y agoTrust me...I absolutely prefer scala as a language. I love almost everything about it (except maybe SBT, but it's tolerable). It pains me to know that the TS compiler is catching only a fraction of the problems that Scala could. But ultimately anything I write has to end up as javascript, and the community just isn't there to support it, so I end up having to deal with javascript regardless. And yes, the js tools are loathsome in general. I've found Typescript to be the best tool available to me, and webpack is pretty good as well. Everything else I've been able to cut out thankfully.
- maxaf 11y agoOh, webpack is a great example of my frustration: I suspect it might be better than browserify for my needs, but I'm already so shell-shocked from adopting browserify at work that I no longer have the nerve to disturb the house of cards that I've built here. Thus webpack will have to wait. Anyway, I hear you, although the only way to make Scala.js work better for everyone is to use it. Otherwise building a community is an insurmountable chicken-and-egg problem.
- bad_user 11y ago> You still have to know javascript Yes, you have to be familiar with the underlying platform. This is also true for languages running on top of the JVM, as you have to be familiar with the JVM and Java's ecosystem and with POSIX and with the target operating system and so on. And that's not just for Scala and the JVM. Don't get me wrong, you don't have to be an expert, but some knowledge of your underlying stack is always required. > Having a problem with the scala version of the react library you want to use? Write up a question for stack overflow, post an issue on github, and then hunker down in the source code and try to find the answer on your own while waiting a few days for a response. Isn't that, you know, how programming works? Yes, you end up interacting with other people through GitHub Issues, Gitter/IRC channels, StackOverflow, etc. It's actually rewarding, because you end up learning a lot. Us developers, we tend to be introverts. It's hurting us ;-) > The compilation down to ES6 is so trivial that I don't have to try to guess what the compiler is doing. It also means that Typescript is barely a step up from Javascript, so why bother? If you're going to be hip and choose an option that isn't THE mainstream choice, don't you want to pick something that brings enough benefits, to counter-balance the disadvantages of not going for straight Javascript? Scala is a statically typed language in a way that Typescript will never be. Scala enables functional programming in a way that Typescript will never do. For all the bitching and moaning about Scala's SBT build tool and Maven's repositories, it's light years beyond the clusterfuck in Javascript's land when it comes to build tools, continuous integration and dependencies management. And the best part of Scala.js is that you get to use many Scala libraries that are now cross-compiled. That means for example many of the Typelevel libraries, like Simulacrum, Cats, Shapeless, Spire and as a shameless plug, my own Monix: https://github.com/monixio/monix/ https://github.com/monixio/monix/ Scala's ecosystem isn't huge, like that of Java or Javascript, but you know, libraries tend to be in much better shape. For example Scala always had good Future implementations (again, versus the clusterfuck that happened in Javascript) and now Scala has Scala-Async which gives you async/await keywords without having to sacrifice browser compatibility: https://github.com/scala/async https://github.com/scala/async Have a problem with React? Fix it. That's how you and the community can grow.
- spriggan3 11y ago> Have a problem with React? Fix it. That's not how things work in the real world and you know it. Furthermore if you're good enough to fix React then you're good enough to write a complicated JS codebase without the need for a third party language. > It also means that Typescript is barely a step up from Javascript Typescript is a huge step up from Javascript has it brings type safety, which eliminates a whole class of errors, make the code easier to read and document and the price to pay for using TS is quite low compared to using Scala.js . Scala has its place, but right now it's definitely not in the front-end.