Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
RailsとYesodの比較
Search
Fujimura Daisuke
April 21, 2012
Programming
3
2.5k
RailsとYesodの比較
Fujimura Daisuke
April 21, 2012
Tweet
Share
More Decks by Fujimura Daisuke
See All by Fujimura Daisuke
庭と負債
fujimura
4
1.1k
AIの時代で我々はどのようにコードを書くのか
fujimura
3
850
SaaSを作るという仕事について
fujimura
12
5.7k
一文字エイリアスのすすめ
fujimura
0
330
現役CTOが語る!RubyKaigiの楽しみ方
fujimura
0
1.2k
いかにして文系新卒エンジニアが「大きな問い」を大事にするCTOになったのか
fujimura
2
670
Kaigi on Rails 2022 - 既存Railsアプリ攻略法 CTOが見ること・やること・考えること
fujimura
14
3.9k
SimpleDelegator活用のご提案
fujimura
0
1.5k
入門 名前
fujimura
24
14k
Other Decks in Programming
See All in Programming
The Efficiency Paradox and How to Save Yourself and the World
hollycummins
1
440
複雑な仕様に立ち向かうアーキテクチャ
myohei
0
170
Stackless и stackful? Корутины и асинхронность в Go
lamodatech
0
640
SymfonyCon Vienna 2025: Twig, still relevant in 2025?
fabpot
3
1.2k
テストケースの名前はどうつけるべきか?
orgachem
PRO
0
130
これが俺の”自分戦略” プロセスを楽しんでいこう! - Developers CAREER Boost 2024
niftycorp
PRO
0
190
プロダクトの品質に コミットする / Commit to Product Quality
pekepek
2
770
range over funcの使い道と非同期N+1リゾルバーの夢 / about a range over func
mackee
0
110
今年のアップデートで振り返るCDKセキュリティのシフトレフト/2024-cdk-security-shift-left
tomoki10
0
190
Jakarta EE meets AI
ivargrimstad
0
230
Haze - Real time background blurring
chrisbanes
1
500
アクターシステムに頼らずEvent Sourcingする方法について
j5ik2o
4
180
Featured
See All Featured
Making the Leap to Tech Lead
cromwellryan
133
9k
Rails Girls Zürich Keynote
gr2m
94
13k
What’s in a name? Adding method to the madness
productmarketing
PRO
22
3.2k
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
0
94
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
127
18k
Testing 201, or: Great Expectations
jmmastey
40
7.1k
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
132
33k
How To Stay Up To Date on Web Technology
chriscoyier
789
250k
Navigating Team Friction
lara
183
15k
A Philosophy of Restraint
colly
203
16k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
95
17k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
26
1.5k
Transcript
RailsͱYesodͷൺֱ ౻ଜେհ Sunday, April 22, 12
ࣗݾհ • ౻ଜେհ • גࣜձࣾAiming • @ffu_ • http://fujimuradaisuke.com Sunday,
April 22, 12
ࣗݾհ (2) Rubyͱࢲ • ੲABAPerͩͬͨɻ·ͱͳݴޠ͕Γͨ͘ͳΓRubyʹస • ͔Ε͜Ε3͘Β͍ϑϧλΠϜͰRailsͷࣄΛͯ͠Δ • Railsίϛολ @a_matsuda
ࣄͯ͠Rails෦ʹ͚ͬ͜͏ৄ͘͠ͳͬͨ • WEB+DB PRESSͷRails3ಛूΛͪΐͬͱखͬͨ • Railsͷ࡞ऀɺDHHͱ൴ͷಇ͘37signalsͷϑΝϯ Sunday, April 22, 12
ࣗݾհ (3) Haskellͱࢲ • The Little SchemerͰؔϓϩάϥϛϯάΛΔ • Seven Languages
in Seven WeeksͰHaskellΛΔ • ελʔτHaskellͰຊ֨తʹHaskell͕͖ʹͳΔ • ݱࡏɺձࣾͰYesodΛࢼݧతʹಋೖத Sunday, April 22, 12
ΞδΣϯμ • Railsʹ͋ͬͯYesodʹͳ͍ͷհ • Rails͍͔ΒݟͨYesod(ͱHaskell)ͷ͍͍ͱ͜Ζ • Yesodʹཉ͍͠ͷհ Sunday, April 22,
12
Yesodʹͳ͍ͷ(1) σϓϩΠπʔϧ • RailsʹCapistranoͱ͍͏σϓϩΠࣗಈԽπʔϧ͕͋Γ·͢ɻ • $ cap deploy ͰσϓϩΠ •
$ cap deploy:rollbackͰલճσϓϩΠͨ͠ίʔυʹϩʔϧόοΫ • ͦͷଞɺSSHͰೖͬͯσϓϩΠ࣌ʹߦ͏࡞ۀͷࣗಈԽҰൠ͕ՄೳͰ͢ɻ • https://github.com/capistrano/capistrano/wiki/2.x-Getting-Started Sunday, April 22, 12
Yesodʹͳ͍ͷ(1) σϓϩΠπʔϧ • cabal-dev ΛͬͨΒͰ͖·ͨ͠… • ͨͩ͠ຖճશґଘϥΠϒϥϦΛΠϯετʔϧ͢ΔͷͰ͕͔͔࣌ؒΔ • ͦͦHaskellerͱͯ͠ʮRubyͷπʔϧΛ͏ʯͰOKͳͷ͔ʁ Sunday,
April 22, 12
Yesodʹͳ͍ͷ(2) CRUDͷੜ • RailsscaffoldͰCRUD͕Ͱ͖Δίʔυ͕ੜ͞Ε·͢ɻ • ͜ͷҐͷίʔυ͕ ੜ͞ΕΔ • RailsྲྀͷRESTfulͳϧʔςΟϯάʹԊͬͨίʔυ͕ੜ͞ΕΔͷͰɺͦΕΛݩ ʹ։ൃ͍ͯ͠ΕɺࣗવͱRailsతͳΘ͔Γ͍͢ίʔυʹͳΓ·͢ɻ
• ࣗવͱRails wayͰ։ൃ͢Δ͜ͱʹͳΔͷͰɺ·ͳ͍ͰࡁΉͱ͍͏རɻ • YesodͰ·ͣ։ൃΛਐΊΒΕΔఔʹscaffoldͰίʔυΛੜͯ͠΄͠ ͍ɻ Sunday, April 22, 12
Yesodʹͳ͍ͷ(3) RSpec • ΄΅σϑΥϧτ࠾༻͞ΕͯΔςετϑϨʔϜϫʔΫɻ • ಈ࡞ݕূͰͳ͘ιϑτΣΞͷʮৼΔ͍ʯΛܾΊΔͨΊͷϥΠϒϥϦ • http://jp.rubyist.net/magazine/?0021-Rspec ʹ֓ཁ͕·ͱ·ͬͯ·͢ɻ •
rspec-railsͱ͍͏ϥΠϒϥϦͰRailsͷςετ͕ܹ͘͠ੜ࢈తʹͳΓ·͢ɻ • ͦͷଞपลϥΠϒϥϦଟɻ Sunday, April 22, 12
ͳͥRSpec͕ཉ͍͔͠ • RSpecઃܭπʔϧͱͯ͠ຊʹ༏लɻ·ͣSpecΛεέονײ֮Ͱॻ͍ͯҰ ୴ઃܭΛจষԽ͢ΔͱɺAPIશମ͕ݟ௨ͤΔΑ͏ʹͳΓ·͢ɻ͜͜Ͱઃܭͷྑ ͠ѱ͠Λݕ౼Ͱ͖ΔͷૉΒ͍͠Ͱ͢ɻ ͜Μͳ۩߹ʹઃܭΛઌʹॻ͘ ࣮ߦ͢Δͱ“PENDING” Sunday, April 22,
12
ͳͥRSpec͕ཉ͍͔͠ • request specཉ͍͠Ͱ͢ɻrequest specSeleniumͳͲͰ࣮ࡍʹΞϓϦέʔ γϣϯΛಈ͔ͯ͠ɺϑϩϯτΤϯυ͔ΒΞϓϦέʔγϣϯΛݕࠪ͢Δ Έɻclick_link(‘#submit-button’)ͱ͍ͬͨײ͡ͰखಈͰ͍ͯͨ͠ಈ࡞֬ೝΛࣗ ಈԽͰ͖·͢ɻ • ਅʹॻ͘ͱɺ࣮ߦՄೳͳड͚ೖΕςετܭըॻʹͳΓ·͢ɻ
• ෳͷػೳΛ·͙ͨγφϦΦςετ͕ॻ͖͍͢ɻ • ͜͜ɺRails͜ͷϨΠϠʔ·Ͱςετ͢Δͷ͕σϑΥϧτɻ Sunday, April 22, 12
ͳ͍ͷ(3) RSpec • ͪͳΈʹHaskellͰhspecͱ͍͏RSpecతͳϥΠϒϥϦ͕͋Γ·͢ɻ • http://hspec.github.com/ • ࠷ۙ1.1ʹͳΓ·ͨ͠ʂ • ͔͠͠ɺdescribe/contextͷೖΕࢠͰ͖ͳ͍͠ɺsetup/teardownແ͍͠ɺ
RSpecʹࣅͨߏจͷxUnitͱ͍͏ͷ͕࣮…ɻ • ࠓޙʹظɻ Sunday, April 22, 12
Rails͍͔ΒݟͨYesod(ͱHaskell)ͷ͍͍ͱ͜Ζ • NullPointerException͕ແ͍ʂ • ܕΛ͋ΘͤΔͱ͍͍ͩͨظ௨Γʹಈ͘ • undefinedΛ͏ͱςετίʔυͳ͠ͰBDDͬΆ͍͜ͱ͕Ͱ͖Δ • ى͜Γ͏Δ͜ͱΛશ෦ߟྀ͠ͳ͍ͱ͍͚ͳ͍ͷͰɺఆΕͷόά͕ͳ͘ͳ Δ
• ΞυϗοΫଟ૬͕RubyͷMix-inͱࣅ͍ͯΔͷͰ͠Έ͍͢ Sunday, April 22, 12
Yesodʹཉ͍͠ͷ(1) • ϏδωεϩδοΫΛهड़͢ΔͨΊͷϥΠϒϥϦ • PersistentΑΓ͏ͪΐͬͱநߴ͍هड़͕͍ͨ͠Ͱ͢ɻ • RailsͰActiveRecordͰϢʔβʔͷϝϯλϧϞσϧʹ͍ۙܗͷදݱ͕Ͱ͖ ͨɻ • ͱ͍ͬͯORϚούʔΛ࡞Δͷҧ͍·͢ΑͶɻDCI
͕ࢀߟʹͳΔؾ͕͠ ͍ͯ·͢ɻ • ࡞ͬͯΈ͍ͨͰ͢ɻ Sunday, April 22, 12
Yesodʹཉ͍͠ͷ(2) • Yesod way • RailsʹϨʔϧ͕͋ͬͯɺͦΕʹΕΔɻ • DHHᐌ͘ʮConstraints are liberatingʯ
• ࠓͷͱ͜ΖYesodʹϨʔϧ͕ݟͨΒͳ͍ɻ Sunday, April 22, 12
͓ΘΓ • ए͍ϥΠϒϥϦͳͷͰɺࠓޙʹظͰ͢ Sunday, April 22, 12
༨ஊ • ςϯϓϨʔτΤϯδϯͷ…ʁ • ձࣾͰ࡞ͬͯΔͷJSON APIͳͷͰɺ৮ͬͯͳ͍ΜͰ͢ɻ • ͠ΔͳΒmustacheΛ͏ͱࢥ͍·͢ɻShakespearean Templatesϑ ϩϯτΤϯυͷਓͱͷίϥϘϨʔγϣϯ͕ͦ͠͏ͳҹͰ͢ɻ
• scottyؾʹͳͬͯ·͢ • Web API࡞ΔͷͰ͋Εͬͪ͜ͷ΄͏͕खܰͦ͏ Sunday, April 22, 12