# Scala ## Install ### Installers These CLI utilities are used to fetch things we need. - [SDKMan](https://sdkman.io/) - [Coursier](https://get-coursier.io/) ### Java We need a JDK, which SDKMAN is used for. ```bash # List available JDKs sdk ls java ``` Amazon seems to have a high-quality one. - [Amazon Coretto](https://aws.amazon.com/corretto/) Version 11 is the last LTS version. ```bash sdk i java 11.0.10.9.1-amzn ``` ### Build #### sbt - [sbt](https://www.scala-sbt.org/index.html) ```bash sdk i sbt 1.5.0 ``` #### Bloop A system-wide build server that speeds compile times and can watch for changes and automatically recompile. - [Bloop](https://scalacenter.github.io/bloop/) ```bash cs install bloop --only-prebuilt=true ``` ## New Project Create a new Scala 3 project using the following template: - [scala3.g8](https://github.com/scala/scala3.g8) ```bash sbt new scala/scala3.g8 ``` Change into your project directory and compile and run it using sbt. ```bash sbt compile sbt run ``` ## SBT Plugins The following plugins can be added to `project/plugins.sbt` to enhance the Scala coding experience. ### Code Formatting - [Scalafmt](https://scalameta.org/scalafmt/) ```bash cs install scalafmt ``` ```scala addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.4.0") // "2.4.0" is just sbt plugin version ``` Metals should automatically create a `.scalafmt.conf` file in the project root. My settings: ```text version = "2.7.4" align.preset = more maxColumn = 100 ``` ### better-monadic-for | A Scala compiler plugin to give patterns and for-comprehensions the love they deserve. - [better-monadic-for](https://github.com/oleg-py/better-monadic-for) ```scala addCompilerPlugin("com.olegpy" %% "better-monadic-for" % "0.3.1") ``` ## IDEs #### VS Code This extension will install everything it needs - [Metals](https://scalameta.org/metals/) ## Watch, Compile, and Run Use Bloop to watch for changes and automatically compile and run your program. Your project should have a `.bloop` directory that contains a `.json`, `-test.json`, and a `` subdirectory. (Metals in VS Code will create this automatically.) If it doesn't exist, you'll need to use `bloop project` to create one. In one terminal session from within your project's root directory (the one that contains `.bloop`), run: ```bash bloop compile -w ``` From another terminal (same directory), run: ```bash bloop run -w ``` ## Project Scaffolds - [Scala 3 Giter8 Template](https://github.com/witt3rd/zio-dotty-quickstart.g8) - [Scala 3 ZIO Starter](https://github.com/witt3rd/zio-starter) ## Language - [Scala 3 Highlights (Dean Wampler)](https://deanwampler.github.io/scala3-highlights.html) - [Rock the JVM](https://rockthejvm.com/) - [Paolo Giarrusso—The DOT Calculus: An Introduction for Scala Programmers](https://www.youtube.com/watch?v=OVu7XzHY5U0) ## Ecosystem ### ZIO - [ZIO](https://github.com/zio/zio) - [A Tour of ZIO](https://youtu.be/TWdC7DhvD8M) - [Scala 3 version](https://github.com/witt3rd/zio-tour) - [Getting started with ZIO](https://youtu.be/6A1SA5Be9qw) - [Functional Programming 101 with Scala and ZIO - Functional World #3](https://youtu.be/gZMwjYTkK9k) - [Prelude](https://github.com/zio/zio-prelude) - [SF Scala: Reimagining Functional Type Classes](https://youtu.be/OwmHgL9F_9Q) - [CLI](https://github.com/zio/zio-cli) - [Query](https://github.com/zio/zio-query) - [Schema](https://github.com/zio/zio-schema) ### Misc - [Scale By The Bay 2020: Juan Pablo Romero, A tour of String diagrams and Monoidal categories](https://youtu.be/CSFEzAgNJFM)