How SWIM works (Scala)

Scala3 code (>25k lines) compiles to two outputs: (using sbt "crossproject")
Scala.js web version
Runs in js, creating SVG plots
Easy access => better for exploring system, illustrating points
Open in a web browser, no installation, it just works
Test relative sensitivity to policy options and scientific uncertainties
Response time to parameter adjustments: ~ 0.5-5s
JVM desktop version
Runs as java, reusing swing GUI from JCM
Faster => better for systematic analysis
Run scripts, probabilistic analysis of thousands of variants
Simpler debugging for code in development
Response time to to parameter adjustments: ~ 0.1-1s
Yet both versions calculate exactly the same curves.
Scala3 - strongly typed, multi-paradigm, yet with readable syntax (minimal braces), is both reliable and flexible.
SWIM shows how scala(3).js succeeds to run a complex model in a browser, fast, flexibly, robustly.
So it's "scalable" in the sense that there is scope to increase complexity and resolution, scala code could also move from client to server for more complex / data-intensive science modules.

Note: Scalajs v17 recently added WASM (webassembly) export
This works well - you can try by adding ?wasm to SWIM url
To get your browser to support wasm:
  • In Chrome go to (address bar) chrome://flags/#enable-experimental-webassembly-features.
  • In Vivaldi go to vivaldi://flags and enable "experimental webassembly".
  • In Firefox (recent) it just works.
  • In Safari (even tech-preview) wasm doesn't seem to load yet (although safari fastest for js).
Use the developer console to check it really is mostly wasm - which even makes the svg plots!
Using wasm SWIM recalculates a little faster, although the code has not yet been modified to optimise this, for example gui and console update calls likely slow-down the model loop. Later wasm may also help connect with other models / tools written in other languages.

Links: More about Scala-JS and Scala 3
Next: Model Doc + Code
(Overview)