/dotty-examples

Running and building Scala 3 on Windows

Primary LanguageShell

Running Scala 3 on Windows

Dotty logo This repository gathers Scala 3 code examples coming from various websites - mostly from the Dotty project - or written by myself.
In particular it includes several batch files/bash scripts for experimenting with the Scala 3 language on a Windows machine.

This document is part of a series of topics related to Scala 3 on Windows:

JMH, Metaprogramming, GraalVM, Haskell, Kotlin, LLVM, Node.js and TruffleSqueak are other trending topics we are currently monitoring.

Project dependencies

This project depends on two external software for the Microsoft Windows platform:

Optionally one may also install the following software:

Installation policy
When possible we install software from a Zip archive rather than via a Windows installer. In our case we defined C:\opt\ as the installation directory for optional software tools (in reference to the /opt/ directory on Unix).

For instance our development environment looks as follows (February 2021) [3]:

C:\opt\apache-ant-1.10.9\    ( 39.7 MB)
C:\opt\apache-maven-3.6.3\   ( 10.7 MB)
C:\opt\bazel-4.0.0\          ( 41.0 MB)
C:\opt\cfr-0.151\            (  1.9 MB)
C:\opt\Git-2.30.1\           (290.0 MB)
C:\opt\gradle-6.8.3\         (116.0 MB)
C:\opt\jacoco-0.8.6\         ( 10.6 MB)
C:\opt\javafx-sdk-15.0.1\    ( 78.2 MB)
C:\opt\jdk-11.0.10+9\        (181.0 MB)
C:\opt\make-3.81\            (  2.1 MB)
C:\opt\Mill-0.9.5\           ( 53.7 MB)
C:\opt\msys64\               ( 5.56 GB)
C:\opt\sbt-1.4.7\            ( 48.3 MB)
C:\opt\scala-2.13.5\         ( 23.4 MB, 612 MB with API docs)
C:\opt\scala-3.0.0-RC1\      ( 30.1 MB)

🔎 Git for Windows provides a Bash emulation used to run git from the command line (as well as over 250 Unix commands like awk, diff, file, grep, more, mv, rmdir, sed and wc).

Directory structure

This project is organized as follows:

bin\*.bat
bin\cfr-0.151.zip
bin\3.0.0\{scalac.bat, scala.bat, ..}
bin\dotty\
docs\
dotty\     (Git submodule)
examples\{README.md, dotty-example-project, ..}
myexamples\{README.md, 00_AutoParamTupling, ..}
plugin-examples\{README.md, DivideZero, ..}
README.md
RESOURCES.md
setenv.bat

where

We also define a virtual drive W: in our working environment in order to reduce/hide the real path of our project directory (see article "Windows command prompt limitation" from Microsoft Support).

🔎 We use the Windows external command subst to create virtual drives; for instance:

> subst W: %USERPROFILE%\workspace\dotty-examples

In the next section we give a brief description of the batch files present in this project.

Batch/Bash commands

We distinguish different sets of batch/bash commands:

  1. setenv.bat - This batch command makes external tools such as maven.cmd, mill.bat and sbt.bat directly available from the command prompt (see section Project dependencies).

    > setenv help
    Usage: setenv { <option> | <subcommand> }
     
      Options:
        -bash       start Git bash shell instead of Windows command prompt
        -debug      show commands executed by this script
        -verbose    display environment settings
     
      Subcommands:
        help        display this help message
    
  2. Directory bin\ - This directory contains several utility batch files:

  3. Directory bin\3.0.0\ - This directory contains batch files to be copied to the bin\ directory of the Scala 3 installation (eg. C:\opt\scala-3.0.0-RC1\bin\) in order to use the scalac, scaladoc and scala commands on Microsoft Windows.

    We wrote (and do maintain) those batch files based on the bash scripts available from the official Scala 3 distribution. We also have submitted pull request #5444 to add them to the Scala 3 distribution.

     > dir /b c:\opt\dotty-3.0.0-RC1\bin
     common
     common.bat
     scala
     scala.bat
     scalac
     scalac.bat
     scaladoc
     scaladoc.bat
     
  1. File bin\dotty\build.bat - This batch command generates the Scala 3 software distribution from the Windows command prompt.

  2. File bin\dotty\build.sh - This bash command generates the Scala 3 software distribution from the Git Bash command prompt.

  3. File examples\*\build.bat - Finally each example can be built/run using the build command.

    We favor build.bat for the following reasons:

    • It matches user commands executed from the Windows command prompt.
    • It provides subcommands for working with CFR, Scalafmt, JUnit and more.
    • Code examples are simple (mostly one single source file).
    • We don't need the sbt machinery (eg. library dependencies, sbt server).
     > build
     Usage: build { <option> | <subcommand> }
      
       Options:
         -debug           show commands executed by this script
         -dotty           use Scala 3 tools (default)
         -explain         set compiler option -explain
         -explain-types   set compiler option -explain-types
         -main:<name>     define main class name (default: Main)
         -print           print IR after compilation phase 'lambdaLift'
         -scala           use Scala 2 tools
         -tasty           compile both from source and TASTy files
         -timer           display the compile time
         -verbose         display progress messages
      
       Subcommands:
         clean            delete generated class files
         compile          compile Java/Scala source files
         decompile        decompile generated code with CFR
         doc              generate HTML documentation
         help             display this help message
         lint             analyze Scala source files with Scalafmt
         run[:i]          execute main class (instrumented execution: :i)
         test             execute unit tests with JUnit
      
       Properties:
       (to be defined in SBT configuration file project\build.properties)
         main.class       alternative to option -main
         main.args        list of arguments to be passed to main class
     

Optional tools

  1. Build tools

    Code examples in directories examples\ and myexamples\ can also be built with the following tools as an alternative to the build command (see examples\README.md and myexamples\README.md for more details):

    Build tool Configuration file Parent file Usage example
    ant.bat build.xml build.xml ant clean compile run
    bazel.exe BUILD n.a. bazel run :enum-Planet
    gradle.bat build.gradle common.gradle gradle clean build run
    make.exe Makefile Makefile.inc make clean run
    mill.bat build.sc common.sc mill -i app
    mvn.cmd pom.xml pom.xml mvn clean compile test
    sbt.bat build.sbt n.a. sbt clean compile run
  2. Decompiler tools

    As an alternative to the standard javap class decompiler one may use cfr.bat (simply extract bin\cfr-0.151.zip to c:\opt\) which prints Java source code instead of Java bytecode:

     > cfr myexamples\00_AutoParamTupling\target\classes\myexamples\Main.class
     /*
      * Decompiled with CFR 0.151.
      */
     package myexamples;
     
     import myexamples.Main$;
     
     public final class Main {
         public static void test01() {
             Main$.MODULE$.test01();
         }
     
         public static void main(String[] arrstring) {
             Main$.MODULE$.main(arrstring);
         }
     
         public static void test02() {
             Main$.MODULE$.test02();
         }
     }
     

    Here is the console output from command javap with option -c for the same class file:

     > javap -c myexamples\00_AutoParamTupling\target\classes\myexamples\Main.class
     Compiled from "Main.scala"
     public final class myexamples.Main {
       public static void main(java.lang.String[]);
         Code:
            0: getstatic     #13                 // Field myexamples/Main$.MODULE$:Lmyexamples/Main$;
            3: aload_0
            4: invokevirtual #15                 // Method myexamples/Main$.main:([Ljava/lang/String;)V
            7: return
     
       public static void test02();
         Code:
            0: getstatic     #13                 // Field myexamples/Main$.MODULE$:Lmyexamples/Main$;
            3: invokevirtual #19                 // Method myexamples/Main$.test02:()V
            6: return
     
       public static void test01();
         Code:
            0: getstatic     #13                 // Field myexamples/Main$.MODULE$:Lmyexamples/Main$;
            3: invokevirtual #22                 // Method myexamples/Main$.test01:()V
            6: return
     }
     

Usage examples

setenv.bat

Command setenv is executed once to setup our development environment; it makes external tools such as bazel.exe, mvn.cmd, sbt.bat and git.exe directly available from the command prompt.

> setenv
Tool versions:
   javac 11.0.10, java 11.0.10, scalac 2.13.5, scalac 3.0.0-RC1,
   ant 1.10.9, gradle 6.8.3, mill 0.9.5, mvn 3.6.3, sbt 1.4.7,
   bazel 4.0.0, bloop v1.3.4, cfr 0.151, make 3.81, python 3.9.1,
   git 2.30.1.windows.1, diff 3.7, bash 4.4.23(1)-release

> where sbt
C:\opt\sbt-1.4.7\bin\sbt
C:\opt\sbt-1.4.7\bin\sbt.bat

🔎 Other external tools such as javac.exe and scalac.bat are accessible through the corresponding environment variable, e.g. JAVA_HOME for javac.exe, SCALA_HOME resp. SCALA3_HOME for scalac.exe.

Command setenv -verbose also displays the tool paths and defined variables:

> setenv -verbose
Tool versions:
   javac 11.0.10, java 11.0.10, scalac 2.13.5, scalac 3.0.0-RC1,
   ant 1.10.9, gradle 6.8.3, mill 0.9.5, mvn 3.6.3, sbt 1.4.7,
   bazel 4.0.0, cfr 0.151, make 3.81, python 3.9.1,
   git 2.30.1.windows.1, diff 3.7, bash 4.4.23(1)-release
Tool paths:
   C:\opt\jdk-11.0.10+9\bin\javac.exe
   C:\opt\jdk-11.0.10+9\bin\java.exe
   C:\opt\scala-2.13.5\bin\scalac.bat
   C:\opt\scala-3.0.0-RC1\bin\scalac.bat
   C:\opt\apache-ant-1.10.9\bin\ant.bat
   C:\opt\gradle-6.8.3\bin\gradle.bat
   C:\opt\Mill-0.9.5\mill.bat
   C:\opt\apache-maven-3.6.3\bin\mvn.cmd
   C:\opt\sbt-1.4.7\bin\sbt.bat
   C:\opt\bazel-4.0.0\bazel.exe
   C:\opt\cfr-0.151\bin\cfr.bat
   C:\opt\make-3.81\bin\make.exe
   C:\opt\Python-3.9.1\python.exe
   C:\opt\Git-2.30.1\bin\git.exe
   C:\opt\Git-2.30.1\mingw64\bin\git.exe
   C:\opt\Git-2.30.1\usr\bin\diff.exe
   C:\opt\Git-2.30.1\bin\bash.exe
Environment variables:
   ANT_HOME=C:\opt\apache-ant-1.10.9
   GIT_HOME=C:\opt\Git-2.30.1
   JAVA_HOME=C:\opt\jdk-11.0.10+9
   JAVAFX_HOME=C:\opt\javafx-sdk-15.0.1
   PYTHON_HOME=C:\opt\Python-3.9.1
   SBT_HOME=C:\opt\sbt-1.4.7
   SCALA_HOME=C:\opt\scala-2.13.5
   SCALA3_HOME=C:\opt\scala-3.0.0-RC1
   SCALAFMT_HOME=C:\opt\scalafmt-2.7.5

cleanup.bat

Command cleanup removes the output directories (ie. target\) from the example projects:

> cleanup
Finished to clean up 2 subdirectories in W:\dotty\cdsexamples
Finished to clean up 16 subdirectories in W:\dotty\examples
Finished to clean up 12 subdirectories in W:\dotty\myexamples

dirsize.bat {<dir_name>}

Command dirsize returns the size (in Kb, Mb or Gb) of the specified directory paths:

> dirsize examples myexamples c:\opt\scala-3.0.0-RC1 c:\opt\jdk-11.0.10+9
Size of directory "examples" is 3.9 Mb
Size of directory "myexamples" is 1.2 Mb
Size of directory "c:\opt\scala-3.0.0-RC1" is 26.7 Mb
Size of directory "c:\opt\jdk-11.0.10+9" is 184.2 Mb

getnightly.bat

By default command getnightly downloads the library files of the latest Dotty nightly build available from the Maven Central Repository and saves them into directory out\nightly-jars\.

> getnightly

> dir /b out\nightly-jars
scala3-compiler_3.0.0-RC1-3.0.0-RC1-bin-20210207-16bf86f-NIGHTLY.jar
scala3-doc_3.0.0-RC1-3.0.0-RC1-bin-20210207-16bf86f-NIGHTLY.jar
scala3-interfaces-3.0.0-RC1-bin-20210207-16bf86f-NIGHTLY.jar
scala3-language-server_3.0.0-RC1-3.0.0-RC1-bin-20210207-16bf86f-NIGHTLY.jar
scala3-library_3.0.0-RC1-3.0.0-RC1-bin-20210207-16bf86f-NIGHTLY.jar
scala3-library_sjs1_3.0.0-RC1-3.0.0-RC1-bin-20210207-16bf86f-NIGHTLY.jar
scala3-sbt-bridge-3.0.0-RC1-bin-20210207-16bf86f-NIGHTLY.jar
scala3-staging_3.0.0-RC1-3.0.0-RC1-bin-20210207-16bf86f-NIGHTLY.jar
scala3-tasty-inspector_3.0.0-RC1-3.0.0-RC1-bin-20210207-16bf86f-NIGHTLY.jar
tasty-core_3.0.0-RC1-3.0.0-RC1-bin-20210207-16bf86f-NIGHTLY.jar

🔎 A few notes about the distributed Java archives:

  • Dotty versions up to 0.18.0 depend on scala-library-2.12.8.jar; Dotty versions 0.18.1 and newer depend on scala-library-2.13.x.jar.
  • Starting with Dotty version 0.22.0 package dotty.tools.tasty is distributed separately in archive tast-core_<xxx>.jar.
  • Starting with Dotty version 0.28.0 package dotty-library_sjs1.x.jar is part of the software distribution.
     

Command getnightly -verbose also displays the download progress:

> getnightly -verbose
Check for nightly files on Maven repository
Downloading file scala3-compiler_3.0.0-RC1-3.0.0-RC1-bin-20210207-16bf86f-NIGHTLY.jar ... 14.1 Mb
Downloading file scala3-library_3.0.0-RC1-3.0.0-RC1-bin-20210207-16bf86f-NIGHTLY.jar ... 1.1 Mb
Downloading file scala3-tasty-inspector_3.0.0-RC1-3.0.0-RC1-bin-20210207-16bf86f-NIGHTLY.jar ... 16.1 Kb
Downloading file tasty-core_3.0.0-RC1-3.0.0-RC1-bin-20210207-16bf86f-NIGHTLY.jar ... 64.4 Kb
Downloading file scala3-language-server_3.0.0-RC1-3.0.0-RC1-bin-20210207-16bf86f-NIGHTLY.jar ... 146.7 Kb
Downloading file scala3-interfaces-3.0.0-RC1-bin-20210207-16bf86f-NIGHTLY.jar ... 3.7 Kb
Downloading file scala3-library_sjs1_3.0.0-RC1-3.0.0-RC1-bin-20210207-16bf86f-NIGHTLY.jar ... 1.8 Mb
Downloading file scala3-doc_3.0.0-RC1-3.0.0-RC1-bin-20210207-16bf86f-NIGHTLY.jar ... 1 Mb
Downloading file scala3-staging_3.0.0-RC1-3.0.0-RC1-bin-20210207-16bf86f-NIGHTLY.jar ... 35.5 Kb
Downloading file scala3-sbt-bridge-3.0.0-RC1-bin-20210207-16bf86f-NIGHTLY.jar ... 21.8 Kb
Finished to download 10 files to directory W:\out\nightly-jars
Nightly version is 3.0.0-RC1-3.0.0-RC1-bin-20210207-16bf86f-NIGHTLY

We can now replace the library files from the original Scala 3 distribution (installed in directory C:\opt\scala-3.0.0-RC1\ in our case) with library files from the latest nightly build.

Concretely, we specify the activate subcommand to switch to the nightly build version and the reset subcommand to restore the original library files in the Scala 3 installation directory.

> getnightly activate
Local nightly version has changed from 3.0.0-RC1 to 3.0.0-RC1-3.0.0-RC1-bin-20210207-16bf86f-NIGHTLY
Activate nightly build libraries: 3.0.0-RC1-3.0.0-RC1-bin-20210207-16bf86f-NIGHTLY

> scalac -version
Scala compiler version 3.0.0-RC1-bin-20210207-16bf86f-NIGHTLY-git-16bf86f -- Copyright 2002-2021, LAMP/EPFL

> getnightly reset
Activate default Scala libraries: 3.0.0-RC1

> scalac -version
Scala compiler version 3.0.0-RC1 -- Copyright 2002-2020, LAMP/EPFL

⚠️ You need write access to the Scala 3 installation directory (e.g. C:\opt\scala-3.0.0-RC1\ in our case) in order to successfully run the activate/reset subcommands.

Internally command getnightly manages two sets of libraries files which are organized as follows:

> pushd c:\opt\scala-3.0.0-RC1&dir/b/a-d&for /f %i in ('dir/s/b/ad lib') do @(echo lib\%~nxi\&dir/b %i)&popd
VERSION
lib\3.0.0-RC1\
  dist_3.0.0-RC1-3.0.0-RC1.jar
  scala3-compiler_3.0.0-RC1-3.0.0-RC1.jar
  scala3-doc_3.0.0-RC1-3.0.0-RC1.jar
  scala3-interfaces-3.0.0-RC1.jar
  scala3-library_3.0.0-RC1-3.0.0-RC1.jar
  scala3-staging_3.0.0-RC1-3.0.0-RC1.jar
  scala3-tasty-inspector_3.0.0-RC1-3.0.0-RC1.jar
  tasty-core_3.0.0-RC1-3.0.0-RC1.jar
lib\3.0.0-RC1-3.0.0-RC1-bin-20210207-16bf86f-NIGHTLY\
  scala3-compiler_3.0.0-RC1-3.0.0-RC1-bin-20210207-16bf86f-NIGHTLY.jar
  scala3-doc_3.0.0-RC1-3.0.0-RC1-bin-20210207-16bf86f-NIGHTLY.jar
  scala3-interfaces-3.0.0-RC1-bin-20210207-16bf86f-NIGHTLY.jar
  scala3-language-server_3.0.0-RC1-3.0.0-RC1-bin-20210207-16bf86f-NIGHTLY.jar
  scala3-library_3.0.0-RC1-3.0.0-RC1-bin-20210207-16bf86f-NIGHTLY.jar
  scala3-library_sjs1_3.0.0-RC1-3.0.0-RC1-bin-20210207-16bf86f-NIGHTLY.jar
  scala3-sbt-bridge-3.0.0-RC1-bin-20210207-16bf86f-NIGHTLY.jar
  scala3-staging_3.0.0-RC1-3.0.0-RC1-bin-20210207-16bf86f-NIGHTLY.jar
  scala3-tasty-inspector_3.0.0-RC1-3.0.0-RC1-bin-20210207-16bf86f-NIGHTLY.jar
  tasty-core_3.0.0-RC1-3.0.0-RC1-bin-20210207-16bf86f-NIGHTLY.jar

In the above output file VERSION-NIGHTLY contains the signature of the managed nightly build and the lib\ directory contains two backup directories with copies of the library files from the original Scala 3 installation respectively from the latest nightly build.

searchjars.bat <class_name>

Command searchjars helps us to search for class file names in the following directories: project's lib\ directory (if present), Dotty's lib\ directory, Java's lib\ directory and Ivy/Maven default directories.

> searchjars -help
Usage: searchjars { <option> | <class_name> }
 
  Options:
    -artifact        include ~\.ivy2 and ~\.m2 directories
    -help            display this help message
    -ivy             include ~\.ivy directory
    -maven           include ~\.m2 directory
    -verbose         display download progress
 
  Arguments:
    <class_name>     class name

Passing argument System to command searchjars prints the following output (class file names are printed with full path and are prefixed with their containing JAR file:

> searchjars System
Searching for class name System in archive files C:\opt\scala-3.0.0-RC1\lib\*.jar
  jline-reader-3.15.0.jar:org/jline/reader/impl/completer/SystemCompleter.class
  scala-library-2.13.5.jar:scala/sys/SystemProperties$.class
  scala-library-2.13.5.jar:scala/sys/SystemProperties.class
Searching for class name System in archive files C:\opt\scala-2.13.5\lib\*.jar
  jline-3.15.0.jar:org/jline/builtins/SystemRegistryImpl$CommandOutputStream.class
  [...]
  scala-library.jar:scala/sys/SystemProperties$.class
  scala-library.jar:scala/sys/SystemProperties.class
Searching for class name System in archive files C:\opt\jdk-11.0.10+9\lib\*.jar
  jrt-fs.jar:jdk/internal/jrtfs/JrtFileSystem$1.class
  [...]
  jrt-fs.jar:jdk/internal/jrtfs/SystemImage$2.class
  jrt-fs.jar:jdk/internal/jrtfs/SystemImage.class
Searching for class name System in archive files c:\opt\javafx-sdk-15.0.1\lib\*.jar
  javafx.graphics.jar:com/sun/glass/ui/SystemClipboard.class
  [...]
  javafx.graphics.jar:com/sun/javafx/tk/TKSystemMenu.class
  javafx.web.jar:com/sun/webkit/FileSystem.class

Searching for an unknown class name - e.g. BinarySearch - produces the following output:

> searchjars BinarySearch
Searching for class name BinarySearch in archive files C:\opt\scala-3.0.0-RC1\lib\*.jar
Searching for class name BinarySearch in archive files C:\opt\scala-2.13.5\lib\*.jar
Searching for class name BinarySearch in archive files C:\opt\jdk-11.0.10+9\lib\*.jar

Searching for FileSystem with option -artifact produces the following output:

> searchjars FileSystem -artifact
Searching for class name FileSystem in archive files C:\opt\scala-3.0.0-RC1\lib\*.jar
Searching for class name FileSystem in archive files C:\opt\scala-2.13.5\lib\*.jar
Searching for class name FileSystem in archive files c:\opt\jdk-11.0.10+9\lib\*.jar
  jrt-fs.jar:jdk/internal/jrtfs/JrtFileSystem$1.class
  jrt-fs.jar:jdk/internal/jrtfs/JrtFileSystem.class
  jrt-fs.jar:jdk/internal/jrtfs/JrtFileSystemProvider$1.class
  jrt-fs.jar:jdk/internal/jrtfs/JrtFileSystemProvider$JrtFsLoader.class
  jrt-fs.jar:jdk/internal/jrtfs/JrtFileSystemProvider.class
Searching for class name FileSystem in archive files c:\opt\javafx-sdk-15.0.1\lib\*.jar
  javafx.web.jar:com/sun/webkit/FileSystem.class
Searching for class name FileSystem in archive files %USERPROFILE%\.ivy2\cache\*.jar
  okhttp-3.14.2.jar:okhttp3/internal/io/FileSystem$1.class
  okhttp-3.14.2.jar:okhttp3/internal/io/FileSystem.class
  ivy-2.3.0-sbt-839fad1cdc07cf6fc81364d74c323867230432ad.jar:org/apache/ivy/plugins/resolver/FileSystemResolver.class
  ivy-2.3.0-sbt-88d6a93d15f9b029958c1c289a8859e8dfe31a19.jar:org/apache/ivy/plugins/resolver/FileSystemResolver.class
  ivy-2.3.0-sbt-fa726854dd30be842ff9e6d2093df6adfe3871f5.jar:org/apache/ivy/plugins/resolver/FileSystemResolver.class
Searching for class name FileSystem in archive files %USERPROFILE%\.m2\repository\*.jar
  commons-io-2.2.jar:org/apache/commons/io/FileSystemUtils.class
  commons-io-2.5.jar:org/apache/commons/io/FileSystemUtils.class
  commons-io-2.6.jar:org/apache/commons/io/FileSystemUtils.class
  ivy-2.4.0.jar:org/apache/ivy/plugins/resolver/FileSystemResolver.class
  sigar-1.6.4.jar:org/hyperic/sigar/FileSystem.class
  [...]
  stagemonitor-os-0.88.9.jar:org/stagemonitor/os/metrics/FileSystemMetricSet.class

timeit.bat <cmd_1> { & <cmd_i> }

Command timeit prints the execution time (hh:MM:ss format) of the specified command (possibly given with options and parameters):

> timeit dir /b
.gitignore
.gradle
build.bat
build.gradle
build.sbt
build.sc
build.xml
pom.xml
project
settings.gradle
src
target
Execution time: 00:00:01
 
> timeit build clean compile
Execution time: 00:00:08

Chaining of commands is also possible. Note that the command separator (either && or &) must be escaped if the command chain is not quoted. For instance:

> timeit build clean compile ^&^& ant run
...
Execution time: 00:00:11
> timeit "build clean compile && ant run"
...
Execution time: 00:00:11

🔎 The && command separator performs error checking - that is, the commands to the right of the && command run if and only if the command to the left of && succeeds. The & command does not perform error checking - that is, all commands run.

build.bat

Command build is a basic build tool consisting of ~800 lines of batch/Powershell code [4].

Running command build with no option in project examples\enum-Planet generates the following output:

> build clean compile run
Your weight on MERCURY (0) is 0.37775761520093526
Your weight on SATURN (5) is 1.0660155388115666
Your weight on VENUS (1) is 0.9049990998410455
Your weight on URANUS (6) is 0.9051271993894251
Your weight on EARTH (2) is 0.9999999999999999
Your weight on NEPTUNE (7) is 1.1383280724696578
Your weight on MARS (3) is 0.37873718403712886
Your weight on JUPITER (4) is 2.5305575254957406

More usage examples are presented in examples\README.md resp. myexamples\README.md

scala.bat

Scala REPL is an interactive tool for evaluating Scala expressions. Internally, it executes a source script by wrapping it in a template and then compiling and executing the resulting program.

⚠️ Batch file scala.bat is based on the bash script scala available from the standard Scala 3 distribution. We also have submitted pull request #5444 to add that batch file to the Dotty distribution.

> where scala
C:\opt\scala-3.0.0-RC1\bin\scala
C:\opt\scala-3.0.0-RC1\bin\scala.bat

> scala -version
openjdk version "11.0.10" 2021-01-19
OpenJDK Runtime Environment AdoptOpenJDK (build 11.0.10+9)
OpenJDK 64-Bit Server VM AdoptOpenJDK (build 11.0.10+9, mixed mode, sharing)

> scala
Starting scala REPL...
scala> :help
The REPL has several commands available:

:help                    print this summary
:load <path>             interpret lines in a file
:quit                    exit the interpreter
:type <expression>       evaluate the type of the given expression
:imports                 show import history
:reset                   reset the repl to its initial state, forgetting all session entries

scala> System.getenv().get("JAVA_HOME")
val res0: String = C:\opt\jdk-11.0.10+9

scala> System.getenv().get("SCALA3_HOME")
val res1: String = C:\opt\scala-3.0.0-RC1

scala> :load myexamples/HelloWorld/src/main/scala/HelloWorld.scala
// defined object HelloWorld

scala> HelloWorld.main(Array())
Hello world!

scala>:quit

Footnotes

[1] Java LTS versions

Oracle annonces in his Java SE Support Roadmap he will stop public updates of Java SE 8 for commercial use after January 2019. Launched in March 2014 Java SE 8 is classified an LTS release in the new time-based system and Java SE 11, released in September 2018, is the current LTS release.

Java SE 17 is in early access (build 9 released in February 2021); it will be the next LTS release after Java 11.

[2] Using Bazel on Windows

Read the page Builds on Windows of the Bazel website for tips to build with MSVC, Clang, Java or Python on a Windows machine.

For instance, for Visual Studio 2019, we set variable BAZEL_VC to the Visual C++ Build Tools installation directory:

> set BAZEL_VC=C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC

[3] Downloads

In our case we downloaded the following installation files (see section 1):

0.9.5-assembly (mill)                             ( 57 MB)
apache-ant-1.10.9-bin.zip                         (  9 MB)
apache-maven-3.6.3-bin.zip                        (  9 MB)
bazel-4.0.0-windows-x86_64.zip                    ( 40 MB)
gradle-6.8.3-bin.zip                              (103 MB)
jacoco-0.8.6.zip                                  (  4 MB)
make-3.81-bin.zip                                 ( 10 MB)
msys2-x86_64-20210228.exe                         ( 94 MB)
openjdk-17-ea+9_windows-x64_bin.zip               (176 MB)
openjfx-15.0.1_windows-x64_bin-sdk.zip            ( 39 MB)
OpenJDK11U-jdk_x64_windows_hotspot_11.0.10_9.zip  ( 99 MB)
PortableGit-2.30.1-64-bit.7z.exe                  ( 41 MB)
sbt-1.4.7.zip                                     ( 17 MB)
scala-2.13.5.zip                                  ( 21 MB)
scala-3.0.0-RC1.zip                               ( 24 MB)

[4] PowerShell

Command Prompt has been around for as long as we can remember, but starting with Windows 10 build 14971, Microsoft is trying to make PowerShell the main command shell in the operating system.


mics/February 2021