Top Banner
BRANDON L. GULLA CS722 - FALL 2014 A quick introduction to:
19
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Scala for n00bs by a n00b.

BRANDON L. GULLA

CS722 - FALL 2014

A quick introduction to:

Page 2: Scala for n00bs by a n00b.

History of Scala

Founded in 2001 by Martin Odersky at the Ecole Polytechnique Fédérale de Lausanne in France (surprise).

Wanted to create a language to solve functional programming problems from the research/scientific fields while maintaining the awesomeness that comes with object-oriented programming languages such as Java.

Scala's codebase had roots in Martin's previous work named Funnel.

Martin was lazy* though...

*you'll get the pun later.

Page 3: Scala for n00bs by a n00b.
Page 4: Scala for n00bs by a n00b.

Java as a foundation.

Odersky decided to create his new language on top

of the Java Virtual Machine.

Scala is actually a library included in the Java

CLASSPATH.

Martin decided to make the Scala language translate into

Java byte code, a instruction set that could be read on

everything from toasters to high-end enterprise work

stations.

Confused?

Page 5: Scala for n00bs by a n00b.

Java Byte Code, Demystified

Page 6: Scala for n00bs by a n00b.

What's Scala look like? Hello World!

• Scala source code files are saved as ___.scala just like ___.java

• You compile scala with the scalac tool (included in the scala binary libraries)

Page 7: Scala for n00bs by a n00b.

But I like bells and whistles...

Scala was born to solve functional problems that mathematicians

and Data-Scientists were facing.

Just because the language is powerful for extremely nerdy problems, it doesn't mean that it can't be pretty too!

Since Scala shares the same VirtualMachine as Java, it can actually

use ANY Java package available, including GUI libraries such as

Swing!

Page 8: Scala for n00bs by a n00b.

JOptionPane in Scala

Page 9: Scala for n00bs by a n00b.

But Why Scala? Isn't Java awesome enough?

No!

Well, actually Java is pretty awesome, but you can extend that

awesomeness in Scala by using the same packages!

Example: import apache.commons.io._

Scala was created to meet the increasing scalability concerns of

distributed computing clusters.

Big Data Big Data Big Data.

Page 10: Scala for n00bs by a n00b.

How is Scala Different?...

Like languages such as SmallTalk and Objective-C, everything in Scala is

an object.

There are no primitives in Scala (int, double, etc) but have been replaced

by Int, Double, Float, etc. Even operators (+,-) are objects and thus can be

re-defined!

Lambda / Anonymous Functions:

Scala allows you to create anonymous or Lambda functions. Lambda functions

are functional definitions that are not bound to an identifier. They are often

passed to another function as an argument. An example is below.

You can actually pass a function as an argument parameter to another

function!

Page 11: Scala for n00bs by a n00b.

How is Scala Different?...

(continued)

Reduced boilerplate. Map Reduce job in Java takes ~130 lines, but it only takes 4 lines in Scala.

val s = for (x <- 1 to 25 if x*x > 50) yield 2*x

While everything is technically an object, Scala is a strictly-typedprogramming language. This is a huge improvement over previously used programming languages such as python and ruby.

Scala code can be decompiled to readable Java code, with the exception of certain constructor operations.

The return operator is unnecessary in a function (although allowed); the value of the last executed statement or expression is normally the function's value.

Polymorphism in Scala is identical to Java.

Page 12: Scala for n00bs by a n00b.

How is Scala Different?...

(continued some more )

Functions do not need parenthesis to be called. Function or method

foo() can also be called as just foo and method foo.toString() can

also be called as just foo toString.

Default visibility in Scala is ‘public’.

It's fast.

Page 13: Scala for n00bs by a n00b.

Scala can be run in an interactive

shell!

Page 14: Scala for n00bs by a n00b.

Examples

Page 15: Scala for n00bs by a n00b.

Examples Continued

Page 16: Scala for n00bs by a n00b.

Future of Scala in Industry

Page 17: Scala for n00bs by a n00b.

Scala is the Hipster of Programming

Languages

Page 18: Scala for n00bs by a n00b.

• Who Uses Scala?

Page 19: Scala for n00bs by a n00b.

Questions?

****( I'm no expert, so be nice)

Scala is open-sourced! Check it out on GitHub (github.com/scala)

Check out books such as Scala for the Java Developer and Scala

for the Impatient.