Have the best of both worlds. Construct elegant class hierarchies for maximum code reuse and extensibility, implement their behavior using higher-order functions. Or anything in-between.
- SEAMLESS JAVA INTEROP
Scala runs on the JVM, so Java and Scala stacks can be freely mixed for totally seamless integration.
- TYPE INFERENCE
So the type system doesn’t feel so static. Don’t work for the type system. Let the type system work for you!
- CONCURRENCY & DISTRIBUTION
Use data-parallel operations on collections, use actors for concurrency and distribution, or futures for asynchronous programming.
Combine the flexibility of Java-style interfaces with the power of classes. Think principled multiple-inheritance.
- PATTERN MATCHING
Think “switch” on steroids. Match against class hierarchies, sequences, and more.
- HIGHER-ORDER FUNCTIONS
Functions are first-class objects. Compose them with guaranteed type safety. Use them anywhere, pass them to anything.
Run Scala in your browser
Scastie is Scala + sbt in your browser! You can use any version of Scala, or even alternate backends such as Dotty, Scala.js, Scala Native, and Typelevel Scala. You can use any published library. You can save and share Scala programs/builds with anybody.
Scala is object-oriented
Scala is a pure object-oriented language in the sense that every value is an object. Types and behaviors of objects are described by classes and traits. Classes can be extended by subclassing, and by using a flexible mixin-based composition mechanism as a clean replacement for multiple inheritance.
Scala is functional
Scala is also a functional language in the sense that every function is a value. Scala provides a lightweight syntax for defining anonymous functions, it supports higher-order functions, it allows functions to be nested, and it supports currying. Scala’s case classes and its built-in support for pattern matching provide the functionality of algebraic types, which are used in many functional languages. Singleton objects provide a convenient way to group functions that aren’t members of a class.
Furthermore, Scala’s notion of pattern matching naturally extends to the processing of XML data with the help of right-ignoring sequence patterns, by way of general extension via extractor objects. In this context, for comprehensions are useful for formulating queries. These features make Scala ideal for developing applications like web services.