Re: Why mobile web apps are slow

Although the title broadly and vaguely referring to “mobile web apps”, Why mobile web apps are slow is actually a lengthy breakdown of JavaScript performance on mobile. tl;dr: too slow, and will stay relatively slow in feasible future.

Regretfully, because I was not formally trained as a computer scientist, I don’t have the necessary knowledge to judge whether or not the analysis of hardware architecture, garbage collection, or even interrupter development trends, are genuine or not. Nor I will try to be an web fanboy to pin the arthur as an Apple fanboy to repudiate what he just wrote. The question I would like to bring up is: Supposedly all of the analysis (and the conclusion) are true, what would the future holds for the Open Web, in post-PC world?

For the web to move away from JavaScript, there are currently two active proposals: Google Native Client (NaCl) and asm.js. NaCl comes with some trade-offs, like interpretability; asm.js on ARM is still in active development, and we will not know whether or not it would bring the same performance boost on x86.

Obviously, without JavaScript, the web as we (the front-end web developers) know it will cease to exist. It’s not necessary a bad thing though — while the web moving a way from a place I grew up, where everyone can find out the layout or logic of any website with view source, it had also involved to something much useful and powerful, embedded into everyone’s digital life more deeply. Yet, working on Mozilla payroll means there is no excuse to give up on the Open Web — even though I am not the person who make these decisions, thought experiments is always a fun thing to do.

So, maybe 10 years from now, website, or web apps would do this: Probe the CPU architecture of your hardware, drop the corresponding optimized asm.js or NaCl bytecode to your device, and render the entire screen with WebGL. There might even be Flash-like authoring tool for that, or even WebHAL — a library to abstract CPU/GPU differences. Think about what the Open Web gain or loose at that future.

As for JavaScript, in that future, people would have conversation like this comic (spooler alert below; thanks Kanru for the link):

— … Can’t remember its name. Today it’s mostly used just as a target language for compilers, but back in [the professor]’s days people actually used to write in it directly!

— Oh, that must be JavaScript!

Perhaps, just like Lisp at the time, a dynamic-typing language is still too advanced for hardware circa 2013.

Github Pull Request 進階操作速查

Github 發 Pull Request 已經幾乎成為貢獻開放原始碼專案的主流操作方法了。Github 的成功就是在於介面設計的相當順手,甚至是如果只是要修改單一檔案可以直接在線上編輯器完成。不過它的流程還是少了最後複雜的部分:在中大型專案,一個 Pull Request 雖然可以留言做 review,但是貢獻者需要一些進階的 git 指令操作能力才能完成 review 來來回回的修改。例如,以下是從 Yuren 那邊偷來的Gaia 在 Github 上面的 workflow:

Gaia Development workflow

因為這樣,我寫了一篇文件以 Pull Request 發出之後,和專案管理者往來會遇到的情境為脈絡,解釋貢獻者該怎麼操作才能順利完成貢獻流程:Github Pull Request 進階操作速查。既然是 Github 上的流程,放 gist 當然是理所當然 … 之後需求的話可以再轉到 repository。

PS: 當初寫的時候沒有搜尋,不過搜尋了才發現還真的沒有人寫過這個流程的中文說明(英文很多就是)。倒是 John Resig 寫了一個 npm package 可以讓專案管理者跳過 Github 的綠色按鈕直接 squash commit:pulley。我比較懶惰,如文章所述,我覺得寫 CONTRIBUTE.md 要求貢獻者照作比較快 😀

HTML5 文字雲更新

Word Cloud of Wikipedia Entry "Hello World Program"

hello, world.

不知為何,撰寫一個印出「hello, world.」文字的程式成為一個學寫程式語言的傳統。學會 web programming 是我到目前得到最多收穫的事情之一;用作品去碰觸每個使用者的生活也是一件有趣的事情。

有時候也是會遲疑:這種軟體的存在究竟給人好的還是壞的影響?把自己的文字萃取、提煉、排成圖片,到底是一種自我反省、還是一種自我投射的強化?人們會因此更關心 HTML5 技術或是 Open Web 嗎?或是,人們會從政治人物發言的文字雲發現發言之空洞嗎?人們會因為一個充滿內容的文字雲,發現一個認真編輯的科普網站嗎?這些腦海中的問題,多多少少讓我不想再這上面花這麼多時間,即便這兩年來的點閱數、分享數、詢問等等。

不過最後我還是花了時間重寫了。主要的動機是想要導入這兩年學到的新技巧與開發模式,把程式碼拆成其他人可以利用的 library、加上測試、說明變成真正有誠意的 open source 專案等;光這樣 app 的部份前前後後也花了快一個月的時間。上週上線之後的回應也不錯:分享圖片的功能立刻就把 Imgur 的上傳容量用完了,Facebook 那邊雖然解決了 API 改版的問題,但圖片分享的部份因為被懷疑在使用者文字裡預填廣告所以被擋了。也感謝草兒幫忙完成了一些介面(open source 貢獻者捕獲!)。

剩下的技術細節就留在 Githubrepository 吧!隨意搜尋網路上的反應,一位香港文化人鄧小樺所留下的文字最令人回味:

……文字雲是世界上最靈異的事物,透露一切,像黃耀明唱,「難得一刻/讓我將真相透露/如同病發」。如果你就是你寫過的字,文字雲豈止是測謊機,簡直就是上帝。看到時總是驚異到雙膝發軟,覺得什麼都不用偽裝被它看透。以下是2013年得到面書文字雲,不斷跟自己說這個可能比較近的時間會有較大的位置,但得到的這個句子還是如神諭一般……

身為分析演算法的作者,不會覺得這個真的有這麼神奇啦(笑)。程式無論介面還是背後的演算機制,都還有很多功夫可以下,歡迎有興趣的同好加入。沒有程式基礎的話,測試、發想功能也是可以幫忙的方向。

不然就開始學寫「hello, world」吧!Say “hello” to the whole world by learning how to code.

註:此文圖片為英文維基百科條目《Hello World Program》的文字雲。文字大小基於美感經過人工調整。