Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Scala vs Ruby

Scala vs Ruby

2015-06-25 第2回SpeeeTeckParty LT資料

Hirokazu Nishioka

June 25, 2015
Tweet

More Decks by Hirokazu Nishioka

Other Decks in Programming

Transcript

  1. Scala vs Ruby
    2015-06-25 ୈ2ճSpeeeTechParty LT
    ੢Ԭ׮݉ @nisshieeorg

    View full-size slide

  2. ࣗݾ঺հ
    • ੢Ԭ׮݉ʢʹ͓͔͠ ͻΖ͔ͣʣ
    • @nisshieeorg
    • ޷͖ͳݴޠɿScala
    • Scalaྺɿ4೥
    • Ruby(Rails)ྺɿ1ϲ݄൒

    View full-size slide

  3. ScalaͱRubyΛൺֱͯ͠ΈΔ
    RubyΛॻ͘͜ͱʹͳͬͨͷͰɾɾɾ

    View full-size slide

  4. ΋ͪΖΜؔ਺ܕͱOOPͷҧ͍
    ͱ͔͸͋ΔΜ͚ͩͲɺ
    Ұ൪ҧͬͨͷ͸ɾɾɾ

    View full-size slide

  5. ҆৺ײͷ࡞Γํͷҧ͍
    • Scala͸ʮίϯύΠϧ͕௨Ε͹͍͍ͩͨ߹ͬͯΔʯͱ
    ͍͏҆৺ײ
    ➡ ίϯύΠϧ͸ςετ
    ➡ ੩తܕ෇͚ؔ਺ܕݴޠͷύϫʔ
    • Ruby͸ςετͰ҆৺ײΛ࡞Δ
    ➡ ѹ౗తʹςετ͕ॻ͖΍͍͢
    ➡ ಈతܕ෇͚+ΦʔϓϯΫϥεͷύϫʔ

    View full-size slide

  6. def fizzbuzz(i: Int): String = (i % 3, i % 5) match {
    case (0, 0) => "FizzBuzz"
    case (0, _) => "Fizz"
    case (_, 0) => "Buzz"
    case _ => i.toString
    }
    // ίϯύΠϧOK
    !
    def fizzbuzz(i: Int): String = (i % 3, i % 5) match {
    case (0, _) => "Fizz"
    case (_, 0) => "Buzz"
    case (0, 0) => "FizzBuzz"
    case _ => i.toString
    }
    [error] /src/main/scala/App.scala:5: unreachable code
    [error] case (0, 0) => "FizzBuzz"
    ScalaͷίϯύΠϧ࣌νΣοΫೳྗʢҰྫʣ
    ※ "-Xfatal-warnings"ίϯύΠϥΦϓγϣϯ࢖༻

    View full-size slide

  7. ScalaͱRubyͬͯ݁ߏࣅͯΔ
    ʢҙ֎ʂʣ

    View full-size slide

  8. OSSίϛϡχςΟ͕׆ൃ
    • ͳͷͰɺόʔδϣϯ໰୊͕ى͖Δ͆
    • ґଘͷґଘͷόʔδϣϯࠩͰࢮ͵

    View full-size slide

  9. ΞυϗοΫͳػೳ௥Ճ
    • Ұੲલ͸ΦʔϓϯΫϥε(Ruby)ͷಛݖͩͬͨ
    • Scala΋Ͱ͖ΔΑʂ → ܕΫϥε (+ ϚΫϩ)
    • ϥΠϒϥϦͷػೳ͕ίʔυʹγʔϜϨεʹ༥
    ߹͢Δ
    • ϦϑΝϨϯε͕ݟ೉͍͆

    View full-size slide

  10. Ͳͬͪ΋ָ͍͠(*°∀°)=3

    View full-size slide

  11. ͝੩ௌ͋Γ͕ͱ͏͍͟͝·ͨ͠

    View full-size slide