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

Rubyから世界へ / Let’s start a journey around the wo...

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

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

Yuya Kato

April 02, 2019
Tweet

More Decks by Yuya Kato

Other Decks in Programming

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. ໨࣍ • ͜ͷ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
  4. ͜ͷ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
  5. ͜ͷ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
  6. ͍Ζ͍Ζͳʮݴޠʯ !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.
  7. ύϥμΠϜʹΑΔ෼ྨ !12 Paradigms ໋ྩܕݴޠʢखଓ͖ܕݴޠʣ Ruby એݴܕݴޠ ؔ਺ܕݴޠ Haskell ࿦ཧܕݴޠ Prolog

    C/C++ LISP Idris Scala ७ਮ ඇ७ਮ Java ͦͷଞɺଟ͘ͷݴޠ Imperative (Procedural) Declarative Functional Purely Not purely Logic Python And many other languages
  8. ந৅౓ʹΑΔ෼ྨ !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.
  9. ܕ෇͚ʹΑΔ෼ྨ !14 ڧ͍ܕ෇͚ ऑ͍ܕ෇͚ ಈతͳܕ෇͚ ੩తͳย෇͚ Ruby C/C++ Java Haskell

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

    LabVIEW Simulink Text or Visual And most other languages Text programming lang. Visual programming lang.
  11. Πϯσϯτʹҙຯ͕͋Δ/ͳ͍ !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
  12. ۩ମྫ: Πϯσϯτ !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
  13. 1࣍ݩ/2࣍ݩ !19 1࣍ݩͳݴޠ 2࣍ݩͳݴޠ Befunge Ruby Haskell C/C++ Java 1

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

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

    Using parentheses a lot, or not And most other languages Using parentheses a lot Using parentheses moderately
  16. ۩ମྫ: 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:
  17. ݟ͑Δ/ݟ͑ͳ͍ !23 ݟ͑Δʢҹ࡮Ͱ͖Δʣݴޠ ݟ͑ͳ͍ʢҹ࡮Ͱ͖ͳ͍ʣݴޠ Whitespace Ruby Haskell C/C++ Java Visible,

    or not Visible (printable) Invisible (not printable) ͦͷଞɺ΄ͱΜͲͷݴޠ And most other languages
  18. ۩ମྫ: 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
  19. Ϋϥεϕʔε/ϓϩτλΠϓϕʔε !26 ΫϥεϕʔεΦϒδΣΫτࢦ޲ ϓϩτλΠϓϕʔεΦϒδΣΫτࢦ޲ JavaScript Ruby C++ Smalltalk Self Lua

    Io Class-based object-oriented, or prototype-based one Class-based object-oriented Prototype-based object-oriented
  20. ίϯύΠϧͷ༗ແ !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
  21. σʔλͷॴ༗ݖͷ༗ແ !28 ॴ༗ݖ͕͋Δݴޠ ॴ༗ݖ͕ͳ͍ݴޠ Rust Ruby Haskell C/C++ Java Incorporate

    data with ownership, or not ͦͷଞɺ΄ͱΜͲͷݴޠ And most other languages Has ownership system Hasn't ownership system
  22. ۩ମྫ: ॴ༗ݖ !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
  23. νϡʔϦϯά׬શੑ͋Γ/ͳ͠ !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.
  24. ϧʔϓจͷ༗ແ !31 ϧʔϓͷ͋Δݴޠ ϧʔϓͷͳ͍ݴޠ Ruby Haskell C/C++ Java Has loop

    statement, or not Has loop statement Hasn't loop statement ͦͷଞɺ΄ͱΜͲͷݴޠ And most other languages
  25. ม਺΁ͷ࠶୅ೖͷՄ൱ !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
  26. ଞʹ΋ • ؆໿ͷॱং͕ҟͳΔݴޠ • ஗ԆධՁ͕ඪ४ͳݴޠ • λϓϧͷ͋Δݴޠ • ͳͲͳͲ !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...