Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Scala 3 - A Quick Tour - Singapore Scala Progra...

Scala 3 - A Quick Tour - Singapore Scala Programmers 2021

Scala 3 is just around the corner! But how can you give Scala 3 a try? What are some of its new exciting features? How do you migrate to Scala 3? Join us and you'll discover the answers to these questions ;)

Daniela Sfregola

May 25, 2021
Tweet

More Decks by Daniela Sfregola

Other Decks in Technology

Transcript

  1. Hellooooo • Software Engineer 
 living in London UK •

    Scala Lover ❤ • OS Maintainer • Author of 
 "Get Programming with Scala" by Manning
 
 35% OFF with code "scala3party"
  2. Scala 3 is here! • After 8 years of work

    • 28,000 commits • 7,400 pull requests • 4,100 closed issues • ...released on May 13th, 2021! https://www.scala-lang.org/blog/2021/05/14/scala3-is-here.html
  3. @main Annotation object HelloWorld extends App { println("Hello World!") }

    object HelloWorld { @main def hello: Unit = { println("Hello world!") } }
  4. @main Annotation object HelloWorld extends App { println("Hello World!") }

    object HelloWorld { @main def hello: Unit = { println("Hello world!") } } object Hello { @main def echo(n: Int, word: String): Unit = { println(word * n) } }
  5. Package Object // in file my/demo/package.scala package my package object

    demo { def customLog(msg: String) { println(s"Customised package log: $msg") } }
  6. Package Object // in file my/demo/package.scala package my package object

    demo { def customLog(msg: String) { println(s"Customised package log: $msg") } } [ DROPPED ]
  7. Enums sealed abstract class Color(val rgb: Int)
 case object Red

    extends Color(0xFF0000) case object Green extends Color(0x00FF00) case object Blue extends Color(0x0000FF)
  8. Enums sealed abstract class Color(val rgb: Int)
 case object Red

    extends Color(0xFF0000) case object Green extends Color(0x00FF00) case object Blue extends Color(0x0000FF) enum Color(val rgb: Int): case Red extends Color(0xFF0000) case Green extends Color(0x00FF00) case Blue extends Color(0x0000FF)
  9. Improved Error Messages Arrested Developers What the Scala Compiler &

    Lucille Bluth 
 Have In Common by Fiona Condon, NeScala 2017 https://www.youtube.com/watch?v=78iIbiRwFTM
  10. Improved Error Messages def echo(str: String): Unit = { str

    } def echoTwice(str: String): String = { echo(str) match { case x: String => s"$x$x" } }
  11. Compatibility with 2.13 Migrating to Scala 3 is easy* !

    * if you are using Scala 2.13 * if you don't have macros in your code Scala 3 Migration Guide https://scalacenter.github.io/scala-3-migration-guide