Introduction to Scala
Scala is a modern multi-paradigm programming language designed to express common programming patterns in a concise, elegant, and type-safe way.
What is Scala?
Scala stands for "Scalable Language". It's a general-purpose programming language that provides support for both object-oriented programming (OOP) and functional programming (FP).
Key Features
- Object-Oriented: Every value is an object, and every operation is a method call
- Functional: Functions are first-class citizens
- Statically Typed: Advanced type system with type inference
- JVM Based: Runs on the Java Virtual Machine (JVM)
- Interoperable: Seamless Java interoperability
Hello World in Scala
object HelloWorld {
def main(args: Array[String]): Unit = {
println("Hello, world!")
}
}
Setting Up Scala
To get started with Scala:
- Install Java JDK (Scala runs on JVM)
- Install Scala (either through your package manager or download from scala-lang.org)
- Optionally install sbt (Scala Build Tool) for project management
Scala REPL
Scala comes with a Read-Eval-Print Loop (REPL) that lets you experiment with code interactively:
$ scala
Welcome to Scala 2.13.5.
Type in expressions for evaluation. Or try :help.
scala> 1 + 1
res0: Int = 2
scala> println("Hello from REPL!")
Hello from REPL!
← Back to Tutorials