• Complain

Alexander - Scala Cookbook

Here you can read online Alexander - Scala Cookbook full text of the book (entire story) in english for free. Download pdf and epub, get meaning, cover and reviews about this ebook. City: Beijing, year: 2013, publisher: OReilly Media, genre: Computer. Description of the work, (preface) as well as reviews are available. Best literature library LitArk.com created for fans of good reading and offers a wide selection of genres:

Romance novel Science fiction Adventure Detective Science History Home and family Prose Art Politics Computer Non-fiction Religion Business Children Humor

Choose a favorite category and find really read worthwhile books. Enjoy immersion in the world of imagination, feel the emotions of the characters or learn something new for yourself, make an fascinating discovery.

Alexander Scala Cookbook
  • Book:
    Scala Cookbook
  • Author:
  • Publisher:
    OReilly Media
  • Genre:
  • Year:
    2013
  • City:
    Beijing
  • Rating:
    3 / 5
  • Favourites:
    Add to favourites
  • Your mark:
    • 60
    • 1
    • 2
    • 3
    • 4
    • 5

Scala Cookbook: summary, description and annotation

We offer to read an annotation, description, summary or preface (depends on what the author of the book "Scala Cookbook" wrote himself). If you haven't found the necessary information about the book — write in the comments, we will try to find it.

Save time and trouble when using Scala to build object-oriented, functional, and concurrent applications. With more than 250 ready-to-use recipes and 700 code examples, this comprehensive cookbook covers the most common problems youll encounter when using the Scala language, libraries, and tools. Its ideal not only for experienced Scala developers, but also for programmers learning to use this JVM language. Author Alvin Alexander (creator of DevDaily.com) provides solutions based on his experience using Scala for highly scalable, component-based applications that support concurrency and distribution. Packed with real-world scenarios, this book provides recipes for: Strings, numeric types, and control structures Classes, methods, objects, traits, and packaging Functional programming in a variety of situations Collections covering Scalas wealth of classes and methods Concurrency, using the Akka Actors library Using the Scala REPL and the Simple Build Tool (SBT) Web services on both the client and server sides Interacting with SQL and NoSQL databases Best practices in Scala development.

Alexander: author's other books


Who wrote Scala Cookbook? Find out the surname, the name of the author of the book and a list of all author's works by series.

Scala Cookbook — read online for free the complete book (whole text) full work

Below is the text of the book, divided by pages. System saving the place of the last page read, allows you to conveniently read the book "Scala Cookbook" online for free, without having to search again every time where you left off. Put a bookmark, and you can go to the page where you finished reading at any time.

Light

Font size:

Reset

Interval:

Bookmark:

Make
Scala Cookbook
Alvin Alexander
Beijing Cambridge Farnham Kln Sebastopol Tokyo For my mom who loves - photo 1

Beijing Cambridge Farnham Kln Sebastopol Tokyo

For my mom, who loves cookbooks.

Special Upgrade Offer

If you purchased this ebook directly from oreilly.com, you have the following benefits:

  • DRM-free ebooksuse your ebooks across devices without restrictions or limitations

  • Multiple formatsuse on your laptop, tablet, or phone

  • Lifetime access, with free updates

  • Dropbox syncingyour files, anywhere

If you purchased this ebook from another retailer, you can upgrade your ebook to take advantage of all these benefits for just $4.99. to access your ebook upgrade.

Please note that upgrade offers are not available from sample content.

A Note Regarding Supplemental Files

Supplemental files and examples for this book can be found at http://examples.oreilly.com/9781449339616-files/. Please use a standard desktop web browser to access these files, as they may not be accessible from all ereader devices.

All code files or examples referenced in the book will be available online. For physical books that ship with an accompanying disc, whenever possible, weve posted all CD/DVD content. Note that while we provide as much of the media content as we are able via free download, we are sometimes limited by licensing restrictions. Please direct any questions or concerns to .

Preface

This is a cookbook of problem-solving recipes about Scala, the most interesting programming language Ive ever used. The book contains solutions to more than 250 common problems, shown with possibly more than 700 examples. (I havent counted, but I suspect thats true.)

There are a few unique things about this book:

  • As a cookbook, its intended to save you time by providing solutions to the most common problems youll encounter.

  • Almost all of the examples are shown in the Scala interpreter. As a result, whether youre sitting by a computer, on a plane, or reading in your favorite recliner, you get the benefit of seeing their exact output. (Which often leads to, Ah, so thats how that works.)

  • The book covers not only the Scala language, but also has large chapters on Scala tools and libraries, including SBT, actors, the collections library (more than 100 pages), and JSON processing.

Just prior to its release, the book was updated to cover Scala 2.10.x and SBT 0.12.3.

1. The Scala Language

My (oversimplified) Scala elevator pitch is that its a child of Ruby and Java: its light, concise, and readable like Ruby, but it compiles to class files that you package as JAR files that run on the JVM; it uses traits and mixins, and feels dynamic, but its statically typed. It uses the Actor model to simplify concurrent programming so you can keep those multicore processors humming. The name Scala comes from the word scalable , and true to that name, its used to power the busiest websites in the world, including Twitter, Netflix, Tumblr, LinkedIn, Foursquare, and many more.

In my opinion, Scala is not a good language for teaching a Programming 101 class. Instead, its a power language created for the professional programmer. Dont let that scare you, though. If you were my own brother and about to start a new project and could choose any programming language available, without hesitation Id say, Use Scala.

Here are a few more nuggets about Scala:

  • Its a modern programming language created by Martin Odersky (the father of javac), influenced by Java, Ruby, Smalltalk, ML, Haskell, Erlang, and others.

  • Its a pure object-oriented programming (OOP) language. Every variable is an object, and every operator is a method.

  • Its also a functional programming (FP) language, so you can pass functions around as variables. You can write your code using OOP, FP, or both.

  • Scala code runs on the JVM and lets you use the wealth of Java libraries that have been developed over the years.

  • You can be productive on Day 1, but the language is deep, so as you go along youll keep learning and finding newer, better ways to write code. Scala will change the way you think about programmingand thats a good thing.

Of all of Scalas benefits, what I like best is that it lets you write concise, readable code. The time a programmer spends reading code compared to the time spent writing code is said to be at least a 10:1 ratio, so writing code thats concise and readable is a big deal. Because Scala has these attributes, programmers say that its expressive .

Solutions

Ive always bought OReilly cookbooks for the solutions, and thats what this book is about: solving problems.

When using a cookbook, I usually think, I have this problem, I need to iterate over the elements in an Array, whats the best way to do that? I like to look at the table of contents, find a recipe, implement the solution, and move on. I tried to write each recipe with this use case in mind.

However, with a modern language like Scala, it may end up that I phrased my question wrong. Because of my prior programming experience I may have thought, I need to iterate over the elements in an Array, but in reality my deeper intent was to loop over those elements for a reason, such as to transform them into a new collection. So its nice when a recipe says, Hey, I know youre here to read about how to loop over the elements in an Array, heres how you do that:

for(i<-Array(1,2,3))println(i)

But, if what youre really trying to do is transform those elements into a new collection, what you want is a for/yield expression or map method:

// for/yieldscala> for (i <- Array(1,2,3)) yield i * 2res0: Array[Int] = Array(2, 4, 6)// mapscala> Array(1,2,3).map(_ * 2)res1: Array[Int] = Array(2, 4, 6)

(More on that _ character shortly.)

To create the list of problems and solutions, I followed the Eat your own dog food philosophy. The recipes come from my own experience of creating Scala scripts, web applications, web services, Swing applications, and actor-based systems. As I developed the applications I needed, I encountered problems like these:

  • Scala files tend to be very small; whats the proper way to organize an application?

  • It looks like SBT is the best build tool for Scala, but its different than Ant or Maven; how do I compile and package applications, and work with dependencies?

  • Constructors are really different than Java; how do I create them? What code is generated when I declare constructor parameters and class fields?

  • Actors are cool; how do I write a complete actor-based application?

  • What, I shouldnt use null values anymore? Why not? How do I code without them?

  • I can pass a function around like any other variable? How do I do that, and whats the benefit?

  • Why are there so many collections classes, and why does each collection class have so many methods?

  • I have all of this legacy Java code; can I still use it in Scala? If so, how?

Next page
Light

Font size:

Reset

Interval:

Bookmark:

Make

Similar books «Scala Cookbook»

Look at similar books to Scala Cookbook. We have selected literature similar in name and meaning in the hope of providing readers with more options to find new, interesting, not yet read works.


Reviews about «Scala Cookbook»

Discussion, reviews of the book Scala Cookbook and just readers' own opinions. Leave your comments, write what you think about the work, its meaning or the main characters. Specify what exactly you liked and what you didn't like, and why you think so.