Simple tooling for scala 3

Metals, scalacli

Tomasz Godzik

Who am i

Tomasz Godzik

Senior Scala Developer

Who am i

Tomasz Godzik

Senior Scala Developer

previously

contributor for Scala Center

Who am i

  • mdoc

  • metals

  • scalameta

  • dotty

  • bloop

  • various commercial projects

Who am i

  •  mdoc

  • metals

  • scalameta

  • dotty

  • bloop

  • various commercial projects

my company

We provide expert software engineering & consultancy services to give our clients a competitive edge​

agenda

1. Introduction

2. what is simple tooling

3. scalacli

4. scalacli demos

5. metals

6. Metals demos

7. questions

Why does it matter ? 

Simple tooling

COMPLICATED SETUP AND TOOLS

 

 

promote people who can better deal with the setup and not actual business features

you hire people to do a specific task, not fight with the tools

- reduce burnout

- INCREASE PRODUCTIVITY

- retain people

- promote the language (scala)

Simple tools

 what makes a tool simple?

Frictionless

 

Frictionless

 

?

?

?

?

?

?

?

?

 

the most basic requirement

 

people need to know that can easily find your website and instructions

 

whether corporate or open source

EASY TO FIND

 

one simple way

 

VS

 

multiple known ways supported (deb, brew, exe)

EASY TO install

 

should be quick 

 

fine to have longer tasks, but they should fail quickly

 

User should not need to iterate dozens of coffee breaks

Responsive

Hard to achive

 

 improve continuously

 

 there is a reason there are dedicated people for it

 

ideally things should be easy to learn, easy to master

user experience

last, not least

 

Many different ways:

- cookbooks

- IM

- issues

 

 

 

 

Side note:

- triage - not everything needs immediate response

easy to find help

Our two attempts at making the world better

ScalaCLI

 

Metals

 

Our two attempts at making the world better

ScalaCLI

 

Metals

 

Better command line interface for Scala

LSP server providing language features to editors such as VS Code, Vim, Emacs, Sublime

scalacli

 

 

Why?

https://scala-cli.virtuslab.org/

get information

It contains information about how to install it, what features are available, cookbooks and guides with multiple example.

Easy to find

installation

Easy to install

Responsive

 

responsive

- uses fastest compilation tool for Scala - Bloop

- a lot of documentation for the commands

- constructive errors 

- actionable diagnostics

Every command you would need

good UX

> scala-cli run Main.scala

> scala-cli -S 3.1.3 Main.scala

> scala-cli compile --jvm adopt:14 Main.scala

> scala-cli fmt --check

> scala-cli package --native .

> scala-cli publish .

> scala-cli test .

> scala-cli repl --ammonite .

help!

EASY TO FIND HELP

Main commands:
  clean                  Clean the workspace
  compile                Compile Scala code
  dependency-update      Update dependencies in project
  doc                    Generate Scaladoc documentation
  fmt, format, scalafmt  Format Scala code
  repl, console          Fire-up a Scala REPL
  package                Compile and package Scala code
  publish
  publish local
  publish setup
  run                    Compile and run Scala code.
  test                   Compile and test Scala code

Miscellaneous commands:
  about    Print details about this application
  version  Print `scala-cli` version

See 'scala-cli <command> --help' to read about a specific subcommand. 
To see full help run 'scala-cli <command> --help-full'.

Easy to find help

good UX

#!/usr/bin/env -S scala-cli shebang
//> using scala "3.2.0"

object types:
  trait Opaque[H, T](using H =:= T):
    def apply(s: T): H = s.asInstanceOf[H]
    extension (h: H) def value: T = h.asInstanceOf[T]

  opaque type Hello = String 
  object Hello extends Opaque[Hello, String]

@main def hello = 
  import types.{*, given}
  val x = Hello("yes")

  x.value

Scripting

 

- using directives can specify everything CLI can

- can work with shebang

- useful for issues reproductions

 

 

 

 

default scala runner

 

  • SIP to use ScalaCLI as a default `scala`

  • Reduced amount of features maybe introduce new via additional SIP

  • current Work on Ux to keep it in line with old runners

  • separate scalacli still useful to experiment with more features

demo

 

setup ide

scalacli with ides in mind

all the tools developer needs

 

metals

 

- user experience depends on LSP

- complicated/ multi faceted

- not much control over the editor

-still we can try some things

metals

 

 -multiple editors supported

- nvim and VS Code easier

- sublime text and emacs ok

metals

 

Easy to find

Easy to install

- start the workspace outside container

- gitpod/codespaces

- one click setup

- allows for additional caching

 

https://github.com/scalameta/metals-gitpod-sample

Easy to install

cloud ides

1. Added a command to automatically translate stack traces to navigable ones

good UX?

ANALYSE STACKTRACE

 

1. Added a command to automatically translate stack traces to navigable ones

2. Add a button for discoverability

good UX?

ANALYSE STACKTRACE

 

1. Added a command to automatically translate stack traces to navigable ones

2. Add a button for discoverability

3. [Future] Detect when a stack trace is copied

good UX?

ANALYSE STACKTRACE

 

1. Added a command to automatically translate stack traces to navigable ones

2. Add a button for discoverability

3. [Future] Detect when a stack trace is copied

good UX?

ANALYSE STACKTRACE

 

PRoblems:

  • (1) how to show it in different editors without webview

  • (2) not really a button

  • (2,3) not all editors have it

1. Added a command to automatically translate stack traces to navigable ones

2. Add a button for discoverability

3. [Future] Detect when a stack trace is copied

good UX?

ANALYSE STACKTRACE

 

PRoblems:

  • (1) how to show it in different editors without webview

  • (2) not really a button

  • (2,3) not all editors have it

solution:

Enrich the LSP protocol

- we have many ways to view the code, why not expose it

- SEMANTICDB, JAVAP, TASTY, CFR DECOMPILER

- easier to debug your code

- helps to see how the tools understand the file

- additional info when sending bug reports

- useful overall

Easy to find help

Metals analyse

birds eye view of what is happening in the workspace

CONTINUOUSLY IMPROVED

user self help

Metals doctor

Easy to find help

bugfix loop

Easy to find help

issue reported

issue fixed

issue reproduced

better reporting and

automatic fixes

Demo

still a lot to work on

 

only few examples

 

we focus on scala 3, but still works for Scala 2

 

bright future for scala 3!

Presentation: https://slides.com/tomekgodzik/simple-tooling


Metals documentation: https://scalameta.org/metals/

SCALACLI Documentation: https://scala-cli.virtuslab.org/

 

Reach out to me on Twitter: @TomekGodzik  

 

OR

 

Ask me about anything on discord!

 

OR

 

Contact as at VirtusLab - we are doing really cool things with tooling

QUESTIONS?

Simple Scala 3 Tooling

By Tomek Godzik

Simple Scala 3 Tooling

  • 73