Live data from Hacker News

From First Principles: Why Scala?

lihaoyi.com

11–20 of 342 posts

Re: From First Principles: Why Scala?

#11
I definitely agree that many newer languages are strongly inspired by Scala, but I don't see a strong argument for why to choose Scala over one of a newer hybrid language. My own intuition is that these newer languages have had the benefit of being able to learn from Scala's mistakes. A lot of them have intentionally sacrificed some of the Scala's flexibility to be easier to learn and use.

I found Scala to be an extremely enlightening language: it taught me a lot about functional programming. But, the complex type system and the sacrifices needed to ensure Java compatibility entail many quirks that I find frustrating. I think it's actually a similar dynamic to what you mention: "retro-fitting these features onto an existing language never fits quite as nicely as a language that was designed with them from scratch."

BTW, I am a huge fan of your writing: the Principle of Least Power is a sacred programming text to me .

Re: From First Principles: Why Scala?

#12

If I've said it once I've said it a thousand times: the day Scala kills sbt officially will be the day thousands of devs consider a return to it. Until then, I couldn't dare.

curious. what exactly is wrong with sbt? I used it once of twice when I was learning scala and I liked it a LOT more than gradle/maven. To the point where I actually opted to use it with my Kotlin projects later.

From the same author as OP: https://www.lihaoyi.com/post/SowhatswrongwithSBT.html

Re: From First Principles: Why Scala?

#13

If I've said it once I've said it a thousand times: the day Scala kills sbt officially will be the day thousands of devs consider a return to it. Until then, I couldn't dare.

curious. what exactly is wrong with sbt? I used it once of twice when I was learning scala and I liked it a LOT more than gradle/maven. To the point where I actually opted to use it with my Kotlin projects later.

Being better than maven is not a high bar, you should try cargo/rust, to have a meaningful comparison of a good build system.

The only problem is, once you've tried out Rust, it will be difficult for you to come back to Scala.

Re: From First Principles: Why Scala?

#14
Scala is just an amazing language. I'm very happy that the worst of the 'Scala as a worse Haskell' days is over and that the Scala community is finding it's own programming style.

I remember years ago when I had a heated discussion about local mutable state. An that time it felt like heresy to even suggest it. I just recently had another discussion with the same programmer and he was like: "Yeah, that works".

Good times.

Re: From First Principles: Why Scala?

#15
Is Scala used outside of Spark and Akka? Spark is my company chosen analytic engine, Scala was/is the main language for majority of the production workload. In the last two years or so, more devs are writing PySpark and SparkSQL jobs than Scala.

Re: From First Principles: Why Scala?

#16
post #4

Great Analysis! I agree that languages are becoming more like Scala. I'm not sure about the JIT part though. Aren't many of the recent language success stories now about AOT compiled languages like Go, Rust and Swift?

I am working on an AI book using Swift. Yesterday in a meeting, my manager was asking why Swift. I compared it to Scala, but built on LLVM, and a rich CoreML and other library infrastructure. REPL + closures, very fast build times. I haven’t had much opportunity to use Scala, but I did take Martin’s Functional Programming with Scala course years ago, and that was great.

Scala is a great language. I haven't done that coursera course, but many people swear by it.

To me, Swift and Kotlin look like they have taken inspiration from Scala. I think Kotlin explicitly did. That idea transfer from one area to another is how we get better langauges.

Re: From First Principles: Why Scala?

#17
Scala is one of those great languages with that one Achilles heel. The speed of that compiler:

   $ time scalac Hello.scala

   real    0m2,907s
   user    0m7,901s
   sys     0m0,308s

   $ cat Hello.scala 
   object Hello{
     def main(args: Array[String]){
         println("hello world")
     }
   }
Implicit type conversion can be debated I guess, but otherwise a very beautiful language.

Re: From First Principles: Why Scala?

#18
post #4

Great Analysis! I agree that languages are becoming more like Scala. I'm not sure about the JIT part though. Aren't many of the recent language success stories now about AOT compiled languages like Go, Rust and Swift?

I am working on an AI book using Swift. Yesterday in a meeting, my manager was asking why Swift. I compared it to Scala, but built on LLVM, and a rich CoreML and other library infrastructure. REPL + closures, very fast build times. I haven’t had much opportunity to use Scala, but I did take Martin’s Functional Programming with Scala course years ago, and that was great.

I wish swift were like Scala. It attempts to look and feel like it, but there’s one huge aspect of Scala that is missing in swift that basically makes swift a world apart, which is expressions vs statements.

In Scala everything is an expression, meaning everything evaluates to some result even if that result is void.

In swift everything is a statement. There’s a big difference because statements don’t return things, only functions do.

It sounds minor, especially since swift has pattern matching and first class supper for functions etc, but the truth is these are all improvements over a more oop (in the Java sense) way of programming. They don’t however make the languages very similar because at a more basic so level they’re very different.

I would even go as far as to say that rust is more like Scala than swift is, although it’s been a while since I coded in rust.

Re: From First Principles: Why Scala?

#19
post #14

Scala is just an amazing language. I'm very happy that the worst of the 'Scala as a worse Haskell' days is over and that the Scala community is finding it's own programming style. I remember years ago when I had a heated discussion about local mutable state. An that time it felt like heresy to even suggest it. I just recently had another discussion with the same programmer and he was like: "Yeah, that works". Good ti…

Local mutable state as in a var in a function or how did you mean?

Re: From First Principles: Why Scala?

#20
I dabbled with Scala several years ago, but I've been using Kotlin for a JVM-based project and am happy with it. My main reason for choosing Kotlin is smoother interop with the JVM world. For example:

- Scala adds an Option type, whereas Kotlin adds nullability checking for existing object types.

- Scala has its own convention for getters and setters, whereas Kotlin automatically turns JVM getters and setters into properties.

- Scala defines its own set of collection classes, whereas Kotlin has zero-overhead wrappers over the JVM collection types.

I haven't tried Kotlin/JS lately, but I expect that Kotlin's strong focus on interop with existing stuff would serve it well there too, especially when it comes to minimizing bundle size.

Scala may be more powerful in some ways, but Kotlin gives me the conciseness I want, with great interop with the huge Java ecosystem.

Post reply on HN