Description #
Scala is a powerful hybrid programming language that blends object-oriented and functional programming concepts. It runs on the Java Virtual Machine (JVM) and offers strong static typing, advanced type inference, and concise syntax, making it suitable for everything from web apps to big data systems.
History #
Scala was created by Martin Odersky and released in 2004. It was designed as a more expressive alternative to Java, with strong support for functional programming. Scala gained popularity in academia, enterprise applications, and with tools like Apache Spark.
Hello World Code #
object HelloWorld {
def main(args: Array[String]): Unit = {
println("Hello, World!")
}
}
How to Run #
Option 1: Online
Option 2: Local
- Install Scala and sbt:
brew install scala sbt # macOS
sudo apt install scala # Linux
Save code in HelloWorld.scala
and run:
scalac HelloWorld.scala
scala HelloWorld
Key Concepts #
- Functional and object-oriented fusion
- Pattern matching
- Immutability and higher-order functions
- Type inference and static typing
- Traits (like interfaces with implementations)
- Case classes and algebraic data types
- Interoperability with Java
- Lazy evaluation
- Expressive syntax and DSL creation
- Concurrency with Akka (actor model)
Try It Online #
Fun Facts #
- Scala stands for “Scalable Language.”
- Apache Spark, a leading big data engine, is written in Scala.
- You can freely mix Java and Scala in the same project.