Live data from Hacker News

From First Principles: Why Scala?

lihaoyi.com

61–70 of 342 posts

Re: From First Principles: Why Scala?

#61
post #59

Earlier quoted context omitted.

Let's clarify some points for folks not so familiar with Scala. > * Scala minor version are binary incompatible, so maintaining Scala projects is a big pain. Upgrading Spark from Scala 2.11 to Scala 2.12 was a massive undertaking for example. Scala just chose a strange naming scheme. Other languages would have just increased their major version instead. The scala minor version is increased every few years and not eve…

> Scala just has implicits which can be used for method extension. I don't think it's fair to say it like this. Scala's implicits can mean different things, depending on where they're used. Scala 3 even divides 'implicit' to multiple keywords. (kind of 'static' in C++ I guess, only more complicated)

That's exactly what I said, no?

Scala has one feature (implicits) but it can be used ("mean") for different things.

Essentially, you can mark definitions as implicit and you can mark parameters as implicit. Yes, Scala 3 uses different keywords to make it easier to understand which is what, but both is still just the concept of things being implicit.

Think about it: one without the other is completely useless. If you cannot define implicit parameters, then marking any value as implicit will not have any effect. The other way around too: you can mark your parameters as implicit as much as you want, if you can't define implicit values, you will always be forced to pass all parameters manually.

Even implicit classes (excentions) are just syntactic sugar for regular methods that are marked implicit.

Re: From First Principles: Why Scala?

#62

I am a Scala programmer & think it's a great language. Here are some arguments for why not Scala: * Li's libs (os-lib, upickle, utest) have clean public interfaces, but most Scala ecosystem libs are hard to use, see the JSON alternatives for examples: https://www.lihaoyi.com/post/uJsonfastflexibleandintuitiveJS... * The Mill build tool looks a lot better than SBT, but seems like everyone is still using SBT * Scala mi…

Overheard on a Java conference: "I love Scala, clients pay me big bucks to rewrite it into sane Java code".

Re: From First Principles: Why Scala?

#63
post #26

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 pr…

> Scala defines its own set of collection classes [...] One (arguably) negative consequence of this is that Scala's collections don't play nice with Hibernate and similar ORMs. Due to the way they work, both Scala and Hibernate wanted to "take over" your collections, and obviously they cannot do so at the same time. Of course, it's arguable whether this is a flaw with Scala or with Hibernate, but for the programmers…

The two major SQL libraries in the Scala ecosystem these days are Doobie (https://tpolecat.github.io/doobie/) and Slick (https://scala-slick.org/).

With Doobie you manually write your queries, and then map the results into the objects in your domain model. Nothing is generated for you. OTOH, nothing is hidden and you are free to write queries as optimized and specialized as you need. The real selling point of Doobie is a typesafe API for manipulating and combining queries, and fragments of queries, into larger wholes. This works very well when your application interfaces with a database it doesn't own.

With Slick you get access to a DSL that lets you layout how your tables look. From there Slick offers an api that let's you treat SQL tables as-if they are basically mutable collections, with Slick handling all the SQL generation itself. You also get DDL, so that you can automate db creation and upgrades. This work very well when your application owns and controls the database it is connecting to.

Both of these have diverged from that traditional ORM model. Slick bills itself as FRM, or Functional Relational Mapping. And Doobie is embedded queries on steroids.

Re: From First Principles: Why Scala?

#64

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 extr…

>the sacrifices needed to ensure Java compatibility entail many quirks that I find frustrating. That reminds me of that dead JVM language called Ceylon. It didn't compromise anything to ensure Java compatibility. The combination of OOP+FP was executed with zero friction. Meanwhile Scala did it so poorly it created a stupid myth that OOP and FP shouldn't mix. Of course everyone knows that nobody used Ceylon, not even…

Ceylon was (is?) really beautiful. At least type unions/intersections found their way into Typescript.

IMO Gavin's biggest mistake was picking Eclipse for the IDE platform at a time when every professional was moving to IntelliJ.

Re: From First Principles: Why Scala?

#65
post #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.

def mirrors my experience too. Vast majority of spark jobs were easily ported to sql/dbt and the remaining ones are in pyspark. I used to use a lot of scala spark in backend data processing in 2016 but now its almost down to zero. scala is real big impediment to making data processing accessible to general public in your company. order of preference now at my company is, 1. sql 2. pyspark 3. java spark 4. scala spark…

> scala is real big impediment to making data processing accessible to general public in your company

Ding Ding Ding! Presto/Athena now is becoming huge in BI ecosystem. We don't really use Spark for ad-hoc BI anymore, we use it for data science and large repetitive workload.

Re: From First Principles: Why Scala?

#66
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?

There are very few optimizations that a JIT can improve over a static compilation of a strongly-typed language. Strong typing brings immense capability for static analysis and subsequent optimizations. The most successful JIT optimizations out there typically are ones that make dynamic languages about as fast as statically typed languages by making assumptions about the runtime types of objects, while trapping/reopti…

I agree that a AOT scala would be great. But don't JITs have the ability to react to real world usage and do hotspot optimization and stuff. I assume they are very complicated to build, and if you do thing ahead of time you should, but aren't the things that can only be done in a JIT important?

Re: From First Principles: Why Scala?

#67

Earlier quoted context omitted.

> Hard to win technical arguments with Scala geniuses that like using complicated language features. I was on a team building good old crud apps using monads, monoids, categories, combinators, effects cats, seamless and bunch of other nonsense that i've now purged from my brain. You could've easily mistaken our team for a programming language research group at a university. This is literally the number one reason i w…

This is my biggest gripe with Scala as well. I'm sure it's a great language, but I've often seen it used to add complexity where none is necessary. It's abused to give developers a sense of accomplishment and intellectual superiority. In fact, in one project my former employer was involved in, one main reason they picked Scala was to, on the one hand, weed out the chaff from their existing team of .net developers (in…

> sense of accomplishment and intellectual superiority

This, I feel, is underneath a very large proportion of everything in our industry.

Re: From First Principles: Why Scala?

#68
post #55
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…

Unfortunately, "Scala as a worse Haskell" is alive and well. The /r/Scala subreddit, for example, is dominated by folks who tell every Scala-curious beginner who drops by that the accepted right way to write Scala is the pure FP ecosystem and everything else died a long time ago. There are beautiful, simple, elegant ways to write Scala, but I'm afraid that the community isn't converging on a single concrete style, an…

Yep this is a huge cultural problem with the Scala community. On paper and in marketing material, Scala is flexible enough to empower you to slip into mutable/OOP style or more FP style. But in practice the pure FP enthusiasts are the ones who totally dominate the ecosystem (aside from Haoyi Li). You simply cannot just ignore the Haskell Larpers/Wannabe's and get on with it, because they infect all the community watering holes like Reddit, Gitter and Discourse. Every time one talks about using non-pure-FP features of the language, they have to go through the same tired patronizing lectures about how "yes I know this is not 'safe'" and "yes I know what I'm doing" and "I'm very sorry that I am not as smart as you smart FP people" before you can actually talk about what you want to talk about.

Re: From First Principles: Why Scala?

#69
post #59

Earlier quoted context omitted.

> Scala just has implicits which can be used for method extension. I don't think it's fair to say it like this. Scala's implicits can mean different things, depending on where they're used. Scala 3 even divides 'implicit' to multiple keywords. (kind of 'static' in C++ I guess, only more complicated)

That's exactly what I said, no? Scala has one feature (implicits) but it can be used ("mean") for different things. Essentially, you can mark definitions as implicit and you can mark parameters as implicit. Yes, Scala 3 uses different keywords to make it easier to understand which is what, but both is still just the concept of things being implicit. Think about it: one without the other is completely useless. If you…

I’m not a Scala programmer so I don’t know who is more right here, but _ai_ was saying that calling three different features by one name does not mean there’s really one feature. Which is different than saying one feature can be used in three different ways. The C++ static example was used because in that case the same keyword was used for several literally different features to avoid adding additional reserved words.

Re: From First Principles: Why Scala?

#70

I am a Scala programmer & think it's a great language. Here are some arguments for why not Scala: * Li's libs (os-lib, upickle, utest) have clean public interfaces, but most Scala ecosystem libs are hard to use, see the JSON alternatives for examples: https://www.lihaoyi.com/post/uJsonfastflexibleandintuitiveJS... * The Mill build tool looks a lot better than SBT, but seems like everyone is still using SBT * Scala mi…

> Hard to win technical arguments with Scala geniuses that like using complicated language features. I was on a team building good old crud apps using monads, monoids, categories, combinators, effects cats, seamless and bunch of other nonsense that i've now purged from my brain. You could've easily mistaken our team for a programming language research group at a university. This is literally the number one reason i w…

I love Scala. But arguing with intellectuals who HAVE to use these feature just because they can is a struggle I hate dealing with.
Post reply on HN