Rubyから世界へ / Let’s start a journey around the world beyond Ruby

Rubyから世界へ / Let’s start a journey around the world beyond Ruby

Rubyを第1言語(最初に学んだプログラミング言語)としてRubyを学んだ人向けのプログラミング言語の紹介です。

682bc9c1067a85bbcaa6cc35b1f23982?s=128

Yuya Kato

April 02, 2019
Tweet

Transcript

  1. Ruby͔Βੈք΁ 2019/04/02 Kobe.rb #100 -LT Party- @120 WORKPLACE KOBE Nayutaya

    Inc. / Yuya Kato !1 Let's start a journey around the world beyond Ruby
  2. ࣗݾ঺հ: Ճ౻ ༐໵ • ιϑτ΢ΣΞΤϯδχΞʢ2000೥ʙʣ • גࣜձࣾಹ༝ଟ԰ ୅දऔక໾ʢ2007೥ʙʣ ͳ Ώ

    ͨ ΍ • झຯ: • ΋ͷͮ͘Γશൠ • 3DϓϦϯλʢ2013೥ʙʣ • ϘϧμϦϯάʢ2011೥ʙʣ !2 yuyakato1984 nayutaya About me: Yuya Kato I work as a software engineer since 2000. I'm running my own company, Nayutaya Inc., as the CEO since 2007. My hobbies are: Creating software, hardware and so on. Designing something using 3D printer. Doing bouldering.
  3. ਆށ.rb 100ճ։࠵ ͓ΊͰͱ͏͍͟͝·͢ !3 Congratulation on holding Kobe.rb 100 times!

  4. ͪͳΈʹ ๻͕ॳΊͯࢀՃͨ͠ ਆށ.rb͸ୈ6ճ ʢ2014೥10݄30೔։࠵ʣ Ͱͨ͠ https://koberb.doorkeeper.jp/events/15791 !4 Incidentally, my first

    participation in Kobe.rb was the 6th meetup held on Oct. 30 2014.
  5. ໨࣍ • ͜ͷLTͷλʔήοτ • ͜ͷLTͷΰʔϧ • ͦ΋ͦ΋ʮݴޠʯͱ͸ʁ • ϓϩάϥϛϯάݴޠΛ༷ʑͳ੾ΓޱͰ !5

    Table of contents The targets of this LT The goals of this LT What is "language?" Let's look at various programming languages from various aspects
  6. ͜ͷLTͷλʔήοτ • ୈ1ݴޠʢॳΊͯ৮ͬͨϓϩάϥϛϯάݴޠʣͱͯ͠RubyΛֶΜͩਓ • ϓϩάϥϛϯάͷੈքΛΑΓ޿͍͛ͨਓ !6 The targets of this

    LT are: People who hopes to spread his/her world about programming People who learned Ruby as his/her first programming language
  7. ͜ͷLTͷΰʔϧ • ϓϩάϥϛϯάͷੈքͷ޿͞Λײͯ͡΋Β͏͜ͱ • ʮଞͷϓϩάϥϛϯάݴޠ΋ֶΜͰΈ͍ͨʂʯͱײͯ͡΋Β͏͜ͱ !7 The goals of this

    LT are: To let you think that you want to learn other programming languages more To let you feel the extent of the programming world
  8. ͦ΋ͦ΋ʮݴޠʯͱ͸ʁ !8 In the first place, what is "language?"

  9. ݴޠͱ͸ !9 ʮ͋Δଘࡏʯͱʮผͷଘࡏʯ͕ҙࢥͷૄ௨ΛਤΔͨΊʹ༻͍Δ จࣈΛத৺ͱͨ͠Ұఆͷܾ·Γʹैͬͨදݱ Languages are Representations according to rules

    to communicate his/her thought between others, in most cases based on characters.
  10. ͍Ζ͍Ζͳʮݴޠʯ !10 ࣗવݴޠ Japanese, English ਓ޻ݴޠ ࠃࡍิॿޠ Esperanto Sign lang.

    ίϯϐϡʔλݴޠ σʔλهड़ݴޠ ϚʔΫΞοϓݴޠ HTML, Markdown ϋʔυ΢ΣΞهड़ݴޠ Verilog, VHDL ໰͍߹Θͤݴޠ SQL, GraphQL ϓϩάϥϛϯάݴޠ Ruby, C/C++ ஫: ͜ͷޙͷεϥΠυͰ͸ʮݴ ޠʯ͸ʮϓϩάϥϛϯάݴޠʯ Λࣔ͠·͢ Variety of languages Natural lang. Artificial lang. International auxiliary lang. Query lang. Programming lang. Computer lang. Data description lang. Markup lang. HDL Note: "Lang." means programming lang. after this slide.
  11. ϓϩάϥϛϯάݴޠΛ ༷ʑͳ੾ΓޱͰ !11 Let's look at various programming languages from

    various aspects
  12. ύϥμΠϜʹΑΔ෼ྨ !12 Paradigms ໋ྩܕݴޠʢखଓ͖ܕݴޠʣ Ruby એݴܕݴޠ ؔ਺ܕݴޠ Haskell ࿦ཧܕݴޠ Prolog

    C/C++ LISP Idris Scala ७ਮ ඇ७ਮ Java ͦͷଞɺଟ͘ͷݴޠ Imperative (Procedural) Declarative Functional Purely Not purely Logic Python And many other languages
  13. ந৅౓ʹΑΔ෼ྨ !13 ௿ந৅౓ʢ௿Ϩϕϧʣ ߴந৅౓ʢߴϨϕϧʣ Machine code Assembly lang. C/C++ Ruby

    ஫:ʮϨϕϧʯ͸ݴޠͷ༏ྼΛࣔ͢΋ͷͰ͸͋Γ·ͤΜ Java Rust Haskell Abstraction level Low degree of abstraction High degree of abstraction Note: "Level" doesn't express superiority or inferiority of lang.
  14. ܕ෇͚ʹΑΔ෼ྨ !14 ڧ͍ܕ෇͚ ऑ͍ܕ෇͚ ಈతͳܕ෇͚ ੩తͳย෇͚ Ruby C/C++ Java Haskell

    Python JavaScript Data typing Dynamic Static Weak Strong Machine code
  15. ςΩετ/ϏδϡΞϧ !15 ςΩετݴޠ ϏδϡΞϧݴޠ Scratch Ruby ͦͷଞɺ΄ͱΜͲͷݴޠ Haskell C/C++ Java

    LabVIEW Simulink Text or Visual And most other languages Text programming lang. Visual programming lang.
  16. ۩ମྫ: Scratch !16 https://microbit.org/ja/2019-01-14-scratch-meets-microbit/ Example: Scratch

  17. Πϯσϯτʹҙຯ͕͋Δ/ͳ͍ !17 Πϯσϯτʹҙຯ͕ͳ͍ݴޠ Πϯσϯτʹҙຯ͕͋Δݴޠ Python Haskell Ruby C/C++ Java Indentation

    of code has meaning, or not ͦͷଞɺଟ͘ͷݴޠ And many other languages Indentation has meaning Indentation hasn't meaning
  18. ۩ମྫ: Πϯσϯτ !18 Ruby Python Haskell def hello 3.times {

    puts("Hello") } end def hello 3.times { puts("Hello") } end def hello(): for _ in range(3): print("hello") def hello(): for _ in range(3): print(“hello”) --- IndentationError: expected an indented block main = let hello 0 = [] hello n = "hello\n" ++ hello(n - 1) in do putStrLn $ hello(3) main = let hello 0 = [] hello n = "hello\n" ++ hello(n - 1) in do putStrLn $ hello(3) --- parse error (possibly incorrect indentation or mismatched brackets) ΠϯσϯτΛফ͢ͱ Example: indentation Remove indentation
  19. 1࣍ݩ/2࣍ݩ !19 1࣍ݩͳݴޠ 2࣍ݩͳݴޠ Befunge Ruby Haskell C/C++ Java 1

    or 2 dimensional ͦͷଞɺ΄ͱΜͲͷݴޠ And most other languages 1 dimensional 2 dimensional
  20. ۩ମྫ: Befunge !20 v @_ v >0"!dlroW"v v :# <

    >" ,olleH" v ^ < Hello, World! Example: Befunge Source code: Output:
  21. ؙׅހΛଟ༻͢Δ/͠ͳ͍ !21 ؙׅހΛద౓ʹ࢖༻͢Δݴޠ ؙׅހΛଟ༻͢Δݴޠ LISP Ruby ͦͷଞɺ΄ͱΜͲͷݴޠ Haskell C/C++ Java

    Using parentheses a lot, or not And most other languages Using parentheses a lot Using parentheses moderately
  22. ۩ମྫ: LISP !22 (dotimes (n 3) (format t "hello~%")) hello

    hello hello (dotimes (i 100) (cond ((and (= (mod (1+ i) 3) 0) (= (mod (1+ i) 5) 0)) (format t "Fizz,Buzz~%")) ((= (mod (1+ i) 3) 0) (format t "Fizz~%")) ((= (mod (1+ i) 5) 0) (format t "Buzz~%")) (t (format t "~A~%" (1+ i))))) 1 2 Fizz 4 Buzz Fizz 7 8 ... Example: LISP Source code: Output:
  23. ݟ͑Δ/ݟ͑ͳ͍ !23 ݟ͑Δʢҹ࡮Ͱ͖Δʣݴޠ ݟ͑ͳ͍ʢҹ࡮Ͱ͖ͳ͍ʣݴޠ Whitespace Ruby Haskell C/C++ Java Visible,

    or not Visible (printable) Invisible (not printable) ͦͷଞɺ΄ͱΜͲͷݴޠ And most other languages
  24. ۩ମྫ: Whitespace !24 SSSTSSTSSSNTNSSSSSTTSSTST NTNSSSSSTTSTTSSNTNSSSSSTT STTSSNTNSSSSSTTSTTTTNTNSS SSSTSTTSSNTNSSSSSTSSSSSNT NSSSSSTTTSTTTNTNSSSSSTTST TTTNTNSSSSSTTTSSTSNTNSSSS STTSTTSSNTNSSSSSTTSSTSSNT

    NSSSSSTSSSSTNTNSSSSSTSTSN TNSSNNNN Hello, World! Source code: Output: Source code: Space -> S Tab -> T New Line -> N Example: Whitespace
  25. ΦϒδΣΫτࢦ޲Ͱ͋Δ/Ͱͳ͍ !25 ΦϒδΣΫτࢦ޲ͳݴޠ ඇΦϒδΣΫτࢦ޲ͳݴޠ C-lang C++ LISP JavaScript Ruby Haskell

    Object-oriented, or not Object-oriented Non-object-oriented
  26. Ϋϥεϕʔε/ϓϩτλΠϓϕʔε !26 ΫϥεϕʔεΦϒδΣΫτࢦ޲ ϓϩτλΠϓϕʔεΦϒδΣΫτࢦ޲ JavaScript Ruby C++ Smalltalk Self Lua

    Io Class-based object-oriented, or prototype-based one Class-based object-oriented Prototype-based object-oriented
  27. ίϯύΠϧͷ༗ແ !27 ίϯύΠϧ͕ඞཁͳݴޠ ίϯύΠϧ͕ෆཁͳݴޠ C/C++ Java Haskell Ruby JavaScript ஫:

    ࣮ࡍʹ͸ॲཧܥґଘ Need compilation, or not Python Need compilation Not need compilation Note: Actually, it depends on a system of implementation
  28. σʔλͷॴ༗ݖͷ༗ແ !28 ॴ༗ݖ͕͋Δݴޠ ॴ༗ݖ͕ͳ͍ݴޠ Rust Ruby Haskell C/C++ Java Incorporate

    data with ownership, or not ͦͷଞɺ΄ͱΜͲͷݴޠ And most other languages Has ownership system Hasn't ownership system
  29. ۩ମྫ: ॴ༗ݖ !29 Ruby def hello(name) printf("hello, %s!\n", name) end

    name = "NAME" hello(name) hello(name) Rust fn main() { fn hello(name: String) { println!("hello, {}!", name); } let name = String::from("NAME"); hello(name); hello(name); } error[E0382]: use of moved value: `name` --> src/main.rs:7:9 | 6 | hello(name); | ---- value moved here 7 | hello(name); | ^^^^ value used here after move | = note: move occurs because `name` has type `std::string::String`, which does not implement the `Copy` trait hello, NAME! hello, NAME! Source code: Output: Example: ownership
  30. νϡʔϦϯά׬શੑ͋Γ/ͳ͠ !30 νϡʔϦϯά׬શͳݴޠ ඇνϡʔϦϯά׬શͳݴޠ Regular expression HQ9+ ʮνϡʔϦϯά׬શʯͱ͸ʁ ສೳνϡʔϦϯάϚγϯͱಉ͡ܭࢉೳྗΛ΋ͭܭࢉϞσϧ ʮສೳνϡʔϦϯάϚγϯʯͱ͸ʁ

    ཁ͢ΔʹԿͰ΋ܭࢉͰ͖Δػցʢೖग़ྗʹ͍ͭͯ͸ൣᙝ֎ʣ Ruby Haskell C/C++ Java Turing-completeness ͦͷଞɺ΄ͱΜͲͷݴޠ And most other languages Turing-complete Non-turing-complete What is turing-complete? What is universal turing machine? In short, a machine which can calculate anything. A calculation model which has ability of calculation as equal as universal turing machine.
  31. ϧʔϓจͷ༗ແ !31 ϧʔϓͷ͋Δݴޠ ϧʔϓͷͳ͍ݴޠ Ruby Haskell C/C++ Java Has loop

    statement, or not Has loop statement Hasn't loop statement ͦͷଞɺ΄ͱΜͲͷݴޠ And most other languages
  32. ม਺΁ͷ࠶୅ೖͷՄ൱ !32 ࠶୅ೖͰ͖Δݴޠ ࠶୅ೖͰ͖ͳ͍ݴޠ Haskell Ruby C/C++ (non-const) Java (non-final)

    Possible that we re-bind on variables, or not ͦͷଞɺ΄ͱΜͲͷݴޠ And most other languages Re-binding is possible Re-binding is not possible
  33. ଞʹ΋ • ؆໿ͷॱং͕ҟͳΔݴޠ • ஗ԆධՁ͕ඪ४ͳݴޠ • λϓϧͷ͋Δݴޠ • ͳͲͳͲ !33

    Something else A language which has peculiar order of reducing A language which always use lazy evaluation A language which has tuple type And so on...
  34. ࠷ޙʹ • ੈքʹ͸༷ʑͳಛ௃Λ࣋ͭϓϩάϥϛϯάݴޠ͕͋Γ·͢ • ৭ʑͳϓϩάϥϛϯάݴޠΛֶΜͰੈքΛ޿͛·͠ΐ͏ʂ !34 Epilogue There are many

    distinctive programming languages in the world Let's learn those languages, and spread your world!
  35. !35 ൃද͸Ҏ্Ͱ͢ Let's enjoy programming. Thank you!