# Scala — Powerful Functional & Object-Oriented JVM Language > Scala is a statically typed programming language that fuses object-oriented and functional programming on the JVM. It powers Apache Spark, Kafka, Akka, and Play Framework, and compiles to JVM bytecode, JavaScript, and native code. ## Install Save in your project root: # Scala — Powerful Functional & Object-Oriented JVM Language ## Quick Use ```bash # Install via Coursier (recommended) curl -fL https://github.com/coursier/coursier/releases/latest/download/cs-x86_64-pc-linux.gz | gzip -d > cs && chmod +x cs && ./cs setup # Start the REPL scala # Compile and run a project with sbt sbt new scala/scala3.g8 cd hello-world && sbt run ``` ## Introduction Scala combines object-oriented and functional programming in a concise, type-safe language that runs on the JVM. Created by Martin Odersky at EPFL, Scala is the foundation of major open-source projects like Apache Spark and Akka, and is used in production at companies building high-throughput data pipelines and distributed systems. ## What Scala Does - Provides a powerful type system with type inference, generics, and pattern matching - Supports functional programming with immutable data, higher-order functions, and algebraic data types - Compiles to JVM bytecode with full Java interoperability - Offers Scala.js for compiling to JavaScript and Scala Native for ahead-of-time compilation - Enables concise, expressive code through case classes, traits, and for-comprehensions ## Architecture Overview The Scala compiler (scalac for Scala 2, dotc for Scala 3) parses source code into an AST, performs type checking with a sophisticated dependent type system, and emits JVM bytecode. Scala 3 (Dotty) introduced a redesigned compiler based on DOT calculus, bringing contextual abstractions, union types, and opaque types. The language interoperates seamlessly with Java libraries — Scala code can call Java and vice versa. ## Self-Hosting & Configuration - Install Scala via Coursier: `cs install scala scalac` - Use sbt (Scala Build Tool) for project management and dependency resolution - Configure `build.sbt` for compiler options, library dependencies, and cross-compilation - Set up IDE support in IntelliJ IDEA (Scala plugin) or VS Code (Metals) - Target Scala 2.13 for maximum library compatibility or Scala 3 for latest features ## Key Features - Pattern matching with exhaustiveness checking for safe, expressive code - Implicit parameters and given/using (Scala 3) for type-class-based programming - Macro system for compile-time code generation and metaprogramming - Concurrent programming via Akka actors, Cats Effect, or ZIO - Strong ecosystem: Spark, Kafka Streams, Play, http4s, and hundreds of libraries ## Comparison with Similar Tools - **Kotlin** — also targets the JVM with modern syntax; Scala offers a more powerful type system and deeper functional programming support - **Java** — Scala runs on the same JVM but provides pattern matching, type inference, and FP that Java is still adopting - **Haskell** — pure functional language; Scala blends FP with OOP and offers JVM ecosystem access - **Clojure** — dynamic Lisp on the JVM; Scala provides static typing and better IDE tooling ## FAQ **Q: Should I use Scala 2 or Scala 3?** A: Scala 3 is the future with cleaner syntax and better tooling. Use Scala 2.13 if you depend on libraries not yet ported to Scala 3. **Q: Is Scala hard to learn coming from Java?** A: Basic Scala is approachable for Java developers. Advanced features like implicits and type-level programming have a steeper curve. **Q: Can I use Scala with Spring Boot?** A: Yes, though the Scala community typically prefers Play Framework, http4s, or ZIO HTTP. **Q: Is Scala suitable for small projects?** A: Yes. Scala scripts and the REPL work well for small tasks. sbt supports lightweight project setups. ## Sources - https://github.com/scala/scala - https://docs.scala-lang.org/ --- Source: https://tokrepo.com/en/workflows/asset-c1d8f805 Author: AI Open Source