Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Rubyはとても「人間的」

5,205 views

Published on

第97回 IWDDで発表したLTです。
http://www.iwdd.net/

Published in: Software
  • Follow the link, new dating source: ♥♥♥ http://bit.ly/369VOVb ♥♥♥
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • Sex in your area is here: ♥♥♥ http://bit.ly/369VOVb ♥♥♥
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • DOWNLOAD THIS BOOKS INTO AVAILABLE FORMAT (Unlimited) ......................................................................................................................... ......................................................................................................................... Download Full PDF EBOOK here { https://tinyurl.com/yyxo9sk7 } ......................................................................................................................... Download Full EPUB Ebook here { https://tinyurl.com/yyxo9sk7 } ......................................................................................................................... ACCESS WEBSITE for All Ebooks ......................................................................................................................... Download Full PDF EBOOK here { https://tinyurl.com/yyxo9sk7 } ......................................................................................................................... Download EPUB Ebook here { https://tinyurl.com/yyxo9sk7 } ......................................................................................................................... Download doc Ebook here { https://tinyurl.com/yyxo9sk7 } ......................................................................................................................... ......................................................................................................................... ......................................................................................................................... .............. Browse by Genre Available eBooks ......................................................................................................................... Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, Cookbooks, Crime, Ebooks, Fantasy, Fiction, Graphic Novels, Historical Fiction, History, Horror, Humor And Comedy, Manga, Memoir, Music, Mystery, Non Fiction, Paranormal, Philosophy, Poetry, Psychology, Religion, Romance, Science, Science Fiction, Self Help, Suspense, Spirituality, Sports, Thriller, Travel, Young Adult,
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • DOWNLOAD THIS BOOKS INTO AVAILABLE FORMAT (Unlimited) ......................................................................................................................... ......................................................................................................................... Download Full PDF EBOOK here { https://tinyurl.com/yyxo9sk7 } ......................................................................................................................... Download Full EPUB Ebook here { https://tinyurl.com/yyxo9sk7 } ......................................................................................................................... ACCESS WEBSITE for All Ebooks ......................................................................................................................... Download Full PDF EBOOK here { https://tinyurl.com/yyxo9sk7 } ......................................................................................................................... Download EPUB Ebook here { https://tinyurl.com/yyxo9sk7 } ......................................................................................................................... Download doc Ebook here { https://tinyurl.com/yyxo9sk7 } ......................................................................................................................... ......................................................................................................................... ......................................................................................................................... .............. Browse by Genre Available eBooks ......................................................................................................................... Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, Cookbooks, Crime, Ebooks, Fantasy, Fiction, Graphic Novels, Historical Fiction, History, Horror, Humor And Comedy, Manga, Memoir, Music, Mystery, Non Fiction, Paranormal, Philosophy, Poetry, Psychology, Religion, Romance, Science, Science Fiction, Self Help, Suspense, Spirituality, Sports, Thriller, Travel, Young Adult,
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • DOWNLOAD THIS BOOKS INTO AVAILABLE FORMAT (Unlimited) ......................................................................................................................... ......................................................................................................................... Download Full PDF EBOOK here { https://tinyurl.com/yyxo9sk7 } ......................................................................................................................... Download Full EPUB Ebook here { https://tinyurl.com/yyxo9sk7 } ......................................................................................................................... ACCESS WEBSITE for All Ebooks ......................................................................................................................... Download Full PDF EBOOK here { https://tinyurl.com/yyxo9sk7 } ......................................................................................................................... Download EPUB Ebook here { https://tinyurl.com/yyxo9sk7 } ......................................................................................................................... Download doc Ebook here { https://tinyurl.com/yyxo9sk7 } ......................................................................................................................... ......................................................................................................................... ......................................................................................................................... .............. Browse by Genre Available eBooks ......................................................................................................................... Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, Cookbooks, Crime, Ebooks, Fantasy, Fiction, Graphic Novels, Historical Fiction, History, Horror, Humor And Comedy, Manga, Memoir, Music, Mystery, Non Fiction, Paranormal, Philosophy, Poetry, Psychology, Religion, Romance, Science, Science Fiction, Self Help, Suspense, Spirituality, Sports, Thriller, Travel, Young Adult,
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here

Rubyはとても「人間的」

  1. 1. Rubyはとても 「人間的」 2014年11月8日 第97回 IWDD 株式会社ハートレイルズ 芹沢和洋
  2. 2. 自己紹介 @seri_k Kazuhiro Serizawa web engineer
  3. 3. Work at http://www.heartrails.com/
  4. 4. Remote Worker
  5. 5. 概要 • Rubyとの出会い • Ruby is 人間的言語
  6. 6. Rubyとの出会い http://anond.hatelabo.jp/20100916072052
  7. 7. 当時の認識 Ruby.is_ネタ言語? #true
  8. 8. Rubyに興味を持った エントリー 残念ながら現在はリンク切れ… うろ覚えですがRubyは楽しく人間的に書ける! という内容だった気がする…
  9. 9. Rubyに興味を持った エントリー 当時の私のはてブコメント
  10. 10. times for (i = 0; i < 10; i ++){ hoge() } while(true){ if(i => 10)break; hoge(); i++; } 10.times {hoge()}
  11. 11. どっちが分かりやすい? for (i = 0; i < 10; i ++){ hoge() 10回hoge()を } 実行したい 10.times { hoge() }
  12. 12. 因みに • 1から10まで順番に引数を渡して実行する → 1.upto(10) { |i| hoge(i) } • 10から1まで順番に引数を渡して実行する →10.downto { |i| hoge(i) } • 1..10の範囲で実行する →(1..10).each{ hoge() }
  13. 13. これを見て自分は こう思ったッス Rubyは人間的だ!
  14. 14. 人間的とは • 人間が「こうしたい」と思う「こうしたい」の文脈をその まま実装に落とせるので「人間的」と思った (私がそう思っただけで一般的な名称ではありませんw) • プログラミング言語の都合に合わせて変換する手間が少な い • 人間は「同じ処理を10回やりたい」と思った時に「1回 処理を実行する度に数値を0から1ずつ増やして数値が9 になるまで繰り返す」とは考えない
  15. 15. Arrayも人間的 • 要素の順番を ひっくり返したい! • 指定の要素が 含まれているか 知りたい! • 重複を排除したい! Array#reverse Array#include?({要素}) Array#uniq
  16. 16. Arrayも人間的 [1,2,3,4,5].reverse #=> [5,4,3,2,1] [1,2,3,4,5].include?(1) #=> true [1,1,1,2,3,4].uniq #=> [1,2,3,4]
  17. 17. Rubyの便利ライブラリ ActiveSupportの例 • Time#today? →今日だったらtrue, そうじゃなかったらfalse • Time#next_week→来週の月曜日の0:00分のTimeオ ブジェクトを返す • Time#weeks_ago(week) / Time#days_ago(day) →X週間前、X日前の日付のTimeオブジェクトを返す
  18. 18. 結果 自主規制w まつもとゆきひろ氏(Ruby作者)曰く 「Rubyをキメると気持ちいい!」
  19. 19. 他にも人間的に書ける要素 • 他の言語と比べてカッコをかなり省略できる print(‘Hello world’) print ‘Hello world’ def say(message) def say message print(message) print message end end
  20. 20. 他にも人間的に書ける要素 • カッコを省略すると自然言語っぽい! print ‘Hello world’ 『「Hello World」と表示しろ!』 と言っているように読めません? 『「ふなっしー!」と言え!』 と言っているように読めません? say ‘ふなっしー!’
  21. 21. 自然言語のように読める!ということで DSLを定義するに使われる事が多い • 例:chefのレシピ # /tmp/dirの権限とオーナーを変更する remote_directory "/tmp/dir" do source "tmpdir" owner "apache" group "apache" mode "0755" end
  22. 22. Ruby on Railsの例 class Product < ActiveRecord::Base has_many :product_categories end • “has_many”は内部的にはDBの リレーションを定義する為のメソッド • has_many {テーブル名}と書くことでproductsとい うテーブルがproduct_categoriesというテーブル を複数所有している関係(has-many)だと読める
  23. 23. まとめ • Rubyはとても人間的で書いてて気持ちいい言語 • 「Rubyをキメると気持ちいい!」はマジだった • なのでRubyやりましょう!

×