Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Implement beautiful DSL for iOS using Ruby
Search
Francis Chong
April 26, 2014
Programming
830
2
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Implement beautiful DSL for iOS using Ruby
At RubyConf Taiwan 2014 #ruby #rubyconftw
Francis Chong
April 26, 2014
More Decks by Francis Chong
See All by Francis Chong
Migrate to Swift 3
siuying
0
220
CocoaPods - A better way to use and publish open source project for Objective-C
siuying
2
400
Legco OpenData
siuying
0
150
EverClip - Evernote DEVCUP Meetup 2013 Hong Kong
siuying
0
110
iOS Development with Ruby using RubyMotion
siuying
1
210
Other Decks in Programming
See All in Programming
조합이폭발하는디자인시스템이걸눈으로도테스트하라고요
giljongyu
0
690
8年前のNode.jsを動かして分かった、npm installの裏側
keisukeikeda
0
120
Groovy as a human and AI friendly programming language
paulk
0
160
Lambda durable functionsでHuman in the Loopを楽に…楽に……
har1101
2
240
パスワード再設定メールのURLについて知っておこう
uyuki234
0
200
sbt 2.0: takeoff
eed3si9n
0
180
PumaからFalconに移行したRailsアプリケーションでの実践
falcon8823
0
320
React Native에 현대적인 빌드 도구 더하기: Rollipop 구현기
leegeunhyeok
0
180
AI主導のプログラミング学習アプリを作ってみた
econanringo
0
210
私なりのハーネスエンジニアリング ~独自の言語処理系の開発を通して~
seosoft
0
160
Python Lambdaにおけるテストしやすい設計とAI支援の活用 / Designing Testable Python Lambda Functions with AI
kitano_yuichi
1
270
学びを記事・スライド・Xへ高速展開する― AI-assisted Learning Loopで回すコンテンツ生成術
ochtum
0
180
Featured
See All Featured
HTML-Aware ERB: The Path to Reactive Rendering @ RubyCon 2026, Rimini, Italy
marcoroth
5
880
A Guide to Academic Writing Using Generative AI - A Workshop
ks91
PRO
1
550
XXLCSS - How to scale CSS and keep your sanity
sugarenia
250
1.3M
What does AI have to do with Human Rights?
axbom
PRO
1
2.5k
Heart Work Chapter 1 - Part 1
lfama
PRO
10
37k
The Hidden Cost of Media on the Web [PixelPalooza 2025]
tammyeverts
2
560
Groundhog Day: Seeking Process in Gaming for Health
codingconduct
0
450
Marketing to machines
jonoalderson
1
6k
Agile that works and the tools we love
rasmusluckow
331
22k
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
PRO
203
77k
Why Mistakes Are the Best Teachers: Turning Failure into a Pathway for Growth
auna
0
340
Game over? The fight for quality and originality in the time of robots
wayneb77
1
320
Transcript
Implement beautiful DSL for iOS using Ruby Francis Chong
About me
鍾振輝 Francis Chong @siuying
Indie Mobile Dev
Why DSL?
https://github.com/tzangms/iloveck101 “I love ck101.com” ! “… I just want the
pictures. But their site is slow, filled with ads and noise … ” @tzangms 海總理
None
None
People found this is a good idea!
• Go • https://github.com/wuman/go-ck101 • https://github.com/lazywei/iloveck101 • Ruby • https://github.com/wancw/iloveck101
• https://github.com/shunwen/iloveck101 • PHP • https://github.com/fukuball/iloveck101 • Objective-C • https://github.com/saiday/hornyfolks • https://github.com/siuying/iloveck101 • Node.js • https://github.com/clonn/iloveck101 • Groovy • https://github.com/tangblack/ groovy_ILoveCK101 • Racket • https://github.com/Domon/iloveck101 • JavaScript • https://github.com/poying/iloveck101 • GreaseMonekey • https://github.com/tomin/iloveck101
I made an iOS version too …
Can we generalize it?
Convert web sites into reusable data.
None
None
Goals • Keep existing code and tools • Add dynamic
behavior to a static app • Interact with native code • Simple to read and write
DSL
Domain Specific Language
–Martin Fowler “DSLs are small languages, focused on a particular
aspect of a software system.”
External & Internal DSL
How to implement DSL for iOS
Internal DSL with Objective-C / RubyMotion
Masonry https://github.com/cloudkite/Masonry
Moria https://github.com/siuying/moria
Kiwi https://github.com/allending/Kiwi
Parser generator like Bison, CoreParse or PEGKit
NUI https://github.com/tombenner/nui
mruby
objc-mruby example
JavaScriptCore
iOS 7.0
Bi-directional Bridge http://blog.bignerdranch.com/3784-javascriptcore-and-ios-7/
None
… but this is a Ruby conference?
Opal
Ruby to JavaScript Compiler http://opalrb.org/try/
Output
JavaScriptCore + Opal
Expose Native Classes to JS
Opal Wrapper for JS
Example
Goal: Convert web sites into reusable data.
Designing the DSL
1. Write an imaginary DSL
2. Make it valid
3. Make it work
4. Add more use case
Everything
http://cl.ly/3Y1y0N3y2J1V
Now we’ve supported one site
Let’s add more!
None
http://cl.ly/0R0k0t1x2v2r
Users could change the code themselves
Add sites without recompile
Practical Tips
JavaScriptCoreOpalAdditions
Compile Opal in Runtime
IGJavaScriptConsole
Interactive Console
Rake and sprockets
Gemfile
Rakefile
Integrate the project into Xcode
Custom Build Phase
Add build task to project
Pros and Cons
Based on features in iOS SDK
Dynamic behavior
Interaction with native code.
Easy to read and write.
One more layer of indirection.
–App Store Review Guidelines “Apps that download code in any
way or form will be rejected.”
Readings
http://www.duokan.com/book/43469
http://www.amazon.com/gp/product/0321712943
Question?