Share E-Book
Scan to open this page

Scan with your phone to open this page

AuthorDean Wampler

Get up to speed on Scala--the JVM, JavaScript, and natively compiled language that offers all the benefits of functional programming, a modern object model, and an advanced type system. Packed with code examples, this comprehensive book shows you how to be productive with the language and ecosystem right away. You'll learn why Scala is ideal for building today's highly scalable, data-centric applications, while maximizing developer productivity. While Java remains popular and Kotlin has become popular, Scala hasn't been sitting still. This third edition covers the new features in Scala 3.0 with updates throughout the book. Programming Scala is ideal for beginning to advanced developers who want a complete understanding of Scala's design philosophy and features with a thoroughly practical focus. • Program faster with Scala's succinct and flexible syntax • Dive into basic and advanced functional programming techniques • Build killer big data and distributed apps using Scala's functional combinators and tools like Spark and Akka • Create concise solutions to challenging design problems with the sophisticated type system, mixin composition with traits, pattern matching, and more

AI Reading Assistant

Whole-book reading guide from stratified index samples; jump to passages in the text

AI guide
【One-Line Pitch】 A practical, code-driven guide to Scala 3 for developers who want to fuse object-oriented design with functional programming to build scalable, data-centric applications. Best suited to working programmers moving beyond Java, Python, or TypeScript who want deep, hands-on fluency rather than a language tour. 【Book Arc】 - **Opening (~0%–10%)**: Orients you to Scala 3's design philosophy and toolchain—why the language fuses OO and FP, how to set up sbt, editors, and the REPL, and how to run scripts versus compiled programs. - **Early (~10%–30%)**: Builds core syntax and semantics: `val`/`var` immutability, type inference, case classes and companions, `apply` factories, `Option` instead of null, and a first taste of `Future`-based concurrency. - **Middle (~30%–50%)**: Rounds out the basics—operators, `for` comprehensions, pattern matching, enumerations, and algebraic data types—showing how concise Scala code expresses filtering, extraction, and data modeling. - **Late (~50%–80%)**: Moves into the sophisticated type system, traits and mixin composition, and advanced functional techniques; excerpts do not cover the exact chapter boundaries here. - **Ending (~80%–100%)**: Applies the language to scalable, distributed, data-centric systems using functional combinators and ecosystem tools like Spark and Akka; excerpts do not cover the closing chapters in detail. 【Key Takeaways】 - **Scala's core thesis is fusion, not replacement** (Opening): OO and FP are treated as complementary paradigms in one language, so you keep existing design instincts while gaining a functional mindset. - **Immutability is the default, and it shapes everything** (Early): `val` references and immutable collections like `Seq` are preferred, while `Array` remains mutable—understanding this distinction prevents subtle bugs. - **Case classes and companion objects remove boilerplate** (Early): The compiler generates `apply`, enabling `Point(1.0, 2.0)` without `new`, and companions act as factories—a pattern you'll reuse constantly. - **`Option` makes absence explicit in the type system** (Middle): Because `Map.get` returns `Option`, the compiler forces you to handle `None` rather than forgetting a null check. - **`for` comprehensions are a Swiss-army tool** (Middle): They work over collections and `Option`, support guards and value definitions, and can filter out `None` via pattern matching in one concise expression. - **Enumerations and sealed hierarchies model algebraic data types** (Middle): Scala 3's `enum` syntax and sealed type hierarchies both express ADTs, with transformations obeying well-defined algebraic properties. - **Scala 3 modernizes the language surface** (Early/Middle): Keywords like `given`, `using`, `then`, `opaque`, and `open` replace or refine older constructs such as `implicit` and `requires`, so edition matters when reading examples. - **The type system and traits enable concise design solutions** (Late): Mixin composition, pattern matching, and advanced typing are positioned as practical tools for challenging design problems, not academic curiosities. 【Reading Tips】 - **Deep-read the early syntax and `Option`/`for` sections**: These are the load-bearing concepts; skimming them will make later chapters feel arbitrary. - **Skim the tooling setup if you already use sbt and an IDE**: The sbt command reference and editor/LSP notes are useful for newcomers but not conceptually central. - **Watch for Scala 2 vs. Scala 3 differences**: Some examples are Scala 2-only, and keywords like `implicit`/`requires` are legacy—check the README and version notes before copying code. - **Treat the type-system and traits chapters as the hard middle**: They reward slow reading and experimentation in the REPL or worksheets. - **Take away the paradigm, not just the syntax**: The book's real payoff is learning to think functionally while designing object-oriented systems. 【Coverage Limits】 This guide is based on stratified excerpts covering roughly the first half of the book plus front matter and table-of-contents fragments; the advanced type-system, concurrency, and distributed-application chapters are only partially represented, so specific late-book techniques and examples are not summarized here.
Excerpt 1
54 Numeric Literals 54 Boolean Literals 55 Character Literals 56 String Literals 56 Symbol Literals 58 Function Literals 58 Tuples 58 Option, Some, and None:...
View in text
Excerpt 2
tors and IDEs, such as IntelliJ IDEA and Visual Studio Code. Once you install the required Scala plug-in, most environments can open your sbt project, automa...
View in text
Excerpt 3
cala) scala> array = Array("Bad!") 1 |array = Array("Bad!") |Reassignment to val array scala> array(1) = "still is" scala> array val res1: Array[String] = Ar...
View in text
Excerpt 4
dayOpt <- dayOptions day <- dayOpt fn = day.fullName yield fn assert(goodDays1 == Seq("Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Su...
View in text
Excerpt 5
finition, which also supports “automatic” pattern matching: // src/main/scala/progscala3/patternmatching/MatchTreeADTEnum.scala package progscala3.patternmat...
View in text
Excerpt 6
xecutionContext => Future(1).map(_ * 2).filter(_ > 0) } Create a simple ExecutionContext that just runs tasks in the same thread. It is used to demonstrate r...
View in text
Excerpt 7
he right. Note the parameters are reversed in the anonymous function and we prepend to the accumulator. Hence vector2 and vector2b are equal. Folding really...
View in text
Excerpt 8
essing a request, by defining the protected method process. A concr
View in text
Tags
AI categories
Programming LanguageGoBackend
scala
ISBN: 1492077895
Publisher: O'Reilly Media
Publish Year: 2021
Language: English
Pages: 556
File Format: PDF
File Size: 6.9 MB
Text Preview (First 20 pages)
Registered users can read the full content for free

Register as a Gaohf Library member to read the complete e-book online for free and enjoy a better reading experience.

Generating text preview…