SlideShare une entreprise Scribd logo
1  sur  86
Télécharger pour lire hors ligne
println("Hello World!")
Do you know
Object-oriented
 Programming?
Do you know
 Functional
Programming?
Do you know
   Scala?
’’’
[Start]
   Scala!
’’’

      @mumoshu
# of atnders
   php
  java
 scala
     js
python
   perl
          0   5        10    15
Categorize
PHP, Java, Scala
Web dev         General Purpose



                  Scala


          PHP     Java
PHP, Java, Scala
Web dev         General Purpose


Dynamically     Statically typed
typed             Scala


          PHP     Java
PHP, Java, Scala
Web dev          General Purpose
       Shorter code
Dynamically      Statically typed
typed              Scala

       Longer code
         PHP       Java
Scala


•   has NOTHING NEW!
PHP and Scala


•   PHP + Static Typing + Shorter code
    = Scala ?!
Java and Scala


•   Java + Shorter code
    = Scala ?!
Really short?
Basic computation
•   Calculate the sum in imperative style
Basic computation
•   Calculate the sum in imperative style

    1 + 2 + 3 = 6
Basic computation
•   Calculate the sum in imperative style

    1 + 2 + 3 = 6

    sum   =   0
    sum   =   sum + 1
    sum   =   sum + 2
    sum   =   sum + 3
MY Ranking

1. (Ruby)
2. Scala
3. (JavaScript)
4. PHP
5. Java
Sum with Java

int[] array = new int[] { 1, 2, 3 };
int sum = 0;
for (int i=0; i<array.length; i++) {
  sum += array[i];
}
System.out.println(sum);
Sum with Java

int[] array = new int[] { 1, 2, 3 };
int sum = 0;
for (int i=0; i<array.length; i++) {
  sum += array[i];
}
System.out.println(sum);
int[] int[] int int
Sum with PHP

$array = array(1, 2, 3);
$sum = 0;
for ($i=1; $i<=count($array); $i++) {
    $sum += $array[$i];
}
print $sum;
Sum with PHP

$array = array(1, 2, 3);
$sum = 0;
for ($i=1; $i<=count($array); $i++) {
    $sum += $array[$i];
}
print($sum);
$$$$$$$$
Sum with JS

var array = [1,2,3]
var sum = 0
for (var i in array) {
  sum += array[i]
}
console.log(sum);
Sum with JS

var array = [1,2,3]
var sum = 0
for (var i in array) {
  sum += array[i]
}
console.log(sum);
(‘A`) vaaaaaaaar
Sum with Ruby
array = [1, 2, 3]
sum = 0
for (x in array)
  sum += x
end
puts sum
(^o^) Elegant!
Scala + for

var array = Array(1, 2, 3)
var sum = 0
for (x <- array) {
  sum += x
}
println(sum)
(‘-’) Is that your
      power?
Scala + for

var array = Array(1, 2, 3)
var sum = 0
for (x <- array) {
  sum += x
}
println(sum)
Scala + for

var array = Array(1, 2, 3)
var sum = 0
for (x <- array) {
  sum += x
}
println(sum)
Scala + foreach
var array = Array(1, 2, 3)
var sum = 0
array foreach { x =>
  sum += x
}
println(sum)
Scala + foreach
var array = Array(1, 2, 3)
var sum = 0
array foreach { x =>
  sum += x
}
println(sum)
Scala + foreach
var array = Array(1, 2, 3)
var sum = 0
array foreach {
  sum += _
}
println(sum)
Sum with `reduce`
•   Calculate the sum in functional styl
Sum with `reduce`
•   Calculate the sum in functional style

    sum = 1 + 2 + 3
    sum = 3 + 3
    sum = 6
Sum with `reduce`
•   Calculate the sum in functional style

    sum = 1 + 2 + 3
Sum with `reduce`
•   Calculate the sum in functional style
    1. (Ruby)
    2. Scala
    3. (JavaScript)
    4. PHP
    5. Java
Java


No reduce
PHP

$array = array(1, 2, 3);
function reduce($a, $b){
   return $a + $b;
};
$sum = array_reduce($array, 'reduce');
print $sum;
JavaScript

var array = [1, 2, 3];
var sum = array.reduce(function(a,b){
    return a + b
});
console.log(sum);
`for` is shorter...
Ruby

array = [1, 2, 3]
sum = array.reduce(&:+)
puts sum
Scala

val array = Array(1, 2, 3)
val sum = array.reduce(_+_)
println(sum)
(^-^)
One more thing...
More Scala

val array = Array(1, 2, 3)
val sum = array.sum
println(sum)
You learn everyday


•   And you code gets BETTER
Are you


•   a Java engineer?
•   or maybe a PHP engineer?
•   Do you use `Class’?
Class
•   Define a class in
    1. Scala
    2. (Ruby)
    3. PHP
    4. Java
    5. (JavaScript)
Greeter
          Hello Scala

Greeter
Classes in Java
public class Greeter {
  private String name;

    public Greeter(String name) {
      this.name = name;
    }

    public Greeter() {
      Greeter(“Scala”);
    }

    public String getName() {
      return this.name;
    }

    public void greet() {
      System.out.println(“Hello “ + this.name);
    }
}

Greeter greeter = new Greeter("Scala!");
greeter.greet();
Classes in PHP
<?php
class Greeter {
   private $name;

    function __construct($name = 'Scala') {
      $this->name = $name;
    }

    public function getName() {
      return $this->name;
    }

    public function greet() {
      print ‘Hello ‘ . $this->name;
    }
}

$greeter = new Greeter(‘Scala!’);
$greeter->greet();
?>
Classes in JS
function Greeter(name) {
  this.name = typeof name == “undefined” ? “Scala” : name;
}

Greeter.prototype = {
   getName: function() {
      return this.name;
   },
   greet: function() {
      console.log(“Hello “ + this.name);
   }
};

var greeter = new Greeter(“Scala”);
greeter.greet();
Classes in Ruby
class Greeter
   attr_reader :name
   def initialize(name="Scala")
     @name = name
   end
   def greet
     puts “Hello “ + @name
   end
end

greeter = Greeter.new(“Scala”)
greeter.greet
Classes in Scala
class Greeter(val name: String = “Scala”) {
   def greet() {
     println(“Hello “ + name)
   }
}

val greeter = new Greeter("Scala!");
greeter.greet()
Really short?
YES!!!
Really short?
break
          1/2



     
        ビースト★ハーレム
                ∼野獣の甘噛み∼

http://pf.gree.jp/56616
Overview
Scala is

• General purpose
  • Not only Web
• Multi-paradigm
  • Object-oriented + Functional
    programming
Scala

              ’’’
•   Run on JVM
•   A lot of Java libraries
•   Hybrid language
    •   Imperative programming
    •   Object oriented programming
    •   Functional programming
Whats happy with FP


•   Concurrency
•   Scalability
Imperative vs
          Functional
•   Imperative Programming

    do A -> state++,
    do B -> state++, ...

•   Functional programming

    in1 -> f(x) -> out1
    in2 -> g(x) -> out2
+ concurrency
Easy concurrency
•   Imperative programming

    do A -> state <- do B
     > sudden conflict!!! <

•   Functional programming

    in1 -> f(x) -> out1, in2 -> g(x) -> out2
      > no conflict!!! <
Dynamic vs Static
         typing


•   About type-safety
Dynamic typing

•   GOOD
    •   Run anyway
•   BAD
    •   More runtime errors
NullPointerException
ReferenceError
TypeError
Call to undefined
     function
Static typing

•   GOOD
    •   More compile errors
•   BAD
    •   Hard to read error messages
Scala 2.10


•   We have Scala 2.9.3
•   Scala 2.10 is coming (on 12/26?)
Recommendation

•   If you want to:
    •   write something other than Web app
    •   write noise-free, consise code
    •   develop your skill GRADUALLY
[Start]
   Scala!
’’’

      @mumoshu
Thank you!
Our bible
Scala for business

•   Scalaはお仕事に向いてます

    •   Java同様、静的型付けは複数人での
        開発に有効

    •   Scalaはエンジニアの成長を止めない
Scala for education
•   ステップアップ学習に最適

    •   sumの例のように、Scalaに慣れてくる
        と徐々に簡潔な書き方が出来るよう
        になっていく

    •   手続き的に書ける。慣れたらいつで
        も関数型チックに書ける。
Scala’s flexibility
•   Scalaは自由度が高い

    •   同じ意味のことを幾通りにも書けて
        メンテナンス性が悪い、のではない

    •   各人のレベルにあった記述ができる

    •   プログラマの創造性を阻害しない
Learning Scala

•   Javaと同じ書き方でいいなら、Javaと同じ学
    習コスト

    •   ちょっと短いだけのJavaとして書けるので

•   Web開発ならPHPの方が最初の敷居が低い
REPL
•   Scalaの対話環境

•   ScalaのREPLを起動すると”Welcome to
    Scala”って言われる

•   「ようこそScalaへ。ご命令を。」って
    言ってくれるScalaかわいい
Compilation time

•   Scalaのコンパイルは長い

•   Time is money
•   PCをスペックアップしましょう

Contenu connexe

Tendances

A Tour Of Scala
A Tour Of ScalaA Tour Of Scala
A Tour Of Scalafanf42
 
Solid And Sustainable Development in Scala
Solid And Sustainable Development in ScalaSolid And Sustainable Development in Scala
Solid And Sustainable Development in ScalaKazuhiro Sera
 
Static or Dynamic Typing? Why not both?
Static or Dynamic Typing? Why not both?Static or Dynamic Typing? Why not both?
Static or Dynamic Typing? Why not both?Mario Camou Riveroll
 
An Introduction to Scala
An Introduction to ScalaAn Introduction to Scala
An Introduction to ScalaBrent Lemons
 
A Brief Intro to Scala
A Brief Intro to ScalaA Brief Intro to Scala
A Brief Intro to ScalaTim Underwood
 
Scala Talk at FOSDEM 2009
Scala Talk at FOSDEM 2009Scala Talk at FOSDEM 2009
Scala Talk at FOSDEM 2009Martin Odersky
 
Refactoring to Scala DSLs and LiftOff 2009 Recap
Refactoring to Scala DSLs and LiftOff 2009 RecapRefactoring to Scala DSLs and LiftOff 2009 Recap
Refactoring to Scala DSLs and LiftOff 2009 RecapDave Orme
 
A Brief, but Dense, Intro to Scala
A Brief, but Dense, Intro to ScalaA Brief, but Dense, Intro to Scala
A Brief, but Dense, Intro to ScalaDerek Chen-Becker
 
Starting with Scala : Frontier Developer's Meetup December 2010
Starting with Scala : Frontier Developer's Meetup December 2010Starting with Scala : Frontier Developer's Meetup December 2010
Starting with Scala : Frontier Developer's Meetup December 2010Derek Chen-Becker
 
Introduction to Scala
Introduction to ScalaIntroduction to Scala
Introduction to ScalaSaleem Ansari
 
Introduction to Scala
Introduction to ScalaIntroduction to Scala
Introduction to ScalaRahul Jain
 
Introduction to Scala : Clueda
Introduction to Scala : CluedaIntroduction to Scala : Clueda
Introduction to Scala : CluedaAndreas Neumann
 

Tendances (20)

A Tour Of Scala
A Tour Of ScalaA Tour Of Scala
A Tour Of Scala
 
Solid And Sustainable Development in Scala
Solid And Sustainable Development in ScalaSolid And Sustainable Development in Scala
Solid And Sustainable Development in Scala
 
Static or Dynamic Typing? Why not both?
Static or Dynamic Typing? Why not both?Static or Dynamic Typing? Why not both?
Static or Dynamic Typing? Why not both?
 
An Introduction to Scala
An Introduction to ScalaAn Introduction to Scala
An Introduction to Scala
 
A Brief Intro to Scala
A Brief Intro to ScalaA Brief Intro to Scala
A Brief Intro to Scala
 
Scala Talk at FOSDEM 2009
Scala Talk at FOSDEM 2009Scala Talk at FOSDEM 2009
Scala Talk at FOSDEM 2009
 
Refactoring to Scala DSLs and LiftOff 2009 Recap
Refactoring to Scala DSLs and LiftOff 2009 RecapRefactoring to Scala DSLs and LiftOff 2009 Recap
Refactoring to Scala DSLs and LiftOff 2009 Recap
 
Scala basic
Scala basicScala basic
Scala basic
 
Scala Intro
Scala IntroScala Intro
Scala Intro
 
Scala coated JVM
Scala coated JVMScala coated JVM
Scala coated JVM
 
Scale up your thinking
Scale up your thinkingScale up your thinking
Scale up your thinking
 
A Brief, but Dense, Intro to Scala
A Brief, but Dense, Intro to ScalaA Brief, but Dense, Intro to Scala
A Brief, but Dense, Intro to Scala
 
scala
scalascala
scala
 
Starting with Scala : Frontier Developer's Meetup December 2010
Starting with Scala : Frontier Developer's Meetup December 2010Starting with Scala : Frontier Developer's Meetup December 2010
Starting with Scala : Frontier Developer's Meetup December 2010
 
Scala in Practice
Scala in PracticeScala in Practice
Scala in Practice
 
Introduction to Scala
Introduction to ScalaIntroduction to Scala
Introduction to Scala
 
Introduction to Scala
Introduction to ScalaIntroduction to Scala
Introduction to Scala
 
Scala on Android
Scala on AndroidScala on Android
Scala on Android
 
Introduction to Scala : Clueda
Introduction to Scala : CluedaIntroduction to Scala : Clueda
Introduction to Scala : Clueda
 
camel-scala.pdf
camel-scala.pdfcamel-scala.pdf
camel-scala.pdf
 

En vedette

Towards Aggregate Programming in Scala
Towards Aggregate Programming in ScalaTowards Aggregate Programming in Scala
Towards Aggregate Programming in ScalaRoberto Casadei
 
CabMe|intercity travels
CabMe|intercity travelsCabMe|intercity travels
CabMe|intercity travelsSHUBHAM GUPTA
 
CabMe(intercity travels)
CabMe(intercity travels)CabMe(intercity travels)
CabMe(intercity travels)SHUBHAM GUPTA
 
How To Use Higher Order Functions in Scala
How To Use Higher Order Functions in ScalaHow To Use Higher Order Functions in Scala
How To Use Higher Order Functions in ScalaBoldRadius Solutions
 
Functional Programming for OO Programmers (part 2)
Functional Programming for OO Programmers (part 2)Functional Programming for OO Programmers (part 2)
Functional Programming for OO Programmers (part 2)Calvin Cheng
 
Introduction to parallel and distributed computation with spark
Introduction to parallel and distributed computation with sparkIntroduction to parallel and distributed computation with spark
Introduction to parallel and distributed computation with sparkAngelo Leto
 
Scala meetup - Intro to spark
Scala meetup - Intro to sparkScala meetup - Intro to spark
Scala meetup - Intro to sparkJavier Arrieta
 
Apache Spark RDDs
Apache Spark RDDsApache Spark RDDs
Apache Spark RDDsDean Chen
 

En vedette (10)

Towards Aggregate Programming in Scala
Towards Aggregate Programming in ScalaTowards Aggregate Programming in Scala
Towards Aggregate Programming in Scala
 
CabMe|intercity travels
CabMe|intercity travelsCabMe|intercity travels
CabMe|intercity travels
 
CabMe(intercity travels)
CabMe(intercity travels)CabMe(intercity travels)
CabMe(intercity travels)
 
Spark Jobserver
Spark JobserverSpark Jobserver
Spark Jobserver
 
How To Use Higher Order Functions in Scala
How To Use Higher Order Functions in ScalaHow To Use Higher Order Functions in Scala
How To Use Higher Order Functions in Scala
 
Functional Programming for OO Programmers (part 2)
Functional Programming for OO Programmers (part 2)Functional Programming for OO Programmers (part 2)
Functional Programming for OO Programmers (part 2)
 
Introduction to parallel and distributed computation with spark
Introduction to parallel and distributed computation with sparkIntroduction to parallel and distributed computation with spark
Introduction to parallel and distributed computation with spark
 
ScalaTrainings
ScalaTrainingsScalaTrainings
ScalaTrainings
 
Scala meetup - Intro to spark
Scala meetup - Intro to sparkScala meetup - Intro to spark
Scala meetup - Intro to spark
 
Apache Spark RDDs
Apache Spark RDDsApache Spark RDDs
Apache Spark RDDs
 

Similaire à Learn Scala Fundamentals

Intro to Scala.js - Scala UG Cologne
Intro to Scala.js - Scala UG CologneIntro to Scala.js - Scala UG Cologne
Intro to Scala.js - Scala UG CologneMarius Soutier
 
2007 09 10 Fzi Training Groovy Grails V Ws
2007 09 10 Fzi Training Groovy Grails V Ws2007 09 10 Fzi Training Groovy Grails V Ws
2007 09 10 Fzi Training Groovy Grails V Wsloffenauer
 
Scala for Java Programmers
Scala for Java ProgrammersScala for Java Programmers
Scala for Java ProgrammersEric Pederson
 
A Sceptical Guide to Functional Programming
A Sceptical Guide to Functional ProgrammingA Sceptical Guide to Functional Programming
A Sceptical Guide to Functional ProgrammingGarth Gilmour
 
Scala final ppt vinay
Scala final ppt vinayScala final ppt vinay
Scala final ppt vinayViplav Jain
 
Introduction To Groovy 2005
Introduction To Groovy 2005Introduction To Groovy 2005
Introduction To Groovy 2005Tugdual Grall
 
Scala Frustrations
Scala FrustrationsScala Frustrations
Scala Frustrationstakezoe
 
An introduction to scala
An introduction to scalaAn introduction to scala
An introduction to scalaXing
 
20160520 what youneedtoknowaboutlambdas
20160520 what youneedtoknowaboutlambdas20160520 what youneedtoknowaboutlambdas
20160520 what youneedtoknowaboutlambdasshinolajla
 
Advanced Technology for Web Application Design
Advanced Technology for Web Application DesignAdvanced Technology for Web Application Design
Advanced Technology for Web Application DesignBryce Kerley
 
The Great Scala Makeover
The Great Scala MakeoverThe Great Scala Makeover
The Great Scala MakeoverGarth Gilmour
 
A Recovering Java Developer Learns to Go
A Recovering Java Developer Learns to GoA Recovering Java Developer Learns to Go
A Recovering Java Developer Learns to GoMatt Stine
 
What You Need to Know About Lambdas - Jamie Allen (Typesafe)
What You Need to Know About Lambdas - Jamie Allen (Typesafe)What You Need to Know About Lambdas - Jamie Allen (Typesafe)
What You Need to Know About Lambdas - Jamie Allen (Typesafe)jaxLondonConference
 
Solid and Sustainable Development in Scala
Solid and Sustainable Development in ScalaSolid and Sustainable Development in Scala
Solid and Sustainable Development in Scalascalaconfjp
 
Effective Scala (JavaDay Riga 2013)
Effective Scala (JavaDay Riga 2013)Effective Scala (JavaDay Riga 2013)
Effective Scala (JavaDay Riga 2013)mircodotta
 

Similaire à Learn Scala Fundamentals (20)

Intro to Scala.js - Scala UG Cologne
Intro to Scala.js - Scala UG CologneIntro to Scala.js - Scala UG Cologne
Intro to Scala.js - Scala UG Cologne
 
2007 09 10 Fzi Training Groovy Grails V Ws
2007 09 10 Fzi Training Groovy Grails V Ws2007 09 10 Fzi Training Groovy Grails V Ws
2007 09 10 Fzi Training Groovy Grails V Ws
 
Scala for Java Programmers
Scala for Java ProgrammersScala for Java Programmers
Scala for Java Programmers
 
A Sceptical Guide to Functional Programming
A Sceptical Guide to Functional ProgrammingA Sceptical Guide to Functional Programming
A Sceptical Guide to Functional Programming
 
Scala final ppt vinay
Scala final ppt vinayScala final ppt vinay
Scala final ppt vinay
 
Introduction To Groovy 2005
Introduction To Groovy 2005Introduction To Groovy 2005
Introduction To Groovy 2005
 
Scala Frustrations
Scala FrustrationsScala Frustrations
Scala Frustrations
 
An introduction to scala
An introduction to scalaAn introduction to scala
An introduction to scala
 
20160520 what youneedtoknowaboutlambdas
20160520 what youneedtoknowaboutlambdas20160520 what youneedtoknowaboutlambdas
20160520 what youneedtoknowaboutlambdas
 
Advanced Technology for Web Application Design
Advanced Technology for Web Application DesignAdvanced Technology for Web Application Design
Advanced Technology for Web Application Design
 
Fancy talk
Fancy talkFancy talk
Fancy talk
 
Polyglot JVM
Polyglot JVMPolyglot JVM
Polyglot JVM
 
The Great Scala Makeover
The Great Scala MakeoverThe Great Scala Makeover
The Great Scala Makeover
 
A Recovering Java Developer Learns to Go
A Recovering Java Developer Learns to GoA Recovering Java Developer Learns to Go
A Recovering Java Developer Learns to Go
 
Coscup
CoscupCoscup
Coscup
 
PHP - Introduction to PHP Functions
PHP -  Introduction to PHP FunctionsPHP -  Introduction to PHP Functions
PHP - Introduction to PHP Functions
 
What You Need to Know About Lambdas - Jamie Allen (Typesafe)
What You Need to Know About Lambdas - Jamie Allen (Typesafe)What You Need to Know About Lambdas - Jamie Allen (Typesafe)
What You Need to Know About Lambdas - Jamie Allen (Typesafe)
 
Php Intermediate
Php IntermediatePhp Intermediate
Php Intermediate
 
Solid and Sustainable Development in Scala
Solid and Sustainable Development in ScalaSolid and Sustainable Development in Scala
Solid and Sustainable Development in Scala
 
Effective Scala (JavaDay Riga 2013)
Effective Scala (JavaDay Riga 2013)Effective Scala (JavaDay Riga 2013)
Effective Scala (JavaDay Riga 2013)
 

Plus de 佑介 九岡

今日から始める人のための Kubernetes on AWS ベストプラクティス 2018版
今日から始める人のための Kubernetes on AWS ベストプラクティス 2018版今日から始める人のための Kubernetes on AWS ベストプラクティス 2018版
今日から始める人のための Kubernetes on AWS ベストプラクティス 2018版佑介 九岡
 
Continuous Deployments to Multiple Kubernetes Clusters
Continuous Deployments to Multiple Kubernetes ClustersContinuous Deployments to Multiple Kubernetes Clusters
Continuous Deployments to Multiple Kubernetes Clusters佑介 九岡
 
From dev to prod: Kubernetes on AWS (short ver.)
From dev to prod: Kubernetes on AWS (short ver.)From dev to prod: Kubernetes on AWS (short ver.)
From dev to prod: Kubernetes on AWS (short ver.)佑介 九岡
 
Auto-scaled Concourse CI on AWS w/o BOSH
Auto-scaled Concourse CI on AWS w/o BOSHAuto-scaled Concourse CI on AWS w/o BOSH
Auto-scaled Concourse CI on AWS w/o BOSH佑介 九岡
 
AWS re:Invent 2015に初参戦→気づいたらOSS二つ作ってた
AWS re:Invent 2015に初参戦→気づいたらOSS二つ作ってたAWS re:Invent 2015に初参戦→気づいたらOSS二つ作ってた
AWS re:Invent 2015に初参戦→気づいたらOSS二つ作ってた佑介 九岡
 
2014/12/13 第1回 Scala関西勉強会 play2-memcached supports Play 2.4 ~Play 2.4モジュールのつく...
2014/12/13 第1回 Scala関西勉強会 play2-memcached supports Play 2.4 ~Play 2.4モジュールのつく...2014/12/13 第1回 Scala関西勉強会 play2-memcached supports Play 2.4 ~Play 2.4モジュールのつく...
2014/12/13 第1回 Scala関西勉強会 play2-memcached supports Play 2.4 ~Play 2.4モジュールのつく...佑介 九岡
 
Elasticsearch at CrowdWorks
Elasticsearch at CrowdWorksElasticsearch at CrowdWorks
Elasticsearch at CrowdWorks佑介 九岡
 
Scala-driven Engineering Life
Scala-driven Engineering LifeScala-driven Engineering Life
Scala-driven Engineering Life佑介 九岡
 

Plus de 佑介 九岡 (11)

今日から始める人のための Kubernetes on AWS ベストプラクティス 2018版
今日から始める人のための Kubernetes on AWS ベストプラクティス 2018版今日から始める人のための Kubernetes on AWS ベストプラクティス 2018版
今日から始める人のための Kubernetes on AWS ベストプラクティス 2018版
 
Continuous Deployments to Multiple Kubernetes Clusters
Continuous Deployments to Multiple Kubernetes ClustersContinuous Deployments to Multiple Kubernetes Clusters
Continuous Deployments to Multiple Kubernetes Clusters
 
From dev to prod: Kubernetes on AWS (short ver.)
From dev to prod: Kubernetes on AWS (short ver.)From dev to prod: Kubernetes on AWS (short ver.)
From dev to prod: Kubernetes on AWS (short ver.)
 
Auto-scaled Concourse CI on AWS w/o BOSH
Auto-scaled Concourse CI on AWS w/o BOSHAuto-scaled Concourse CI on AWS w/o BOSH
Auto-scaled Concourse CI on AWS w/o BOSH
 
AWS re:Invent 2015に初参戦→気づいたらOSS二つ作ってた
AWS re:Invent 2015に初参戦→気づいたらOSS二つ作ってたAWS re:Invent 2015に初参戦→気づいたらOSS二つ作ってた
AWS re:Invent 2015に初参戦→気づいたらOSS二つ作ってた
 
2014/12/13 第1回 Scala関西勉強会 play2-memcached supports Play 2.4 ~Play 2.4モジュールのつく...
2014/12/13 第1回 Scala関西勉強会 play2-memcached supports Play 2.4 ~Play 2.4モジュールのつく...2014/12/13 第1回 Scala関西勉強会 play2-memcached supports Play 2.4 ~Play 2.4モジュールのつく...
2014/12/13 第1回 Scala関西勉強会 play2-memcached supports Play 2.4 ~Play 2.4モジュールのつく...
 
Elasticsearch at CrowdWorks
Elasticsearch at CrowdWorksElasticsearch at CrowdWorks
Elasticsearch at CrowdWorks
 
Basics of Akka
Basics of AkkaBasics of Akka
Basics of Akka
 
Scala-driven Engineering Life
Scala-driven Engineering LifeScala-driven Engineering Life
Scala-driven Engineering Life
 
IDEALIZE YOU
IDEALIZE YOUIDEALIZE YOU
IDEALIZE YOU
 
[Start] Playing
[Start] Playing[Start] Playing
[Start] Playing
 

Learn Scala Fundamentals

  • 3. Do you know Functional Programming?
  • 4. Do you know Scala? ’’’
  • 5. [Start] Scala! ’’’ @mumoshu
  • 6. # of atnders php java scala js python perl 0 5 10 15
  • 8. PHP, Java, Scala Web dev General Purpose Scala PHP Java
  • 9. PHP, Java, Scala Web dev General Purpose Dynamically Statically typed typed Scala PHP Java
  • 10. PHP, Java, Scala Web dev General Purpose Shorter code Dynamically Statically typed typed Scala Longer code PHP Java
  • 11. Scala • has NOTHING NEW!
  • 12. PHP and Scala • PHP + Static Typing + Shorter code = Scala ?!
  • 13. Java and Scala • Java + Shorter code = Scala ?!
  • 15. Basic computation • Calculate the sum in imperative style
  • 16. Basic computation • Calculate the sum in imperative style 1 + 2 + 3 = 6
  • 17. Basic computation • Calculate the sum in imperative style 1 + 2 + 3 = 6 sum = 0 sum = sum + 1 sum = sum + 2 sum = sum + 3
  • 18. MY Ranking 1. (Ruby) 2. Scala 3. (JavaScript) 4. PHP 5. Java
  • 19. Sum with Java int[] array = new int[] { 1, 2, 3 }; int sum = 0; for (int i=0; i<array.length; i++) {   sum += array[i]; } System.out.println(sum);
  • 20. Sum with Java int[] array = new int[] { 1, 2, 3 }; int sum = 0; for (int i=0; i<array.length; i++) {   sum += array[i]; } System.out.println(sum);
  • 22. Sum with PHP $array = array(1, 2, 3); $sum = 0; for ($i=1; $i<=count($array); $i++) {     $sum += $array[$i]; } print $sum;
  • 23. Sum with PHP $array = array(1, 2, 3); $sum = 0; for ($i=1; $i<=count($array); $i++) {     $sum += $array[$i]; } print($sum);
  • 25. Sum with JS var array = [1,2,3] var sum = 0 for (var i in array) { sum += array[i] } console.log(sum);
  • 26. Sum with JS var array = [1,2,3] var sum = 0 for (var i in array) { sum += array[i] } console.log(sum);
  • 28. Sum with Ruby array = [1, 2, 3] sum = 0 for (x in array) sum += x end puts sum
  • 30. Scala + for var array = Array(1, 2, 3) var sum = 0 for (x <- array) {   sum += x } println(sum)
  • 31. (‘-’) Is that your power?
  • 32. Scala + for var array = Array(1, 2, 3) var sum = 0 for (x <- array) {   sum += x } println(sum)
  • 33. Scala + for var array = Array(1, 2, 3) var sum = 0 for (x <- array) {   sum += x } println(sum)
  • 34. Scala + foreach var array = Array(1, 2, 3) var sum = 0 array foreach { x =>   sum += x } println(sum)
  • 35. Scala + foreach var array = Array(1, 2, 3) var sum = 0 array foreach { x =>   sum += x } println(sum)
  • 36. Scala + foreach var array = Array(1, 2, 3) var sum = 0 array foreach { sum += _ } println(sum)
  • 37. Sum with `reduce` • Calculate the sum in functional styl
  • 38. Sum with `reduce` • Calculate the sum in functional style sum = 1 + 2 + 3 sum = 3 + 3 sum = 6
  • 39. Sum with `reduce` • Calculate the sum in functional style sum = 1 + 2 + 3
  • 40. Sum with `reduce` • Calculate the sum in functional style 1. (Ruby) 2. Scala 3. (JavaScript) 4. PHP 5. Java
  • 42. PHP $array = array(1, 2, 3); function reduce($a, $b){ return $a + $b; }; $sum = array_reduce($array, 'reduce'); print $sum;
  • 43. JavaScript var array = [1, 2, 3]; var sum = array.reduce(function(a,b){ return a + b }); console.log(sum);
  • 45. Ruby array = [1, 2, 3] sum = array.reduce(&:+) puts sum
  • 46. Scala val array = Array(1, 2, 3) val sum = array.reduce(_+_) println(sum)
  • 47. (^-^)
  • 49. More Scala val array = Array(1, 2, 3) val sum = array.sum println(sum)
  • 50. You learn everyday • And you code gets BETTER
  • 51. Are you • a Java engineer? • or maybe a PHP engineer? • Do you use `Class’?
  • 52. Class • Define a class in 1. Scala 2. (Ruby) 3. PHP 4. Java 5. (JavaScript)
  • 53. Greeter Hello Scala Greeter
  • 54. Classes in Java public class Greeter { private String name; public Greeter(String name) { this.name = name; } public Greeter() { Greeter(“Scala”); } public String getName() { return this.name; } public void greet() { System.out.println(“Hello “ + this.name); } } Greeter greeter = new Greeter("Scala!"); greeter.greet();
  • 55. Classes in PHP <?php class Greeter { private $name; function __construct($name = 'Scala') { $this->name = $name; } public function getName() { return $this->name; } public function greet() { print ‘Hello ‘ . $this->name; } } $greeter = new Greeter(‘Scala!’); $greeter->greet(); ?>
  • 56. Classes in JS function Greeter(name) { this.name = typeof name == “undefined” ? “Scala” : name; } Greeter.prototype = { getName: function() { return this.name; }, greet: function() { console.log(“Hello “ + this.name); } }; var greeter = new Greeter(“Scala”); greeter.greet();
  • 57. Classes in Ruby class Greeter attr_reader :name def initialize(name="Scala") @name = name end def greet puts “Hello “ + @name end end greeter = Greeter.new(“Scala”) greeter.greet
  • 58. Classes in Scala class Greeter(val name: String = “Scala”) { def greet() { println(“Hello “ + name) } } val greeter = new Greeter("Scala!"); greeter.greet()
  • 61. break 1/2   ビースト★ハーレム ∼野獣の甘噛み∼ http://pf.gree.jp/56616
  • 63. Scala is • General purpose • Not only Web • Multi-paradigm • Object-oriented + Functional programming
  • 64. Scala ’’’ • Run on JVM • A lot of Java libraries • Hybrid language • Imperative programming • Object oriented programming • Functional programming
  • 65. Whats happy with FP • Concurrency • Scalability
  • 66. Imperative vs Functional • Imperative Programming do A -> state++, do B -> state++, ... • Functional programming in1 -> f(x) -> out1 in2 -> g(x) -> out2
  • 68. Easy concurrency • Imperative programming do A -> state <- do B > sudden conflict!!! < • Functional programming in1 -> f(x) -> out1, in2 -> g(x) -> out2 > no conflict!!! <
  • 69. Dynamic vs Static typing • About type-safety
  • 70. Dynamic typing • GOOD • Run anyway • BAD • More runtime errors
  • 74. Call to undefined function
  • 75. Static typing • GOOD • More compile errors • BAD • Hard to read error messages
  • 76. Scala 2.10 • We have Scala 2.9.3 • Scala 2.10 is coming (on 12/26?)
  • 77. Recommendation • If you want to: • write something other than Web app • write noise-free, consise code • develop your skill GRADUALLY
  • 78. [Start] Scala! ’’’ @mumoshu
  • 81. Scala for business • Scalaはお仕事に向いてます • Java同様、静的型付けは複数人での 開発に有効 • Scalaはエンジニアの成長を止めない
  • 82. Scala for education • ステップアップ学習に最適 • sumの例のように、Scalaに慣れてくる と徐々に簡潔な書き方が出来るよう になっていく • 手続き的に書ける。慣れたらいつで も関数型チックに書ける。
  • 83. Scala’s flexibility • Scalaは自由度が高い • 同じ意味のことを幾通りにも書けて メンテナンス性が悪い、のではない • 各人のレベルにあった記述ができる • プログラマの創造性を阻害しない
  • 84. Learning Scala • Javaと同じ書き方でいいなら、Javaと同じ学 習コスト • ちょっと短いだけのJavaとして書けるので • Web開発ならPHPの方が最初の敷居が低い
  • 85. REPL • Scalaの対話環境 • ScalaのREPLを起動すると”Welcome to Scala”って言われる • 「ようこそScalaへ。ご命令を。」って 言ってくれるScalaかわいい
  • 86. Compilation time • Scalaのコンパイルは長い • Time is money • PCをスペックアップしましょう