Comment

Comment by valenterry

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 every month or so.

> * Scala has tons of language features and lets people do crazy things in the code.

Actually, that's not true. Or rather: compared to what language?

Scala has surprisingly few language features, but the ones it has are very flexible and powerful. Take Kotlin for example. It has method extensions as a dedicated feature. Scala just has implicits which can be used for method extension.

> * Scalatest is stil used by most projects and is annoying to use, as described here: https://github.com/lihaoyi/utest#why-utest. The overuse of DSLs in Scala is really annoying.

I agree with the overuse of DSLs. Luckily that got much better, but older libraries like scalatest still suffer from that.

> * 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

I think that just comes from using the library in a non-idiomatic way. In most applications, you will need to use the whole json anyways, and then you use (or can use) circe like that:

    {
      "id": "c730433b-082c-4984-9d66-855c243266f0",
      "name": "Foo",
      "counts": [1, 2, 3],
      "values": {
        "bar": true,
        "baz": 100.001,
        "qux": ["a", "b"]
      }
    }
    
    case class Data(
     id: String,
     name: String,
     count: List[Int],
     values: List[DataValue]
    )
    
    case class DataValue(
     bar: Boolean,
     baz: Float,
     qux: List[String]
    )
    
    import circe.generic.auto._
    import io.circe.parser._
    
    val data = decode[Data]("...").get
    data.copy(name = data.name.reverse).asJson
Yeah, that is more code, but as I said, in the vast majority for projects, you need all or most of the fields anyways, so all the structure definition is a one-time thing.

The advantage is that the last line is plain Scala code. You don't even need to understand the json-library to do transformations and re-encode into json.

parent valenterry 5 years ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton