background preloader

Scala Programing Language:

Facebook Twitter

Trading

Scala.Either - Stefan's Posterous. The “Scala is too Complex” Conspiracy. They don’t want pragmatic Scala programmers. The “Scala is too complex for the average programmer” movement is disturbing. It conspires that Scala is too difficult for the average programmer to learn and that it is too academic. Scala is a hybrid programming language that is object oriented and functional. Java is a programming language that is object oriented and imperative. This means that Java programmers have no functional programming power. This year I read Programming in Scala and practiced some functional programming. It is true that moving from object oriented to functional programming requires a shift in mindset. Fortunately Java 7 is looking to add lambda support to the language so we will soon no longer have to write anonymous inner classes wherever single method interfaces and abstract classes (SAM types) are expected.

For any programmer who has not looked at Scala or who has been deterred by a “too complex” conspirator, here are some code samples.. Case classes Folding Lists. ScalaTest. ScalaTest. Scala Labs - Home. ?northeast scala symposium. The Scala Programming Language. Package Objects. Scala: Arrays, Lists, Sets and Maps « Blog about Java EE Development.

Despite all Scala code is translated to Java code, there are some differences between Scala Collections and Java Collections.

Scala: Arrays, Lists, Sets and Maps « Blog about Java EE Development

In this post we will try to explain four types of collections: Arrays, Lists, Sets and Maps. Arrays In Scala, in contrast to Java, there is an Array object and it can be created in the same way as Java does. However, the syntax differs. The first one is the classical way to create an object. var classicWay = new Array[String](3) classicWay(0) = “The” classicWay(1) = “classic” classicWay(2) = “way” There are two important differences to notice.

Var compactWay = Array(“I”,”like”,”this”,”way”) As it can be seen, there is no need to specify the type of the Array, the compiler will infer that the type is String. Print(compactWay(1)) compactWay(0) = “We” It will be transformed into: print(compactWay.apply(1)) compactWay.update(0,”We”) Lists Lists in Scala are always immutable (in Java they can be mutable), they are designed to enable a functional style programming. Sets Maps. Functional Scala: High, Higher, Higher Order Functions. Welcome to the sixth episode of Functional Scala!

Functional Scala: High, Higher, Higher Order Functions

This time, we’ll finally dive into one of the most powerful concepts i consistently referred to again and again within almost every previous part of this series: Higher Order Functions. Isn’t that cool? I know it’s not, since a cool name alone can’t set you on fire. I will demonstrate you some of its coolness and show you some essential aspects which induce not few voices to accuse Higher Order Functions as one of the basic principles for elegance, compactness and efficiency in Functional Programming. So what’s a Higher Order Function then? So here you have it. Just for the records: the critical part for detecting all proper values which will be selected for the resulting list, seems to be the predicate which is used by that guard. So far, nothing really exciting happened.

Ok, just for fun – let’s filter a list of integer values again, but now retain all odd values of the incoming list. . … and ‘Bob’s your uncle’ What’s left? Addendum.