Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

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.



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


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.


It's literally one feature - each of the different "ways" gets rewritten.

It's why Scala 2 and 3 are able to maintain pretty good interoperability.


Did you mean:

    values: DataValue
?

Otherwise the decoder is incorrect and, I'm not 100% sure but, is likely to throw a runtime error.


You are totally right!




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: