scala : language of the future

66
SCALA : language of the future by Robin Syihab Mindtalk: @robin Twitter: @anvie Email: [email protected]

Upload: ansvialab

Post on 12-Apr-2017

79 views

Category:

Technology


3 download

TRANSCRIPT

Page 1: Scala : language of the future

SCALA : language of the future

by Robin SyihabMindtalk: @robin

Twitter: @anvieEmail: [email protected]

Page 2: Scala : language of the future

Scala is

a Modern Programming language.Created by Martin Odersky.Static TypingOOP + FPCompiled into bytecode and run on top of JVM.Java compatible binaries.a better Java.

Page 3: Scala : language of the future

“If I were to pick a language to use today other than Java, it would be Scala”

~ James Gosling (father of Java).

Page 4: Scala : language of the future

Scala is

JVM Language

Page 5: Scala : language of the future

Java & Scala timeline

Page 6: Scala : language of the future

JVM Languages available today

ScalaGroovyFantomClojureJRubyJythonKotlin

Page 7: Scala : language of the future

Java & JVML timeline

Page 8: Scala : language of the future

“The legacy of Java will be the platform, not the language.”~ Martin Fowler (OOP programming expert)

Page 9: Scala : language of the future

Scala is

Scalable Language

Page 10: Scala : language of the future

“No other language on the JVM seems as capable of being a

"replacement for Java" as Scala.”~ Charlies Nutter (JRuby lead)

Page 11: Scala : language of the future

Scala in production

Page 12: Scala : language of the future

Scala Job Trends

Page 13: Scala : language of the future

Java vs Scala (syntax)

Page 14: Scala : language of the future

Java

Scala

Page 15: Scala : language of the future

Scala

Java

Singleton

Page 16: Scala : language of the future

Scala

Java

Singleton Use

Page 17: Scala : language of the future

Scala

Java

Regex

Page 18: Scala : language of the future

Scala is powerful for functional

programming

Page 19: Scala : language of the future

Scala

Java

Partitioning

Page 20: Scala : language of the future

Scala

Java

Calculating average

Page 21: Scala : language of the future

Scala is more than“syntactic sugar language”

Page 22: Scala : language of the future

Scala is OOP

http://www.ibs.ro

Page 23: Scala : language of the future

Scala OOP

Object inheritanceObject and method accessibility (public, protected, private).Static method.Mutable & Immutable variable.

Page 24: Scala : language of the future

Scala OOP

Page 25: Scala : language of the future
Page 26: Scala : language of the future

Everything return value

Page 27: Scala : language of the future

Traits

Like interfaces in java, butcan have implementationscan have fieldscan mix-in

Page 28: Scala : language of the future
Page 29: Scala : language of the future

Scala is Functional

Page 30: Scala : language of the future

XML LiteralsScala support XML literals inside of code

Page 31: Scala : language of the future

XML literals

Page 32: Scala : language of the future

Lazy variable evaluation

Page 33: Scala : language of the future

Lazy Variable Evaluation

// Use case

Page 34: Scala : language of the future

Pattern Matching

animal match { case cat:Cat => cat.meow()

case tiger:Tiger => tiger.hoa()

}

Page 35: Scala : language of the future

Pattern Matching

Page 36: Scala : language of the future

Pattern Matching: data extraction

Page 37: Scala : language of the future

Pattern Matching: data extraction + guardian

Page 38: Scala : language of the future

Implicit definition

http://www.iwallscreen.com

Page 40: Scala : language of the future

Implicit definition: View bounds

Page 41: Scala : language of the future

robin say “hello”

robin.say(“hello”)

Lenient Invocation Syntax

object method parameter

Page 42: Scala : language of the future

Lenient Invocation Syntax

Page 43: Scala : language of the future

h(x) = y f(x, y)⟼

Currying Function

Page 44: Scala : language of the future

We need this simple code run robustly:+ no crash when exception happen.+ handle unicode UTF-8 correctly.+ no memory leak.

Currying Function

Page 45: Scala : language of the future

Currying Function

Page 46: Scala : language of the future

Partial Function

http://bertzzie.com

Page 47: Scala : language of the future

Partial Function

PipeliningPattern Matching

Page 48: Scala : language of the future

Partial Function: Pipelining

Execution

Page 49: Scala : language of the future

Partial Function: Pipelining

Page 50: Scala : language of the future

Partial Function: Pattern Matching

Parameter

Page 51: Scala : language of the future

Partial Function: Pattern Matching

Page 52: Scala : language of the future

ActorConcurrent Programming

Page 53: Scala : language of the future

When to use Actor?

If we want to build distributed system.Handle massive concurrent request.Needs for build event-driven asynchronous application.High performance lightweight than Thread.

Page 54: Scala : language of the future

Scala Actor Local

Page 55: Scala : language of the future

Akka Actor: Distributed

100.10.10.1

Actor A

100.10.10.2

Actor B

100.10.10.3

Actor C

100.10.10.4

Actor D

event stream

http://akka.io/

Page 56: Scala : language of the future

Akka Actor

Support local & remote actorSelf-healing using supervisorDecentralized

Adaptive load balancing Configuration-driven

ExtensibleSmall memory footprint ~2.5 million actors per GB of HeapEvent stream easy to handle cluster state

Page 57: Scala : language of the future

Akka Actor in production

Page 58: Scala : language of the future

TDD in Scalahttp://lostechies.com

Page 59: Scala : language of the future

Scala testing framework

ScalatestJUnitSpec2Gatling (performance test)

Page 60: Scala : language of the future

Specs2 Unit test

Page 61: Scala : language of the future

Specs2 Acceptance test

Page 62: Scala : language of the future

Specs2

Page 63: Scala : language of the future

Ok thats sound interesting,but wait...

how with the development tools?

http://www.thetinylife.com

Page 64: Scala : language of the future

Development tools

IDE

Scala-IDE (eclipse based)

NetBeans

IntellijIdea

Emacs (ENSIME)

Build System

Maven

SBT (Simple Build Tools)

Project generator

Giter8

JRebel (incremental development)

Page 65: Scala : language of the future

giter8

Build Scala “hello world”application in minute

Page 66: Scala : language of the future

Thank you