Beginning Scala -  David Pollak

Beginning Scala (eBook)

(Autor)

eBook Download: PDF
2009 | 1st ed.
XXII, 350 Seiten
Apress (Verlag)
978-1-4302-1990-3 (ISBN)
Systemvoraussetzungen
46,99 inkl. MwSt
  • Download sofort lieferbar
  • Zahlungsarten anzeigen

The open source Scala language is a Java-based dynamic scripting, functional programming language. Moreover, this highly scalable scripting language lends itself well to building cloud-based/deliverable Software as a Service (SaaS) online applications.

Written by Lift Scala web framework founder and lead Dave Pollak, Beginning Scala takes a down-to-earth approach to teaching Scala that leads you through simple examples that can be combined to build complex, scalable systems and applications.

This book introduces you to the Scala programming language and then guides you through Scala constructs and libraries that allow small and large teams to assemble small components into high-performance, scalable systems. You will learn why Scala is becoming the language of choice for Web 2.0 companies such as Twitter as well as enterprises such as Seimens and SAP.



David Pollak has been writing commercial software since 1977. He wrote the award-winning Mesa spreadsheet, which in 1992 was the first real-time spreadsheet. Wall Street companies traded billions of dollars a day through Mesa. In 1996, David sold his company to CMP Media and became CTO of CMP Media's NetGuide Live and was one of the first large-scale users of Java and WebLogic to power an Internet site. In 1998, David released Integer, the world's first browser-accessible, multiuser spreadsheet. Since 2000, David has been consulting for companies including Hewlett-Packard, Pretzel Logic/WebGain, BankServ, Twitter, and SAP. David has been using Scala since 2006 and is the lead developer of the Lift Web framework.
The open source Scala language is a Java-based dynamic scripting, functional programming language. Moreover, this highly scalable scripting language lends itself well to building cloud-based/deliverable Software as a Service (SaaS) online applications. Written by Lift Scala web framework founder and lead Dave Pollak, Beginning Scala takes a down-to-earth approach to teaching Scala that leads you through simple examples that can be combined to build complex, scalable systems and applications. This book introduces you to the Scala programming language and then guides you through Scala constructs and libraries that allow small and large teams to assemble small components into high-performance, scalable systems. You will learn why Scala is becoming the language of choice for Web 2.0 companies such as Twitter as well as enterprises such as Seimens and SAP.

David Pollak has been writing commercial software since 1977. He wrote the award-winning Mesa spreadsheet, which in 1992 was the first real-time spreadsheet. Wall Street companies traded billions of dollars a day through Mesa. In 1996, David sold his company to CMP Media and became CTO of CMP Media's NetGuide Live and was one of the first large-scale users of Java and WebLogic to power an Internet site. In 1998, David released Integer, the world's first browser-accessible, multiuser spreadsheet. Since 2000, David has been consulting for companies including Hewlett-Packard, Pretzel Logic/WebGain, BankServ, Twitter, and SAP. David has been using Scala since 2006 and is the lead developer of the Lift Web framework.

Contents at a Glance 5
Table of Contents 6
Foreword 12
About the Author 13
About the Technical Reviewer 14
Acknowledgments 15
Introduction 16
Who This Book Is For 16
How This Book Is Structured 17
Prerequisites 17
Downloading the Code 17
Contacting the Author 17
CHAPTER 1 About Scala and How to Install It 18
Scala: A Great Language for the Java Virtual Machine 18
Beyond Java 19
Finding Scala 20
Scala’s History 22
Installing Scala 23
Installing on Windows 23
Installing on Mac OS X and Linux 25
The Scala Community 25
Summary 27
CHAPTER 2 Scala Syntax, Scripts, and Your First Scala Programs 28
Scala at the Command Line and Scala Scripts 28
Interactive Scala 28
Scala Scripts 30
Compiling Scala Programs 30
Your First Scala Programs 31
Hello World 31
Printing Some Numbers 32
Adding Things Up 32
Importing Stuff 33
Parsing a String to an Int 33
Summing Things Up 35
Program Body 36
Basic Scala Syntax 37
Number, String, and XML Constants 37
package 38
import 38
Class, Trait, and Object Definition 39
Scala’s Class Hierarchy 44
Method Declaration 45
Variable Declaration 47
Code Blocks 48
Call-by-Name 48
Method Invocation 50
Functions, apply, update, and Compiler Magic 51
Case Classes 53
Basic Pattern Matching 55
if/else and while 57
The for comprehension 58
throw, try/catch/finally, and synchronized 60
Comments 62
Scala vs. Java vs. Ruby 62
Classes and Instances 62
Traits, Interfaces, and Mixins 63
Object, Static, and Singletons 64
Functions, Anonymous Inner Classes, and Lambdas/Procs 64
Summary 65
CHAPTER 3 Collections and the Joy of Immutability 66
Thinking Immutably 66
Scala List, Tuple, Option, and Map Classes 68
List[T] 70
Getting Functional 72
Contrast with Java 73
Transformation 75
Transformation vs. Mutation 77
Reduxio 78
Look Ma, No Loops 81
Tuples 83
Map[K, V] 84
Option[T] 89
Wrapping Up List, Tuple, Map, and Option 91
XML Creation and Manipulation 92
XML in Your Scala Code 92
Parsing XML 98
Modifying XML 101
Concurrency Without Synchronization 104
Summary 109
CHAPTER 4 Fun with Functions, and Never Having to Close That JDBC Connection 110
A Function Is an Instance 110
Passing Functions As Parameters 111
Partial Application and Functions 114
Functions and Type Parameters 116
Functions Bound to Variables in Scope 117
Putting Functions in Containers 120
Functions and Interactive Applications 121
Building New Functions 122
Call-by-Name, Call-by-Value, and General Laziness 124
Build Your Own Control Structures 126
JDBC Looping 128
Summary 130
CHAPTER 5 Pattern Matching 131
Basic Pattern Matching 131
Matching Any Type 133
More Pattern Matching 135
Testing Data Types 135
Case Classes 136
Pattern Matching in Lists 139
Pattern Matching and Lists 140
Nested Pattern Matching in Case Classes 142
Examining the Internals of Pattern Matching 144
Pattern Matching As Functions 145
Object-Oriented and Functional Tensions 147
Shape Abstractions 148
Summary 152
CHAPTER 6 Actors and Concurrency 153
A Different Approach to Concurrency: Look Ma, No Locks 153
Defining an Actor 154
Defining an Actor 155
Would You Like State With That? 156
Instantiating an Actor 157
Implementing a Listener 158
As an Actor 160
Actors: More Than Write-Only 164
Beyond the Basics 165
Protocol Handler 165
Actors, Atomic Updates, and Transactions 169
Performing an Atomic Update 169
Performing Transactions 171
Testing the Transactional Actor 177
Composing Actors 180
Summary 185
CHAPTER 7 Traits and Types and Gnarly Stuff for Architects 187
Show Me Some Bad Java Code 188
Library Pimping, Implicit Conversions, and Vampires 189
Library Pimping³ 191
Inviting Vampires Into Your Code 196
Traits: Interfaces on Steroids 197
Traits and Class Hierarchies 200
Types—It’s Beyond Generic 206
Table Code 207
The Column 213
The Table 213
Concrete Columns 214
Building a Query 216
Making Queries Type-Safe 217
Boilerplate 219
Vending JDBC Connections 221
Making a Concrete Class That Implements Table 221
Type-Safe Fun 222
Variance 223
Invariant Parameter Types 224
Covariant Parameter Types 226
Contravariant Parameter Types 227
Rules of Variance 229
Poignantly Killing Bunnies: Dwemthy’s Stairs 230
The Immutable World 230
The Code 231
Walking Through the Code 236
Summary 247
CHAPTER 8 Parsers—Because BNF Is Not Just for Academics Anymore 249
Higher-Order Functions and Combinators 249
Higher-Order Functions 250
Combinators 251
The Calculator Parser 253
JSON Parsing 258
Twitter JSON Parsing 268
Utilities 269
Parsing the JSON 271
Summary 277
CHAPTER 9 Scaling Your Team 278
Testing: Behavior-Driven Development 278
Specs 279
Scala Test 280
Build Tools 281
Maven 281
Ant 284
Buildr 286
Other Build Tools 286
Team Structure 287
Bringing New Team Members on Board 287
Organizing Teams Around Scala 288
Best Practices 289
Options Instead of Null Testing 289
Focus on Immutability 290
Keep Methods Short 291
Refactor Mercilessly 292
Compose Functions and Compose Classes 293
Selling Scala in Your Organization 294
The Super-Soft Sell 294
The Back-Office Project 295
The Big Sell 295
Addressing the Potential Risks of Scala 296
My Direct Experience (YMMV) 297
Selecting Team Members 297
Yeah, But How Compatible? 298
A Tad Bit of History 299
Present-Day Compatibility 300
Popping the Stack to the CEO or Board 300
Why Is Scala Different? 301
Anything You Can Do, I Can Do Better (in Scala) 302
Giving Scala a Lift 303
How Lift’s Comet Support Works 304
Summary 305
INDEX 306

Erscheint lt. Verlag 1.10.2009
Zusatzinfo XXII, 350 p.
Verlagsort Berkeley
Sprache englisch
Themenwelt Informatik Programmiersprachen / -werkzeuge Scala
Informatik Software Entwicklung Objektorientierung
Mathematik / Informatik Informatik Theorie / Studium
Schlagworte Concurrency • Functional Programming • Lift • Open Source • programming • Programming language • Scala
ISBN-10 1-4302-1990-4 / 1430219904
ISBN-13 978-1-4302-1990-3 / 9781430219903
Haben Sie eine Frage zum Produkt?
PDFPDF (Wasserzeichen)
Größe: 1,1 MB

DRM: Digitales Wasserzeichen
Dieses eBook enthält ein digitales Wasser­zeichen und ist damit für Sie persona­lisiert. Bei einer missbräuch­lichen Weiter­gabe des eBooks an Dritte ist eine Rück­ver­folgung an die Quelle möglich.

Dateiformat: PDF (Portable Document Format)
Mit einem festen Seiten­layout eignet sich die PDF besonders für Fach­bücher mit Spalten, Tabellen und Abbild­ungen. Eine PDF kann auf fast allen Geräten ange­zeigt werden, ist aber für kleine Displays (Smart­phone, eReader) nur einge­schränkt geeignet.

Systemvoraussetzungen:
PC/Mac: Mit einem PC oder Mac können Sie dieses eBook lesen. Sie benötigen dafür einen PDF-Viewer - z.B. den Adobe Reader oder Adobe Digital Editions.
eReader: Dieses eBook kann mit (fast) allen eBook-Readern gelesen werden. Mit dem amazon-Kindle ist es aber nicht kompatibel.
Smartphone/Tablet: Egal ob Apple oder Android, dieses eBook können Sie lesen. Sie benötigen dafür einen PDF-Viewer - z.B. die kostenlose Adobe Digital Editions-App.

Zusätzliches Feature: Online Lesen
Dieses eBook können Sie zusätzlich zum Download auch online im Webbrowser lesen.

Buying eBooks from abroad
For tax law reasons we can sell eBooks just within Germany and Switzerland. Regrettably we cannot fulfill eBook-orders from other countries.