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
990
AIの時代で我々はどのようにコードを書くのか
fujimura
3
770
SaaSを作るという仕事について
fujimura
12
5.7k
一文字エイリアスのすすめ
fujimura
0
320
現役CTOが語る!RubyKaigiの楽しみ方
fujimura
0
1.2k
いかにして文系新卒エンジニアが「大きな問い」を大事にするCTOになったのか
fujimura
2
660
Kaigi on Rails 2022 - 既存Railsアプリ攻略法 CTOが見ること・やること・考えること
fujimura
14
3.9k
SimpleDelegator活用のご提案
fujimura
0
1.5k
入門 名前
fujimura
23
13k
Other Decks in Programming
See All in Programming
watsonx.ai Dojo #4 生成AIを使ったアプリ開発、応用編
oniak3ibm
PRO
1
190
Jakarta EE meets AI
ivargrimstad
0
230
Kaigi on Rails 2024 〜運営の裏側〜
krpk1900
1
260
Micro Frontends Unmasked Opportunities, Challenges, Alternatives
manfredsteyer
PRO
0
110
Nurturing OpenJDK distribution: Eclipse Temurin Success History and plan
ivargrimstad
0
1.1k
cmp.Or に感動した
otakakot
3
240
Contemporary Test Cases
maaretp
0
140
イマのCSSでできる インタラクション最前線 + CSS最新情報
clockmaker
4
2.2k
RubyLSPのマルチバイト文字対応
notfounds
0
120
Why Jakarta EE Matters to Spring - and Vice Versa
ivargrimstad
0
1.2k
Hotwire or React? ~アフタートーク・本編に含めなかった話~ / Hotwire or React? after talk
harunatsujita
1
120
React への依存を最小にするフロントエンド設計
takonda
14
3.9k
Featured
See All Featured
Being A Developer After 40
akosma
87
590k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
665
120k
Testing 201, or: Great Expectations
jmmastey
38
7.1k
Designing for humans not robots
tammielis
250
25k
Building Flexible Design Systems
yeseniaperezcruz
327
38k
How To Stay Up To Date on Web Technology
chriscoyier
788
250k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
42
9.2k
GraphQLとの向き合い方2022年版
quramy
43
13k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
26
2.1k
No one is an island. Learnings from fostering a developers community.
thoeni
19
3k
Fontdeck: Realign not Redesign
paulrobertlloyd
82
5.2k
[RailsConf 2023] Rails as a piece of cake
palkan
52
4.9k
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