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

プログラミング言語Rust

 プログラミング言語Rust

Rustの紹介的な勉強会

70d9714ea13fc1133803d61fb16e4160?s=128

Yusuke Hosonuma

November 09, 2016
Tweet

Transcript

  1. ϓϩάϥϛϯάݴޠ Rust

  2. ࣗݾ঺հ • Yusuke Hosonuma • https://github.com/YusukeHosonuma • Qiita΋ͨ·ʹॻ͍ͯΔΑɻ • ϚΠϯυϑϧωε࣮ફதɻ

  3. Rustͬͯʁ

  4. Rustͬͯʁ • Mozilla͕࡞ͬͨγεςϜϓϩάϥϛϯάݴޠ • ߴ଎ੑɺ҆શੑɺฒߦੑɺʹϑΥʔΧε • C/C++/GoͷΑ͏ʹγϯάϧόΠφϦग़ྗͰ͖Δ • Ϟμϯͳ֓೦ʢؔ਺ܕͱ͔ʣΛऔΓೖΕͯΔ •

    Swift͕ӨڹΛड͚ͨݴޠͰ΋͋Δ
  5. ߴ଎ʁ

  6. ߴ଎ʁ • C/C++ͷΑ͏ͳθϩΦʔόʔϔουΛ໨ࢦ͢ • GCͳ͠ɺࢀরΧ΢ϯτͳ͠ɺͷϝϞϦ؅ཧ • Ϟμϯͳ֓೦Λαϙʔτͭͭ͠ɺΦʔόʔϔου ͕ݶΓͳ͘ൃੜ͠ͳ͍Α͏ʹߟ͑ΒΕͯΔ • ʮθϩίετந৅Խʯ(zero-cost

    abstractions)
  7. ҆શʁ

  8. ҆શʁ • C/C++Ͱ͸ϝϞϦؔ࿈ͷόά͕ઈ͑ͳ͍ • ະॳظԽ or ൣғ֎ͷྖҬʹΞΫηεͨ͠Γ • όοϑΝʔΦʔόʔϑϩʔ੬ऑੑͷѱເ •

    RustͰ͸ίϯύΠϧ࣌ʹແޮͳϝϞϦΞΫηε͕ൃ ੜ͠ͳ͍͜ͱΛอূ͢Δ • ੩తܕ෇͚Ͱܕਪ࿦͋Γ
  9. ฒߦʁ

  10. ฒߦʁ • Ұൠతʹฒߦϓϩάϥϛϯά͸೉͍͠ • ෳ਺ͷεϨου͕ಉ͡σʔλΛಉ࣌ʹಡΈॻ͖ ͠ͳ͍Α͏ʹࡉ৺ͷ஫ҙ͕ඞཁ • ࠶ݱੑͷ௿͍όά΋ੜΈग़͠΍͍͢ • RustͰ͸ίϯύΠϧ࣌ʹσʔλڝ߹Λ๷͙࢓૊Έ

    ͕͋Δ
  11. ࣮੷ʁ

  12. ࣮੷ʁ • Friends of Rust
 https://www.rust-lang.org/en-US/friends.html
 
 ↑࣮ϓϩμΫτʹRustΛ࢖͍ͬͯΔ૊৫ • Mozilla͸FirefoxͷϝσΟΞύʔβͰར༻


    ˠ 10ԯਓҎ্͕ར༻͍ͯ͠Δͷʹɺ1݅΋Τϥʔ͕ ൃੜ͍ͯ͠ͳ͍ʢΒ͍͠ʣ • Dropbox΍LINEͱ͍ͬͨେޚॴ΋ར༻͍ͯ͠Δ
  13. Why Rust ?

  14. Why Rust ? • C/C++ͷΑ͏ʹߴ଎ੑ͕ٻΊΒΕΔιϑτ΢ΣΞ ʢOS/υϥΠόͳͲʣʹ޲͍͍ͯΔ • C/C++͸ߴ଎͚ͩͲɺϝϞϦ؅ཧ͸҆શͰ͸ͳ͍͠ɺ ฒߦϓϩάϥϛϯά΋೉͍͠ •

    ݱঢ়ͷʢGoݴޠҎ֎ͷʣϞμϯݴޠ͔ΒݟΔͱػೳ͸ ऑ͍ʢ͖ͼ͠Ίʹݴ͑͹࣌୅஗Εʣ • ͦ͜ͰRustͰ͢Αʂ
  15. ͭ·Γʁ

  16. ͭ·Γʁ • ϙετC++Λ໨ࢦ͢ݴޠ • ߴ଎ɺ҆શɺฒྻɺʹϑΥʔΧεͨ͠ݴޠ • ࠷େͷڝ߹͸Dݴޠ

  17. Hello Rust

  18. Hello Rust fn main() {
 println!("Hello, world!"); // This is

    macro
 }
  19. ϑΟϘφον਺ྻ

  20. ϑΟϘφον਺ྻ fn fib(n: u32) -> u32 { // Function definition


    match n { // Pattern match
 0 => 1,
 1 => 1,
 _ => fib(n - 1) + fib(n - 2), // Recursive call
 } // not need `return`
 }
 
 fn main() {
 let fib5 = fib(5); // local variable (Immutable is default)
 println!("fib(5): {}", fib5); // `{}` is placeholder
 // => 8
 }
  21. Cargo(Χϧΰ)

  22. Cargo(Χϧΰ) • Rustඪ४ͷϏϧυπʔϧ • ಉ࣌ʹύοέʔδϚωʔδϟͰ΋͋Δ • ͭ·ΓɺϏϧυɺϥΠϒϥϦͷμ΢ϯϩʔυɺ ґଘؔ܎ͷղܾɺΛશ෦΍Δ • ʮધՙʯͱ͍͏ҙຯ͕͋Δ

  23. Rustͷ࢝Ίํ

  24. Rustͷ࢝Ίํ • $ brew install rust • $ cargo new

    hello --bin • $ cd ./hello • $ cargo run • > Hello, world!
  25. Rust Samurai ΁ͷಓ ʻࡶίϥͰѱ͔ͬͨͳ

  26. Rust Samurai ΁ͷಓ • ϓϩάϥϛϯάݴޠRustʢ೔ຊޠ༁ʣ
 https://rust-lang-ja.github.io/the-rust- programming-language-ja/1.6/book/ README.html • όʔδϣϯ1.6Ͱͪΐͬͱݹ͍͚Ͳ෼͔Γ΍͍͢

  27. Rust Samurai ΁ͷಓ • Rust by Example
 http://rustbyexample.com/index.html • αϯϓϧίʔυΛϕʔεʹֶͯ͠΂·͢ɻͨͩ͠

    ӳޠɻ
  28. Rust Samurai ΁ͷಓ • APIϦϑΝϨϯε
 https://doc.rust-lang.org/std/ • ݕࡧػೳ͕ͳ͔ͳ͔༏लͰ͢ɻ

  29. Join us?

  30. Join us? • StackOverflowʹ͓͍ͯɺ2016೥ͷѪ͞ΕͯΔݴޠϥ ϯΩϯά1ҐΛ֫ಘ͍ͯ͠·͢ɻ • طʹηϧϑϗεςΟϯάʢࣗ਎Ͱࣗ਎ΛίϯύΠϧʣ Λ࣮ݱ͍ͯ͠·͢ɻ • GoݴޠͷΑ͏ʹޙΖ६͕ແͯ͘΋੒௕͖ͯͨ͠ݴޠ

    Ͱ͢ɻ • ࠷ۙʹͳͬͯར༻࣮੷͕֦େ͍ͯ͠·͢ɻ
  31. Rust͸͍͍ͧʂ

  32. Thanks!