Hello, World!
@main def main(): Unit =
println("Hello, World!")Tap Run to execute
Main.scala · output appears here
Press Run to execute
Output streams here as your program runs.
Scala is a statically typed, general-purpose programming language created by Martin Odersky, with its first public release in 2004. It fuses object-oriented and functional programming, runs on the Java Virtual Machine with full Java interoperability, and offers powerful features like pattern matching, immutability, type inference, and a sophisticated type system.
Scala is used for building scalable backend systems, data engineering, and distributed computing—most notably as the language behind Apache Spark. It's popular in big data, finance, and high-throughput services. Scala 3, a major redesign of the language, brought a cleaner syntax and improvements while keeping the expressive power that makes Scala suited to complex applications.
Main.scala is the entry point. Add helper files from the explorer and import them into your project.
Use the Input panel to pipe standard input to your program when it needs data.
Run sends your code to a fresh hosted runtime and streams the result into the output panel.
Your draft stays in this browser, and Share creates a separate snapshot link.
Scala source tabs compile together, exposing top-level declarations to Main.scala.
@main def main(): Unit =
println(answer())
def answer(): Int = 42
@main def main(): Unit =
println("Hello, World!")import scala.io.StdIn.readLine
@main def greet(): Unit =
print("Enter your name: ")
val name = readLine()
println(s"Hello, $name!")@main def listDemo(): Unit =
val fruits = List("apple", "banana", "cherry")
for (fruit, i) <- fruits.zipWithIndex do
println(s"${i + 1}: $fruit")def factorial(n: Int): Int =
if n <= 1 then 1 else n * factorial(n - 1)
@main def run(): Unit =
println(factorial(5))case class Point(x: Int, y: Int)
def describe(p: Point): String = p match
case Point(0, 0) => "origin"
case Point(x, 0) => s"on x-axis at $x"
case Point(x, y) => s"point ($x, $y)"
@main def run(): Unit =
println(describe(Point(3, 4)))
println(describe(Point(0, 0)))@main def run(): Unit =
val ages = Map("alice" -> 30, "bob" -> 25)
for (name, age) <- ages do
println(s"$name is $age")
val nums = List(5, 2, 8, 1, 9)
println(nums.sorted)
println(nums.filter(_ % 2 == 0))def divide(a: Int, b: Int): Option[Int] =
if b == 0 then None else Some(a / b)
@main def run(): Unit =
divide(10, 2) match
case Some(v) => println(s"Result: $v")
case None => println("Cannot divide by zero")
val result = try 10 / 0 catch case _: ArithmeticException => -1
println(result)@main def run(): Unit =
val nums = List(1, 2, 3, 4, 5)
val total = nums.foldLeft(0)(_ + _)
println(s"Sum: $total")
println(nums.map(x => x * x))enum Color:
case Red, Green, Blue
def hex(c: Color): String = c match
case Color.Red => "#FF0000"
case Color.Green => "#00FF00"
case Color.Blue => "#0000FF"
@main def run(): Unit =
for c <- Color.values do
println(s"$c -> ${hex(c)}")trait Greeter:
def greet(name: String): String
class Friendly extends Greeter:
def greet(name: String): String = s"Hi, $name!"
@main def run(): Unit =
val g: Greeter = Friendly()
println(g.greet("Scala"))def parse(s: String): Option[Int] = s.toIntOption
@main def run(): Unit =
val result =
for
a <- parse("10")
b <- parse("20")
yield a + b
println(result)The editor uses Monaco, the engine behind VS Code, with language-aware editing tools and familiar keyboard controls.
Type or paste your code into the editor, then click Run (or press Ctrl/Cmd + Enter) to execute it.
Output streams into the console panel, including runtime errors, exit status, and execution time.
Nothing to install and no account to create — code runs in an isolated hosted runtime.
Language-aware autocomplete and IntelliSense suggestions where the editor has a matching language service
Syntax highlighting, with native compiler and runtime errors shown in the console
Bracket matching, auto-indentation, code folding, and a minimap
Multi-cursor editing plus find & replace (Ctrl/Cmd + F)
Full undo/redo history and copy to clipboard
Built on Monaco — the same editor that powers VS Code
Run on demand, or turn on Auto-run to execute on every change
Stop long-running or infinite programs at any time
A real console shows standard output, errors, exit status, and execution time
Pass standard input (stdin) to your program from the Input panel — one value per line
Switch between light and dark themes
Adjust font size and other editor settings
Toggle side-by-side or top/bottom layouts
Enter distraction-free fullscreen mode
Generate a shareable link to your exact code in one click — no login needed
Your work autosaves to your browser, so you can pick up where you left off
Copy the active file to your clipboard
Run code: Ctrl/Cmd + Enter
Find & replace: Ctrl/Cmd + F
Open the full shortcut list from the keyboard icon in the toolbar
Scala is one of 23 linked-project compilers. Run always starts Main.scala; selecting a helper tab changes what you edit, not the entry file.
Scala source tabs compile together, exposing top-level declarations to Main.scala.
Linked-project languages (23): Node.js, TypeScript, Deno, Python, C, Go, Dart, Swift, Rust, Ruby, PHP, Java, Kotlin, C++, C#, Nim, Crystal, Haxe, Zig, Scala, D, Bun, Objective-C.
Single-file scratchpads (46): Matplotlib, NumPy, pandas, Haskell, Clojure, Perl, Lua, Tcl, jq, Raku, Elixir, Bash, Zsh, Nushell, R, Assembly (NASM), Julia, Octave, Groovy, PowerShell, Visual Basic .NET, Odin, Pascal, Lisp, Erlang, CoffeeScript, COBOL, BASIC, V, Racket, OCaml, Prolog, AWK, Emacs Lisp, Emojicode, Forth, F#, Fortran, Assembly (NASM64), Solidity, Mojo, Ada, WASM (WAT), Gleam, Shell Script (sh), Scheme. Their extra project files are not submitted to the runtime.
Download project exports every Scala tab and a README in one ZIP archive.