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
Forth in Node
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
Zoom.Quiet
September 03, 2013
Programming
220
2
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Forth in Node
[符式協會:4759] Node.js hosts umbilical FORTH
Zoom.Quiet
September 03, 2013
More Decks by Zoom.Quiet
See All by Zoom.Quiet
PyCon2014China-Zhuhai-high performance
zoomquiet
0
220
PyCon2014China-Zhuhai-meta programming
zoomquiet
1
190
PyCon2014China-Zhuhai-bpm.py
zoomquiet
0
160
PyCon2014China-Zhuhai-luna kv db
zoomquiet
0
170
PyCon2014China-Zhuhai-seed studio
zoomquiet
0
170
PyCon2014China-Zhuhai-Docker Registry Build By Python
zoomquiet
0
180
PyCon2014China-Zhuhai-jeff
zoomquiet
0
160
PyCon2014China-Zhuhai-pythonic front-end
zoomquiet
0
220
DevFest2014-Zhuhai-Polymer
zoomquiet
0
510
Other Decks in Programming
See All in Programming
現場と育てるRailsモデリング 〜Spreadsheetから始めたモデル設計〜
siroemk
2
1.2k
선언형 햅틱 라이브러리 진동을 소개합니다
l2hyunwoo
1
300
GraphQL の onError と Nullability のこれから
quramy
0
210
作れるエンジニアから、価値を届けるエンジニアへ
ryunakayama
1
240
AmebaブログはKMPから卒業します
kmars0605
0
340
SODA - FACT BOOK(JP)
sodainc
1
40k
クラウドエージェントは、 何がそんなに便利なのか / what makes cloud agents so useful
rkaga
5
810
複数ドメインを一つのアプリに統合するFlutterの設計と運用_FlutterKaigi2026登壇資料(須永高弘)
takahirosunaga
0
160
エージェントを使い続けるためのメタワーク / Meta-work for keeping using the agent
rkaga
6
2.2k
Herb in Rails 8.2: Your ERB views, now HTML-aware @ Kaigi on Rails 2026, Tokyo, Japan
marcoroth
2
420
Materialが消えた日 〜真っ白なFlutterキャンバスにRenderObjectで絵を描く〜
umigishiaoi
0
150
Web3Dライブラリを作ってVue Custom Rendererの仕組みを理解しよう / lets learn vue custom renderer by making 3d library
drumath2237
1
130
Featured
See All Featured
Skip the Path - Find Your Career Trail
mkilby
1
290
Evolving SEO for Evolving Search Engines
ryanjones
0
360
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
50
10k
The Hidden Cost of Media on the Web [PixelPalooza 2025]
tammyeverts
2
570
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
508
140k
Joys of Absence: A Defence of Solitary Play
codingconduct
1
570
Organizational Design Perspectives: An Ontology of Organizational Design Elements
kimpetersen
PRO
1
880
It's Worth the Effort
3n
188
29k
Fashionably flexible responsive web design (full day workshop)
malarkey
409
67k
Ecommerce SEO: The Keys for Success Now & Beyond - #SERPConf2024
aleyda
1
2.2k
Stop Working from a Prison Cell
hatefulcrawdad
274
21k
Exploring the relationship between traditional SERPs and Gen AI search
raygrieselhuber
PRO
4
4.4k
Transcript
Node.js to host Umbilical FORTH 吳政昌 動程科技 2013/08/31
想一想 如何為遠在火星的好奇號開發程式?
臍帶式開發環境 • 整個開發環境分成 Host 端和 Target 端 • 開發工具在 Host
端。 • 透過通訊功能以及簡單的幾個指令,開發、測 試並執行 Target 端上的軟體。 • 經典:A 3-INSTRUCTION FORTH http://utoh. org/3ins4th.html • 只需要三個指令:XC@, XC!, XCALL • Host 和 Target 端都是 FORTH 系統
舊愛:FORTH,1984 • 裝置端,很適合用於控制設備 • 2-Stack Virtual machine • Operating system
• Scripting language • Cooperative multitasking • Asynchrounous programming • 於被用於 Open firmware (Mac), Actionscript • 一個人就可以理解、掌握
新歡:Javascript, Node.js, 2013 • 雲端 • Asynchronous programming • 目前受
Google, Microsoft, Oracle 支持 • 內建於 Google Drive, Window 8, Java 8 • 從網頁端下凡至伺服端的仙女:Node.js • 延續下凡的趨勢:愛死拼腦(Espruino), Javascript for Things
趨勢:從裝置端到雲端
運算的雲、製造的雲 • 雲就是霧茫茫看不清楚, 為數眾多的意思。 • Javascript 不真的適合最 後的一里路:裝置端。 • 最後一里是
C 或是專用 語言(如 PLC) 的天下。 • 兩端需要溝通。
解決方案:新歡舊愛,執其兩端 • umbilical jxForth
開發步驟 步驟二:建立臍帶式 Forth 開發環境 使用工具:node.js, objdump, EventEmitter, VT100 步驟一:產生 jxForth
映象。 使用工具:gcc, gas, node.js, PEG.js
步驟一:產生 jxForth 映象 • 撰寫 core.f,這是一個 FORTH 程式。 • 以
PEG.js 對 core.f 進行語法解析後,產生 core.S 以及 words.json 檔。 • 以 gcc 編譯及連結 main.c 及 core.S,得到 jxForth 映象。
PEG.js • Parsing expression gramma • 2004 by Bryan Ford
• Parsed in linear time • 不需要 tokenization step • Cannot be ambiguous • 最大的優勢:語言支援(C,C++,Java, Javascript, Python,Ruby,Lua,...) • 很適合用來開發領域語言(DSL)
建立臍帶式開發環境 1. 使用 objdump -t 及 words.json 建立 Target的 字典。
2. 以 <指令位址> x 方式要求 Target 執行指令。 3. Target 回傳的字串中,以 <host></host> 標記 的部份是下給 host 執行的指令。 4. 指令 sync。 5. 指令 dp!。
定義新指令 • TARGET 字典有變更時,DP 必須同步。
Host 和 Target 同步 • 事件:words.ready • 事件:sync • 當發生事件
words.ready 後,代表字典備妥, node.js 可以開使進入 repl。 (read-eval-print- loop) • 每執行一行(使用者按 Enter),將此行解譯送 給 target ,要求 target 於完成後執行 sync,等 待 sync 事件。 • 當發生 sync 事件時,再執行一次 repl。
Line Editor • REPL 迴圈需要一個 line editor。 • Node.js 的
readline 不好用。 • Line Editor 是什麼? • var editor = new EventEmitter(); • Editor 將標準輸入設為 Raw mode,並且監聽 input 的 data 事件,以便讀取每個按鍵。 • Editor 會發出 ^C, ^D, backspace, enter 事 件。 • Editor 監聽自己的 ^C,^D,backspace,enter 事 件,並執行預設的行為。
VT100 • 使用以下三個 VT100 的 control sequence。 • var vt100_backward
= '\x1B[D'; • var vt100_erase_end_of_line = '\x1B[K'; • var bell = '\x07';
結論 • 秀一下。 • 程式在 http://projects.mapacode. tw/jxforth/doc/trunk/doc/wiki/index.wiki • 歡迎提問!