• u_tamtam@programming.dev
    link
    fedilink
    English
    arrow-up
    0
    ·
    edit-2
    1 year ago

    IMO Scala is one of the best programming languages out there. I know it might sound like zealotry because Scala is already way past its hype curve, and the “Through of disillusionment” already caught a fair bunch in ways that more recent and hyped languages haven’t yet, but it’s not only still very relevant today, but more and more so (IMO).

    So, what’s to like about Scala? Like most of things, those are two-edged swords:

    1- multi paradigm

    To my knowledge Scala is the only language that unifies object oriented programming and functional programming so seamlessly. You can pick the right tool for the job, opting for imperative-style where it’s fit and choosing elegant composable/curried when appropriate, without having to bend your mind as much as you would with Haskell/clojure/OCaml/F#/… where things are more one-sided. The downside is that different programmers will have different takes and preferences as to what’s the most adequate style might be, and a same codebase might look very different from one place to the other.

    2- type system

    Scala has one of the most advanced type system. Nothing Rust or Kotlin might match any time soon, or ever. Scala’s implementation of GADTs, combined with its powerful pattern matching enables concise and idiomatic abstractions. Many of which are zero-cost thanks to things like opaque types, inlining, tail recursion, … There is a whole area of the Scala community striving to make invalid states irrepresentable (your code won’t compile if your instance of a pizza is missing a topping), which makes such libraries self-documenting and easy to use. The downside is that nothing prevents you from climbing the abstraction ladder and encoding everything in the type system when all you need is a simple trait/generic, and that’s a human/complexity management problem tooling and the language can hardly mitigate.

    3- scalable

    The author of Scala (who was a long-time Java compiler architect) wanted Scala to scale from shells one liners to complex multi-cluster distributed systems, and delivered on that. You can start small with a scala-cli proof of concept, transition to a mid-scale “python with types” kind of project, and grow up to very large and complex projects. Beyond the JVM, you can target the browser with scala-js and share models and validation logic between the front and back ends. You can target native binaries for instant startup/low footprint executables that are cheap to spin-up as microservices.

    4- has a foothold in academics

    A whole team at the EPFL is pushing boundaries of programming languages and using Scala and its compiler as a ground for experimentations. Scala 3 has a proven sound type system thanks to its foundations on the DOT calculus. Effects and Capabilities are being researched as part of the project Caprese to offer a solution to “what color is your function” (mixing sync and async), of memory management/lifecycles (more generic than rustc’s), of pure/side-effectful code, etc. The downside is that this gives an impression that Scala’s development lacks focus, but arguably those happen in distinct development branches and by different people.

    Anyway, feel free to continue the discussion on: !scala@programming.dev

    !scala@programming.dev

      • argv_minus_one@beehaw.org
        link
        fedilink
        English
        arrow-up
        0
        ·
        1 year ago

        Since when?

        Scala lets you define new operators, but only in the sense that any method can be used in operator notation and method names don’t have to be alphanumeric (e.g. ++ is a valid method name).

        Scala lets you quote reserved words in order to use them as identifiers. They’re quoted, though; an unquoted reserved word cannot be used as an identifier.

        Several Java operators, including instanceof, are just methods in Scala. They are special in that they are final and don’t cause NPE when called on null, but they are not reserved words and can, for example, be used as local variable names.

        Scala isn’t insane, just misunderstood. Its build tool, on the other hand… 😬

        • u_tamtam@programming.dev
          link
          fedilink
          English
          arrow-up
          0
          ·
          1 year ago

          Scala isn’t insane, just misunderstood. Its build tool, on the other hand… 😬

          Good thing is, mill brings a lot of sanity into this space. It’s been years since I’ve had to use sbt on a regular basis, and every time I looked at it since was with incomprehension and disgust. I don’t think sbt is improving in ways that makes it friendlier. Nowadays scala-cli is all the rage, and deserved (IMO).