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
Implement beautiful DSL for iOS using Ruby
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
Francis Chong
April 26, 2014
Programming
810
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
210
CocoaPods - A better way to use and publish open source project for Objective-C
siuying
2
390
Legco OpenData
siuying
0
140
EverClip - Evernote DEVCUP Meetup 2013 Hong Kong
siuying
0
98
iOS Development with Ruby using RubyMotion
siuying
1
200
Other Decks in Programming
See All in Programming
LLMによるContent Moderationの本番運用の裏側と品質担保への挑戦
suikabar
3
780
スマートグラスで並列バイブコーディング
hyshu
0
260
キャリア迷子上等 ─ "ない道"は自分で作ればいい
16bitidol
3
2.3k
エンジニア向け会社紹介/Findy Company Profile
findyinc
6
350k
ローカルLLMでどこまでコードが書けるか -拡張版 / How much code can be written on a local LLM Extended
kishida
12
4.4k
「なぜそう決めたのか」を残し続ける仕組み ― Notion AI カスタムエージェント × Slack連携による設計判断の自動記録 - NIKKEI Tech Talk #47
niftycorp
PRO
0
230
IBM Bobを活用したレガシーアプリの最新化
oniak3ibm
PRO
1
220
AI 輔助遺留系統現代化的經驗分享
jame2408
1
1k
Dataformのリポジトリを立ち上げるときにまずやること / dataform-day0-2026
snhryt
0
190
TSKaigi Night Talks 2026_TypeScriptでサプライチェーンの整合性を型に閉じ込める
geekplus_tech
0
410
Signal Forms: Details & Live Coding @enterJS 2026 in Mannheim
manfredsteyer
PRO
0
190
フロントエンドとバックエンドで「1文字」を揃えよう
youkidearitai
PRO
0
750
Featured
See All Featured
What the history of the web can teach us about the future of AI
inesmontani
PRO
1
620
HU Berlin: Industrial-Strength Natural Language Processing with spaCy and Prodigy
inesmontani
PRO
0
420
Marketing to machines
jonoalderson
1
5.5k
Navigating Weather and Climate Data
rabernat
0
240
Agile Leadership in an Agile Organization
kimpetersen
PRO
0
170
End of SEO as We Know It (SMX Advanced Version)
ipullrank
3
4.2k
Impact Scores and Hybrid Strategies: The future of link building
tamaranovitovic
0
310
AI in Enterprises - Java and Open Source to the Rescue
ivargrimstad
0
1.3k
The AI Search Optimization Roadmap by Aleyda Solis
aleyda
1
5.9k
Leading Effective Engineering Teams in the AI Era
addyosmani
9
2.1k
Building a Scalable Design System with Sketch
lauravandoore
463
34k
Applied NLP in the Age of Generative AI
inesmontani
PRO
4
2.3k
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?