Did you know Scala has an FAQ? If you didn’t that could be because it hadn’t been updated in years…
…until now! New version is online at https://docs.scala-lang.org/tutorials/FAQ/index.html — it’s also the first search result if you google “scala faq”, and it’s also reachable via the sca.la redirection service: https://sca.la/faq
PRs with further improvements are encouraged. Source file is https://github.com/scala/docs.scala-lang/blob/master/_overviews/FAQ/index.md
Now that I’ve laid the foundation, I’m hoping this might attract some contributor interest, and then after a while (in a few weeks, perhaps?) we could publicize it more widely.
This scratches a personal itch: I’m often answering the same questions over and over again on Gitter, I feel. From now on, I’m going to try to notice when I’m doing that, and add it to the FAQ.
And still answer, but with an FAQ link
Note that I don’t foresee this turning into a huge document… there are only so many questions are actually frequently asked by newcomers to our chat rooms and forums.
+100 to this: the big dangers with FAQs is that the owners start writing answers to the questions they wish people would ask, or the rare-but-fun ones. A really good FAQ is empirical – you pay close attention to the questions you are actually getting often, and only answer those in it. That’s how you get a FAQ that is genuinely useful, and which people are likely to use a lot.
(I ran both the Questions Desk and FAQ for one of my clubs for about ten years – in the end, the FAQ wound up 18 questions long, and looked nothing like what the officers of the club would have guessed upfront.)
A post was split to a new topic: GitHub Discussions for Scala
Naftoli asked about GitHub Discussions. Oron also asked about it on Gitter. I’ve created a separate thread to talk about that in a broader context than just the FAQ: GitHub Discussions for Scala
Re: the FAQ specifically, the current FAQ happens to have a lot of Stack Overflow links, but there’s nothing tying us to that, we can link to multiple sites.
Do we collect statistics of page visits? Maybe it’d be good to check if the all the FAQ are still FA when adding new ones with a quick glance on how often people land there. Not now, because how old and dusty everything was in that corner of the site, but maybe in the future. Then it would be good to know the infrastructure to check that is already in place.
No clue, not sure if somebody else knows or might like to track this, that’s a bit above my ambition level here, I think.
after a series of PRs from myself and @BalmungSan, I’m feeling like this is in pretty decent shape:
It’s looking pretty good, and I learned something new from it!
I learned something new: It says
List[Int] is erased to
List[Object]. I was assuming that common standard collections are specialized. I guess I might use
Array more often for local and private things.
Yeah I really hope Scala gets automatic specialisation one day. Darkdimus made a prototype of it in or with Dotty a few years back called “linker” or something and it sounded really promising. Maybe once Scala 3 is stable, something like that will be resurrected.
But yeah if you’re on Scala 2.13+, try
ArraySeq for an immutable version of
It’s really too bad that the linker project was not completed. I hope it will be some day. Scala.js has its linker, Scala Native as well, and hopefully Scala JVM will get it too. It seems to me that the linker is the only viable solution for specialization, but that’s only one of the benefits of the linker which would get you all sorts of whole-program optimizations. (Maybe even unboxed options?)
Note that how a type erases and whether a type is specialized are separate questions. So for example
Tuple2 is specialized:
scala 2.13.4> (1, 2.0).getClass
val res5: Class[_ <: (Int, Double)] = class scala.Tuple2$mcID$sp
Tuple2[Int, Double] erases to
scala 2.13.4> def foo(p: (Int, Double)): Double = p._1 + p._2
def foo(p: (Int, Double)): Double
scala 2.13.4> :javap foo
public double foo(scala.Tuple2<java.lang.Object, java.lang.Object>);
scala 2.13.4> :javap scala.Tuple2$mcID$sp
public final class scala.Tuple2$mcID$sp extends scala.Tuple2<java.lang.Object, java.lang.Object> ...
Similarly, even if
List were specialized on
List[Int] would still erase to