Beginning Scala

This document was uploaded by one of our users. The uploader already confirmed that they had the permission to publish it. If you are author/publisher or own the copyright of this documents, please report to us by using this DMCA report form.

Simply click on the Download Book button.

Yes, Book downloads on Ebookily are 100% Free.

Sometimes the book is free on Amazon As well, so go ahead and hit "Search on Amazon"

I had a difficult time learning much from this book. One problem is that the author doesn't explain things systematically. Typically, a new concept is introduced without being defined, and some code examples are then presented. This gave me only a rough idea of what that particular language feature does. Another problem is that there's no summary of the language - not even a grammar showing its syntax. So that when I encounter a feature (or a punctuation token that I haven't seen yet), it's hard to find an explanation. The book reads as if it's a stream-of-consciousness collection of topics the author finds interesting. I don't know how this came about, but I would like a book that explains a new idea by first presenting the ideas that the new one depends on. There are quite a few typographical errors and un-grammatical sentences in the book, which leads me to believe it wasn't carefully edited. There are also places in the book that use prose that conveys only an approximate idea of what's going on. For example, from page 235: "The | operator also takes two of these combinated function thingies and combines them into a single function thingy..." Overall, the book just seems to be not very carefully written. Having had no previous knowledge of Scala, I now have a rough idea of what Scala is, but if I ever need to learn the language, I'll have to find another source of information.

Author(s): David Pollak
Edition: 1
Publisher: Apress
Year: 2009

Language: English
Pages: 322
Tags: Библиотека;Компьютерная литература;Scala;

Prelims
......Page 1
Contents at a Glance......Page 7
Contents......Page 9
Foreword......Page 15
About the Author......Page 17
About the Technical Reviewer......Page 19
Acknowledgments......Page 21
Who This Book Is For......Page 23
Contacting the Author......Page 24
Scala: A Great Language for the Java Virtual Machine......Page 25
Beyond Java......Page 26
Finding Scala......Page 27
Scala’s History......Page 29
Installing on Windows......Page 30
The Scala Community......Page 32
Summary......Page 34
Interactive Scala......Page 35
Compiling Scala Programs......Page 37
Hello World......Page 38
Adding Things Up......Page 39
Parsing a String to an Int......Page 40
Summing Things Up......Page 42
Program Body......Page 43
Number, String, and XML Constants......Page 44
import......Page 45
Class, Trait, and Object Definition......Page 46
Scala’s Class Hierarchy......Page 51
Method Declaration......Page 52
Variable Declaration......Page 54
Call-by-Name......Page 55
Method Invocation......Page 57
Functions, apply, update, and Compiler Magic......Page 58
Case Classes......Page 60
Basic Pattern Matching......Page 62
if/else and while......Page 64
The for comprehension......Page 65
throw, try/catch/finally, and synchronized......Page 67
Classes and Instances......Page 69
Traits, Interfaces, and Mixins......Page 70
Functions, Anonymous Inner Classes, and Lambdas/Procs......Page 71
Summary......Page 72
Thinking Immutably......Page 73
Scala List, Tuple, Option, and Map Classes......Page 75
List[T]......Page 77
Getting Functional......Page 79
Contrast with Java......Page 80
Transformation......Page 82
Transformation vs. Mutation......Page 84
Reduxio......Page 85
Look Ma, No Loops......Page 88
Tuples......Page 90
Map[K, V]......Page 91
Option[T]......Page 96
Wrapping Up List, Tuple, Map, and Option......Page 98
XML in Your Scala Code......Page 99
Parsing XML......Page 105
Modifying XML......Page 108
Concurrency Without Synchronization......Page 111
Summary......Page 116
A Function Is an Instance......Page 117
Passing Functions As Parameters......Page 118
Partial Application and Functions......Page 121
Functions and Type Parameters......Page 123
Functions Bound to Variables in Scope......Page 124
Putting Functions in Containers......Page 127
Functions and Interactive Applications......Page 128
Building New Functions......Page 129
Call-by-Name, Call-by-Value, and General Laziness......Page 131
Build Your Own Control Structures......Page 133
JDBC Looping......Page 135
Summary......Page 137
Basic Pattern Matching......Page 139
Matching Any Type......Page 141
Testing Data Types......Page 143
Case Classes......Page 144
Pattern Matching in Lists......Page 147
Pattern Matching and Lists......Page 148
Nested Pattern Matching in Case Classes......Page 150
Examining the Internals of Pattern Matching......Page 152
Pattern Matching As Functions......Page 153
Object-Oriented and Functional Tensions......Page 155
Shape Abstractions......Page 156
Summary......Page 160
A Different Approach to Concurrency: Look Ma, No Locks......Page 161
Defining an Actor......Page 162
Defining an Actor......Page 163
Would You Like State With That?......Page 164
Instantiating an Actor......Page 165
Implementing a Listener......Page 166
As an Actor......Page 168
Actors: More Than Write-Only......Page 172
Protocol Handler......Page 173
Performing an Atomic Update......Page 177
Performing Transactions......Page 179
Testing the Transactional Actor......Page 185
Composing Actors......Page 188
Summary......Page 193
Traits and Types and Gnarly Stuff for Architects......Page 195
Show Me Some Bad Java Code......Page 196
Library Pimping, Implicit Conversions, and Vampires......Page 197
Library Pimping......Page 199
Inviting Vampires Into Your Code......Page 204
Traits: Interfaces on Steroids......Page 205
Traits and Class Hierarchies......Page 208
Types—It’s Beyond Generic......Page 214
Table Code......Page 215
The Table......Page 221
Concrete Columns......Page 222
Building a Query......Page 224
Making Queries Type-Safe......Page 225
Boilerplate......Page 227
Making a Concrete Class That Implements Table......Page 229
Type-Safe Fun......Page 230
Variance......Page 231
Invariant Parameter Types......Page 232
Covariant Parameter Types......Page 234
Contravariant Parameter Types......Page 235
Rules of Variance......Page 237
The Immutable World......Page 238
The Code......Page 239
Walking Through the Code......Page 244
Summary......Page 255
Higher-Order Functions and Combinators......Page 257
Higher-Order Functions......Page 258
Combinators......Page 259
The Calculator Parser......Page 261
JSON Parsing......Page 266
Twitter JSON Parsing......Page 276
Utilities......Page 277
Parsing the JSON......Page 279
Summary......Page 285
Testing: Behavior-Driven Development......Page 287
Specs......Page 288
Scala Test......Page 289
Maven......Page 290
Ant......Page 293
Other Build Tools......Page 295
Bringing New Team Members on Board......Page 296
Organizing Teams Around Scala......Page 297
Options Instead of Null Testing......Page 298
Focus on Immutability......Page 299
Keep Methods Short......Page 300
Refactor Mercilessly......Page 301
Compose Functions and Compose Classes......Page 302
The Super-Soft Sell......Page 303
The Big Sell......Page 304
Addressing the Potential Risks of Scala......Page 305
Selecting Team Members......Page 306
Yeah, But How Compatible?......Page 307
A Tad Bit of History......Page 308
Popping the Stack to the CEO or Board......Page 309
Why Is Scala Different?......Page 310
Anything You Can Do, I Can Do Better (in Scala)......Page 311
Giving Scala a Lift......Page 312
How Lift’s Comet Support Works......Page 313
Summary......Page 314
Index......Page 315