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
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
Francis Chong
April 26, 2014
Programming
2
790
Implement beautiful DSL for iOS using Ruby
At RubyConf Taiwan 2014 #ruby #rubyconftw
Francis Chong
April 26, 2014
Tweet
Share
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
380
Legco OpenData
siuying
0
140
EverClip - Evernote DEVCUP Meetup 2013 Hong Kong
siuying
0
95
iOS Development with Ruby using RubyMotion
siuying
1
180
Other Decks in Programming
See All in Programming
AHC061解説
shun_pi
0
370
モジュラモノリスにおける境界をGoのinternalパッケージで守る
magavel
0
3.5k
ロボットのための工場に灯りは要らない
watany
10
2.8k
エンジニアの「手元の自動化」を加速するn8n 2026.02.27
symy2co
0
150
エージェント開発初心者の僕がエージェントを作った話と今後やりたいこと
thasu0123
0
240
株式会社 Sun terras カンパニーデック
sunterras
0
2.1k
encoding/json/v2のUnmarshalはこう変わった:内部実装で見る設計改善
kurakura0916
0
410
モックわからないマン卒業記 ~振る舞いを起点に見直した、フロントエンドテストにおけるモックの使いどころ~
tasukuwatanabe
2
270
AI時代のソフトウェア開発でも「人が仕様を書く」から始めよう-医療IT現場での実践とこれから
koukimiura
0
150
Claude Codeセッション現状確認 2026福岡 / fukuoka-aicoding-00-beacon
monochromegane
4
420
Agent Skills Workshop - AIへの頼み方を仕組み化する
gotalab555
15
8.7k
野球解説AI Agentを開発してみた - 2026/02/27 LayerX社内LT会資料
shinyorke
PRO
0
280
Featured
See All Featured
Mozcon NYC 2025: Stop Losing SEO Traffic
samtorres
0
170
Evolving SEO for Evolving Search Engines
ryanjones
0
150
The MySQL Ecosystem @ GitHub 2015
samlambert
251
13k
A Tale of Four Properties
chriscoyier
163
24k
Building a Modern Day E-commerce SEO Strategy
aleyda
45
8.9k
The Limits of Empathy - UXLibs8
cassininazir
1
260
Accessibility Awareness
sabderemane
0
80
The Impact of AI in SEO - AI Overviews June 2024 Edition
aleyda
5
760
The B2B funnel & how to create a winning content strategy
katarinadahlin
PRO
1
300
The AI Search Optimization Roadmap by Aleyda Solis
aleyda
1
5.4k
Noah Learner - AI + Me: how we built a GSC Bulk Export data pipeline
techseoconnect
PRO
0
130
Practical Orchestrator
shlominoach
191
11k
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?