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

Scala vs Ruby

Scala vs Ruby

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

C48758d8162582b770092002effb7dff?s=128

Hirokazu Nishioka

June 25, 2015
Tweet

Transcript

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

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

    • Ruby(Rails)ྺɿ1ϲ݄൒
  3. ScalaͱRubyΛൺֱͯ͠ΈΔ RubyΛॻ͘͜ͱʹͳͬͨͷͰɾɾɾ

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

  5. ҆৺ײͷ࡞Γํͷҧ͍ • Scala͸ʮίϯύΠϧ͕௨Ε͹͍͍ͩͨ߹ͬͯΔʯͱ ͍͏҆৺ײ ➡ ίϯύΠϧ͸ςετ ➡ ੩తܕ෇͚ؔ਺ܕݴޠͷύϫʔ • Ruby͸ςετͰ҆৺ײΛ࡞Δ

    ➡ ѹ౗తʹςετ͕ॻ͖΍͍͢ ➡ ಈతܕ෇͚+ΦʔϓϯΫϥεͷύϫʔ
  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"ίϯύΠϥΦϓγϣϯ࢖༻
  7. ScalaͱRubyͬͯ݁ߏࣅͯΔ ʢҙ֎ʂʣ

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

  9. ΞυϗοΫͳػೳ௥Ճ • Ұੲલ͸ΦʔϓϯΫϥε(Ruby)ͷಛݖͩͬͨ • Scala΋Ͱ͖ΔΑʂ → ܕΫϥε (+ ϚΫϩ) •

    ϥΠϒϥϦͷػೳ͕ίʔυʹγʔϜϨεʹ༥ ߹͢Δ • ϦϑΝϨϯε͕ݟ೉͍͆
  10. Ͳͬͪ΋ָ͍͠(*°∀°)=3

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