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
860
SaaSを作るという仕事について
fujimura
12
5.8k
一文字エイリアスのすすめ
fujimura
0
340
現役CTOが語る!RubyKaigiの楽しみ方
fujimura
0
1.2k
いかにして文系新卒エンジニアが「大きな問い」を大事にするCTOになったのか
fujimura
2
680
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
アクターシステムに頼らずEvent Sourcingする方法について
j5ik2o
6
490
Zoneless Testing
rainerhahnekamp
0
130
非ブラウザランタイムとWeb標準 / Non-Browser Runtimes and Web Standards
petamoriken
0
380
CQRS+ES の力を使って効果を感じる / Feel the effects of using the power of CQRS+ES
seike460
PRO
0
210
create_tableをしただけなのに〜囚われのuuid編〜
daisukeshinoku
0
310
React 19でお手軽にCSS-in-JSを自作する
yukukotani
5
470
これでLambdaが不要に?!Step FunctionsのJSONata対応について
iwatatomoya
2
3.9k
DevFest - Serverless 101 with Google Cloud Functions
tunmise
0
130
良いユニットテストを書こう
mototakatsu
11
3.4k
Scalaから始めるOpenFeature入門 / Scalaわいわい勉強会 #4
arthur1
1
360
CloudflareStack でRAGに入門
asahiiwm
0
140
「Chatwork」Android版アプリを 支える単体テストの現在
okuzawats
0
190
Featured
See All Featured
Build The Right Thing And Hit Your Dates
maggiecrowley
33
2.4k
Facilitating Awesome Meetings
lara
50
6.2k
The Language of Interfaces
destraynor
155
24k
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
226
22k
Rebuilding a faster, lazier Slack
samanthasiow
79
8.7k
Site-Speed That Sticks
csswizardry
2
200
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
3
310
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
29
2.3k
Measuring & Analyzing Core Web Vitals
bluesmoon
5
190
Optimising Largest Contentful Paint
csswizardry
33
3k
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
251
21k
Designing for humans not robots
tammielis
250
25k
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