2010 ProgramminginScala
- (Odersky et al., 2010) ⇒ Martin Odersky, Lex Spoon, and Bill Venners. (2010). “Programming in Scala, 2nd edition.” Artima. ISBN:0981531644
Subject Headings: Scala Language; Programming Language Introductory Book.
Notes
Cited By
Quotes
Book Overview
Scala is an object-oriented programming language for the Java Virtual Machine. In addition to being object-oriented, Scala is also a functional language, and combines the best approaches to OO and functional programming. In Italian, Scala means a stairway, or steps -- indeed, Scala lets you step up to a programming environment that incorporates some of the best recent thinking in programming language design while also letting you use all your existing Java code. Artima is very pleased to publish a new edition of the best-selling book on Scala, written by the designer of the language, Martin Odersky. Co-authored by Lex Spoon and Bill Venners, this book takes a step-by-step tutorial approach to teaching you Scala. Starting with the fundamental elements of the language, Programming in Scala introduces functional programming from the practitioner's perspective, and describes advanced language features that can make you a better, more productive developer.
Chapter 1. A Scalable Language p.50
The name Scala stands for "scalable language.” The language is so named because it was designed to grow with the demands of its users. You can apply Scala to a wide range of programming tasks, from writing small scripts to building large systems.[1] Scala is easy to get into. It runs on the standard Java platform and interoperates seamlessly with all Java libraries. It's quite a good language for writing scripts that pull together Java components. But it can apply its strengths even more when used for building large systems and frameworks of reusable components. Technically, Scala is a blend of object-oriented and functional programming concepts in a statically typed language. The fusion of object-oriented and functional programming shows up in many different aspects of Scala; it is probably more pervasive than in any other widely used language. The two programming styles have complementary strengths when it comes to scalability. Scala's functional programming constructs make it easy to build interesting things quickly from simple parts. Its object-oriented constructs make it easy to structure larger systems and to adapt them to new demands. The combination of both styles in Scala makes it possible to express new kinds of programming patterns and component abstractions. It also leads to a legible and concise programming style. And because it is so malleable, programming in Scala can be a lot of fun. This initial chapter answers the question, "Why Scala?" It gives a high-level view of Scala's design and the reasoning behind it. After reading the chapter you should have a basic feel for what Scala is and what kinds of tasks it might help you accomplish. Although this book is a Scala tutorial, this chapter isn't really part of the tutorial. If you're eager to start writing some Scala code, you should jump ahead to Chapter 2.
1.1 A language that grows on you
Programs of different sizes tend to require different programming constructs. Consider, for example, the following small Scala program:
var capital = Map("US" -> "Washington", "France" -> "Paris") capital += ("Japan" -> "Tokyo") println(capital("France"))
This program sets up a map from countries to their capitals, modifies the map by adding a new binding ("Japan" -> "Tokyo"), and prints the capital associated with the country France.[2] The notation in this example is high-level, to the point, and not cluttered with extraneous semicolons or type annotations. Indeed, the feel is that of a modern "scripting" language like Perl, Python, or Ruby. One common characteristic of these languages, which is relevant for the example above, is that they each support an "associative map" construct in the syntax of the language.
Associative maps are very useful because they help keep programs legible and concise. However, sometimes you might not agree with their "one size fits all" philosophy, because you need to control the properties of the maps you use in your program in a more fine-grained way. Scala gives you this fine-grained control if you need it, because maps in Scala are not language syntax. They are library abstractions that you can extend and adapt.
In the above program, you'll get a default Map implementation, but you can easily change that. You could for example specify a particular implementation, such as a HashMap or a TreeMap, or you could specify that the map should be thread-safe, by mixing in a SynchronizedMap
trait. You could specify a default value for the map, or you could override any other method of the map you create. In each case, you can use the same easy access syntax for maps as in the example above. This example shows that Scala can give you both convenience and flexibility. Scala has a set of convenient constructs that help
Chapter 2. First Steps in Scala p.69
Chapter 3. Next Steps in Scala p.82
Chapter 4. Classes and Objects p.104
Chapter 5. Basic Types and Operations p.118
Chapter 6. Functional Objects p.140
Chapter 7. Built-in Control Structures p.160
Chapter 8. Functions and Closures p.185
Chapter 9. Control Abstraction p.208
Chapter 10. Composition and Inheritance p.223
Chapter 11. Scala's Hierarchy p.251
Chapter 12. Traits p.259
Chapter 13. Packages and Imports p.278
Chapter 14. Assertions and Unit Testing p.296
Chapter 15. Case Classes and Pattern Matching p.310
Chapter 16. Working with Lists p.345
Chapter 17. Collections p.378
Chapter 18. Stateful Objects p.400
Chapter 19. Type Parameterization p.423
Chapter 20. Abstract Members p.448
Chapter 21. Implicit Conversions and Parameters p.480
Chapter 22. Implementing Lists p.504
Chapter 23. For Expressions Revisited p.517
Chapter 24. The Scala Collections API p.534
Chapter 25. The Architecture of Scala Collections p.610
Chapter 26. Extractors p.634
Chapter 27. Annotations p.650
Chapter 28. Working with XML p.658
Chapter 29. Modular Programming Using Objects p.672
Chapter 30. Object Equality p.687
Chapter 31. Combining Scala and Java p.713
Chapter 32. Actors and Concurrency p.726
Chapter 33. Combinator Parsing p.762
Chapter 34. GUI Programming p.791
Chapter 35. The SCells Spreadsheet p.803
Appendix A. Scala scripts on Unix and Windows p.828
Glossary p.829
References
;
Author | volume | Date Value | title | type | journal | titleUrl | doi | note | year | |
---|---|---|---|---|---|---|---|---|---|---|
2010 ProgramminginScala | Martin Odersky Lex Spoon Bill Venners | Programming in Scala | 0981531644 | 2010 |