background preloader

Scala

Facebook Twitter

MAth stats ml

Effective Scala. Table of Contents Other languages 日本語Русский简体中文 Introduction Scala is one of the main application programming languages used at Twitter.

Effective Scala

Much of our infrastructure is written in Scala and we have several large libraries supporting our use. Scala provides many tools that enable succinct expression. Above all, program in Scala. This is not an introduction to Scala; we assume the reader is familiar with the language. This is a living document that will change to reflect our current “best practices,” but its core ideas are unlikely to change: Always favor readability; write generic code but not at the expensive of clarity; take advantage of simple language features that afford great power but avoid the esoteric ones (especially in the type system). And have fun. Formatting The specifics of code formatting — so long as they are practical — are of little consequence. This is of particular importance to Scala, as its grammar has a high degree of overlap.

Whitespace Indent by two spaces. Naming to Use. Java to Scala with the Help of Experts. Java to Scala with the Help of Experts Many leading experts in the industry have recognised the importance of Scala and are enthusiastic to help others appreciate the language.

Java to Scala with the Help of Experts

They have written excellent reviews and teaching materials that range from broad evaluations of the language to detailed cook-books on how to use the scala language. Each one comes from a different programming background and quite likely you will find one like your own. At times we all get stuck on learning a specific topic, just don't seem to get it. We need to take a look from a fresh point of view to gain the insight we need.

There are lots of other experts in the Scala community and Scala user groups that are there ready to help you too. There is a growing list of books on programming in Scala too. If you find other material helpful as you moved from Java to Scala or from other languages please let us know so we can share it with other first time Scala programmers. The Seductions of Scala Bill Venners Artima A. Learning Scala in small bites. Learning with the REPL One of the useful features for learning Scala is its REPL (read-eval-print-loop) support.

Learning Scala in small bites

If you want to try something out in Scala, just run: % scala and then try it out at the prompt. Examples Each well-commented script below demonstrates a different facet of Scala. [Values.scala] #! /* Scala has a rich set of value types, and a rich literal syntax to support them // Integers:val anInt = 3 // Floating point:val aDouble = 4.0 // Charaters:val aCharacter = 'c' // Strings:val aString = "Google" // Symbols:val aSymbol = 'foo // XML:val anXMLElement = <a href=" // Tuples:val aPair = (aString,aDouble) // Lists:val aList = List(1,2,3,4) // Ranges:val aRange = 1 to 5 // Maps:val aMap = Map(3 -> "foo", 4 -> "bar") // Sets:val aSet = Set(8,9,10) // Arrays:val anArray = Array(1,2,3,5) // Unit:val unit = () // Null:val nullValue = null // Functions:def incImplicit(x : Int ) = x + 1 val incAnonymous = ((x : Int) => x + 1) [Functions.scala] // Implicit function:def id(x : Int) : Int = x def x = realX.

Scalala/Scalala.