Welcome to XCODX Online Compiler
Quick Start:
Ctrl+Enter Run code
Ctrl+S Save / Download
Ctrl+L Clear output
Select a language and start coding.
Welcome to XCODX Online Compiler
Quick Start:
Ctrl+Enter Run code
Ctrl+S Save / Download
Ctrl+L Clear output
Select a language and start coding.
Apache Spark, Kafka, and Akka — three pillars of large-scale data infrastructure — were all written in Scala, and companies like Netflix, LinkedIn, and Databricks lean on it for streaming and analytics pipelines. Designed by Martin Odersky at EPFL, Scala fuses object-oriented and functional programming on the JVM, and Scala 3 modernized the language with cleaner syntax, real enums, and a redesigned type system. This page gives you a Scala environment with an interactive terminal right in the browser: StdIn.readLine blocks for actual keyboard input while your program runs, so you can explore pattern matching and immutable collections without waiting through an sbt setup.
import scala.io.StdIn
object Main extends App {
print("Enter comma-separated numbers: ")
val nums = StdIn.readLine().split(",").map(_.trim.toInt).toList
val doubled = nums.map(_ * 2)
val (evens, odds) = nums.partition(_ % 2 == 0)
println(s"Sum = ${nums.sum}, doubled = ${doubled.mkString(", ")}")
println(s"Evens: $evens | Odds: $odds")
}
Practice the functional patterns that Spark jobs are built from — map, flatMap, fold, partition — on plain collections before applying them to distributed datasets, complete assignments for the functional-programming courses many universities teach in Scala, or prepare for data-engineering interviews where whiteboard questions come with a Scala accent. It's also the quickest way to check how an implicit conversion, case class match, or for-comprehension desugars in practice, with no build tool between you and the answer.
Yes — scala.io.StdIn.readLine (and readInt) read from a live terminal, so execution genuinely suspends at each call until you respond. That covers interactive exercises and any coding-challenge format that streams test input over stdin, with no separate input panel needed.
No — those are external dependencies that require a build tool to fetch, and the sandbox runs a single self-contained file. The Scala standard library plus the entire Java standard library are available, which is plenty for the collection-processing patterns Spark code is made of.
Code that sticks to shared syntax — like the object Main extends App pattern — runs regardless of compiler generation, which is why our example uses it. If you rely on version-specific features (Scala 3 indentation syntax, given/using, or Scala 2 implicits), run once to confirm; compiler errors report the installed version clearly.
Main.scalatext/x-scalaStdIn.readLine()object Main extends App {
println("Hello from Scala!")
println("Welcome to XCODX Online Compiler!")
val message = "Scala is powerful!"
println(message)
}
Building the jar produces a duplicate-manifest warning from java.util.jar. It is filtered from the output pane.