9 ms·
The way I look at modern Scala is a mix of Python and Java. Do it badly, and you end up with the unmaintainability of Python and the clunkiness of Java. Awful.
by lihaoyi 7y ago
The way I look at modern Scala is a mix of Python and Java.
Do it badly, and you end up with the unmaintainability of Python and the clunkiness of Java. Awful.
Do it well, and you end up with the convenience and interactivity of Python and the typesafety, performance, and toolability of Java.
This lets you implement your code quickly the first time, and have it run blazing fast on a hot JVM, with the compiler having your back as you grow your codebase in size and complexity. Sure beats trying to prototype in Java, or porting half your Python prototype to C when you realize it’s too slow.
Scala has a bad reputation, well-earned due to an early culture of crazy experiments, crazy operators, and crazy tools. But those days are behind us.
You can no longer get stuff into the standard library “just because”, and a lot of the early experiments in that category (xml, parallel collections, parser combinators) has been consciously moved out.
Operator-heavy tools like SBT have largely replaced the crazy operators, while operator-heavy libraries like Dispatch have been largely replaced by less-operator-heavy equivalents.
SBT used to be awful, but it’s improved a lot. And you don’t need to use it: I haven’t touched an SBT build in years by now, in both OSS and proprietary contexts.
There remains a lot of different ways to write Scala, more than most languages, but you don’t need to write Haskell-in-Scala unless you really want to.
I’m personally very happy with my Python-like language with Python-like libraries, with static typing for maintainability, orders of magnitude better runtime performance, excellent parallelism and concurrency, one of the best compile-to-JS experiences in the world, and the best tooling (IDEs, profilers, monitoring, etc.) on the market.
As someone who maintains optimized programming language interpreters, distributed backend clusters, three-tier web apps, command-line tools, and many other things on a daily basis, I appreciate being able to do all this in one language rather than juggling 5 different languages (and 5 different sets of libraries, and 5 different sets of tools, ...) to satisfy each use case.
Scala may be diverse and fragmented, but it’s not as diverse or fragmented as the polyglot Python/Ruby/C/Go/Javascript codebase it would likely take to replace Scala for my daily work
- nullspace 7y ago> I’m personally very happy with my Python-like language with Python-like libraries, with static typing for maintainability, orders of magnitude better runtime performance, excellent parallelism and concurrency, one of the best compile-to-JS experiences in the world, and the best tooling (IDEs, profilers, monitoring, etc.) on the market. Hey lihaoyi, completely agree with you on this. (Coming from someone who recently stopped writing scala). That said, in my opinion, if you got to write “python-like scala” with static typing and hof on a regular basis, you should count yourself as one of the lucky ones. In the context of a diverse team, with interests and experiences ranging from Java to Js to python To all the way to Idris, how would you reconcile how different team members want to write Scala? What I’ve seen this lead to is just because you understand one portion of the codebase, doesn’t mean you can understand another one (both on similar levels of domain complexity), and just because intellij works great on one module, doesn’t mean it’s going to work at all in another one. EDIT: and I have to say, I love your contributions to Scala library ecosystem, and have used many of them. :) they really do reflect the simplicity of python-like scala.
- lihaoyi 7y agoI’d say you deal with it the same as in any other language(s): with consensus, coordination, and code review. After all, if you are a Go shop, what’s stopping someone implementing their code in Haskell? Or someone in a Python shop deciding they want to use Clojurescript on Node.js for scripting? Or even within a language, if you are a Spring shop and someone wanted to implement their service on WebLogic? Scala definitely had a culture of crazy experiments and bifurcation in the past, but it’s always been a matter of team culture rather than of the language itself: something that applies to all languages, especially as polyglot codebases become more common Without Scala, but with the same lack of coordination, quite likely you would end up with 4 separate silos in your polyglot codebase, written in JS, Java, Python, and Haskell/Idris. Would that really be a better state?
- dionian 7y agouse several of your libs in production code for this reason - simple, type safe stuff. perfect example of scala's flexibility. you can write simple/clean stuff in Scala it just takes discipline. scala is a lot like perl, a powerful tool in the right hands, but gives you more rope to hang yourself if you dont know what youre doing
- esarbe 7y agoThat's about my experience. The language is maturing very well and the library ecosystem is just amazing. (Looking at you, lihaoyi!). I really appreciate that I can walk the full gradient from immutable-functional to impure-imperative with one language, depending on the context and the requirements. It takes some discipline for a team (code reviews, regular feedback, discussion on approaches) but I'd say that's true for any language to some degree. Then there is the ecosystem that's getting better and better with every year, with more and more libraries building on and onto each other. SBT has been a sore point in the past, that has been ameliorated quite a bit in the past three years. SBT 1.3.x together with GraalVM native is a game changer! And then there are lots of other build tools that less ambitious and more approachable than SBT, if SBT simply isn't your cuppa. Scala.js is also quite amazing. Scala is definitively underrated in that area. Being able to stay in one tool for a full stack application and being able to shift code seamlessly up and down the stack, depending on the current requirements has been an eye opener for me. Biggest Scala pros - Terse expressive syntax with a strong type system - Welcoming community and creators - Amazing libraries and rich ecosystem - World-class tooling! I the future I hope that Odersky and the core team will continue to identify "implicits" use cases and provide dedicated syntax for them, just like they did with extension methods in Scala 3.
- idclip 7y agoThis comment and lihao’s are rekindling a flame in my chest.
- AheadOfTime295 7y agoScala 3 has been around for seven years on Github https://github.com/lampepfl/dotty/commit/2308509d2651ee78e1122b5d61b798c984c96c4d https://github.com/lampepfl/dotty/commit/2308509d2651ee78e11... Scala.js and Scala Native will support Scala 3 eventually. SBT isn't nearly as bad as it used to be. It's an open question how much more it will "improve".
- esarbe 7y ago> Scala.js and Scala Native will support Scala 3 eventually. I'm looking forward to it! Now that the Dotty experiments come to an end and development of the Scala language shifts away from Scala 2.x to Scala 3 I think this becomes feasible!
- abhijat 7y agoI assume you don't have to use sbt builds because you use mill? Also you mentioned command line tools. Any chance you could elaborate on how you distribute them? Thanks