To work with scala with pleasure and effeciency, I had tried SBT, maven, gradle from time to time, but at last I stay with Maven as my main build tool for scala.
Although SBT is popular in scala community, and I had put a lot of time and attention to it before, let’s say:
The chapter about SBT in “Real World Scala”(incomplete), https://github.com/CSUG/real_world_scala/blob/master/02_sbt.markdown How to write a SBT 0.10+ plugin?
In the old days, when we want to create some instances of some classes, we have to use the new keyword, just like this:
val payloadOldWay = new JsonObject(); val message = new JsonObject It’s not a big deal in the most of the time, but when Scala3 comes, the new keyword is not mandatory anymore, I think it’s a small change BUT a big step, less keystrokes matter:
val payload = JsonObject() Underneatch, Scala3 compiler will take care of the old new things, this time, scala team leave simple to user and leave complexity to themselves.
Scala offers its own collection framework besides java’s collections. But most of the time, I use more java’s collection than scala’s. So that means, I have to import converters to convert to or convert from java collections or scala collections. This is annoying in my opinion.
Furthermore, in Scala2.12.x and Scala2.13.x, the collection converters are different, I have write down a note for this or put two code snippets in my Dash.
I get to know extension is via Kotlin, After Scala3, extension comes to scala also. Cheerful, isn’t it?
extension is an elegant way to extend types and classes.
I use Commons-Lang3 library a lot to process string things, Let’s say, StringUtils.isEmpty(StringUtils.trimToEmpty(..)) or StringUtils.substringBetween(StrinUtils.trimToEmpty(..), .., ..), it’s necessary for precaution, but tedious, isn’t it? With Scala 3’s extension ability, we can make this more natural and elegant:
extension (s:String) { def isEmpty():Boolean = StringUtils.
Although we have Executor/ExecutorService, even ForkJoinPool, most of the time, I only use Scala’s Future instead. Not because others are not excellent or no good, just because I feel natural to use Future.
I had said, if the syntax of a programming language is the taste of it, then I like scala’s taste and stick with it. Same same, I like Future style instead of submit(task) or execute(runnable) styles, although the underneath mechanism is almost a same.
I have been writing Scala code for many years, since sbt 0.11.x days.
I checked a project that I open sourced many years ago when I was working at Alibaba, it tells me that it was 11 years ago.
What time flies…
In fact, I had tried many programming languages, so choosing Scala as the main programming language brings a lot thoughts and practices.
Pragmatic I set up a big picture for a team that I think I would like to build and work in many years ago:
Before Scala3, you have to declare a wrapper object for a simple hello world program:
object Main{ def main(args: Array[String]) : Unit = { println("Hello, World") } } When Scala3 comes, a great change follows. If we want to delare an entry method to run a program, we only need to annotate any method you want it to be the main with @main annotation, now, our hello world program becomes a simple one-linner:
Since the content of this column is ONLY my own point of view, so the name BiasedScala comes. Prejudices mayb.
Scala community is small, so I don’t think this column will become popular, I just would like to write it.
I went back to my hometown on vacation of National Day(China). My mom prepared several dishes for dinner. When we were eating, one of the topics we talked about which is the best way of cooking chicken.