SLC: Make `Vector` the default implementation of `Seq` instead of `List`

In this discussion, I think we can assume it is known and agreed upon that production code written by professional engineers shouldn’t use Seq.apply in contexts where exact performance characteristics might matter.

However, much Scala code doesn’t meet that description. In a great deal of Scala code, I think it’s fine and normal to use Seq.apply. I use it myself often. Writing Seq communicates to the reader that “the exact sequence type doesn’t matter here”. And a lot of the time it simply doesn’t matter:

  • When still learning the language
  • In tests
  • In one-off scripts, prototypes, experiments, and other such casual coding
  • In build definitions
  • Even in production code for sequences that are known not to be performance-critical and/or where the sequence size is known to be short

To pick just one example from the above list, in build.sbt files we all write:

libraryDependencies ++= Seq(...)

I hope nobody would insist that it’s better to write List or Vector here instead of Seq.

3 Likes