Showing posts from March, 2020

quick note on optimizing scala.js compilation and linking

quick note on optimizing scala.js compilation and linking If you use scala.js, you probably use mill or sbt to handle the compilation and linking phases. sbt’s fastOptJS runs the scala.js compiler as a plugin to the scala compiler. Then the linker is run to create the final .js file. Both the the scala.js compiler and linker are provided as standalone CLI at so you can download and run the compiler and linker by hand. However, you need to add scala.js compiled jars to include external libraries. It’s not convenient to use the compiler or linker by hand if you have alot of dependencies. Also, the compiler and linker are jvm programs so they have slow startup times. Can we do better? You could use the CLI individually without needing to run mill or sbt. This would shrink, somewhat, the continuous memory overhead at the expense of compile time. You could also run bloop standalone which reduces overhead from build tools.

mill for dotty

mill for dotty I was putting together some content for my upcoming scalar 2020 full stack workshop in Poland and I used dotty to whip up a short data fetch programs for the AI part. I created the dotty program quite easily using sbt but as I was typing in some of the boilerplate for sbt, I thought this was perfect time to try mill–a scala build tool. Mill handles more than scala but I was specifically interested in using it for dotty. I installed using coursier by running cs install mill mill-interactive . Coursier is great! Note that mill-interactive installs the interactive version, think interactive prompt, of mill. If you install mill via the shell installer, you only have one command, mill , versus via the coursier way where you get 2 commands mill and mill-i (the CLI names). I developed the short “script” using dotty’s “main” feature and some ammonite libs that are available independent of ammonite. Mill was fast to start and easy to put a build config