2014年7月20日星期日

The King's Speech

每聞近日政情,總想起當年英國向納粹德國宣戰當日,佐治六世的全國演說中的幾句話:
"Over and over again we have tried to find a peaceful way out of the differences between ourselves and those who are now our enemies. But it has been in vain. We have been forced into a conflict. For we are called ... to meet the challenge of a principle which ... permits a state, in the selfish pursuit of power, to disregard its treaties and its solemn pledges ... . Such a principle, stripped of all its disguise, is surely the mere primitive doctrine that might is right."
所謂莊嚴承諾,是隨時都可以反臉不認人的。那些野蠻人,無論披上幾多文明的外衣,骨子裏信奉的,始終都是「強權就是公理」。

佐治六世的演說內容,相信不少讀者已經從電影 The King's Speech 之中聽過。我剛剛讀由 Mark Logue(當年為佐治六世治療口吃的 Lionel Logue 之孫) 與 Peter Conradi 合著同名書本,發現此演說原來有兩個有趣的細節。首先,即使是如此重要的講稿,原來也有錯漏。原稿中 'threat' 一詞打漏了字母 'h',變成 'treat',不過 Lionel Logue 於講稿中為國王記低應該停頓的地方時,已留意到並更正此錯處。

其次,原來 Logue 臨時改變了講稿中幾處用字(見附錄有間線的地方),將 'my government' 改成 'ourselves',於某處將 'it' 改成 'this principle',以及將 'summon' 改成 'call'。據書中所述,Logue 認為 'my government' 與 'summon' 比較難唸,故而更改。然而書中並無解釋何以 'it' 一個單音節的字,反而變為 'this principle' 這組有四個音節的詞語。我覺得,Logue 這樣一改,演辭實在比之前更明白,可是照道理,如此重要的演辭,必須經過政府同意,方能更改。看來 Lionel Logue 此人要不是當機立斷,膽識過人,就是當年的英國政府,並無強國的「人民喉舌」那麼僵化。

附錄:英王佐治六世演說全文,1939年9月3日下午六時正。
In this grave hour, perhaps the most fateful in our history, I send to every household of my peoples, both at home and overseas, this message, spoken as I were able to cross your threshold and speak to you myself.

For the second time in the lives of most of us we are at war. Over and over again we have tried to find a peaceful way out of the differences between ourselves and those who are now our enemies. But it has been in vain. We have been forced into a conflict. For we are called, with our allies, to meet the challenge of a principle which, if it were to prevail, would be fatal to any civilised order in the world.

It is the principle which permits a state, in the selfish pursuit of power, to disregard its treaties and its solemn pledges; which sanctions the use of force, or threat of force, against the sovereignty and independence of other states.

Such a principle, stripped of all its disguise, is surely the mere primitive doctrine that might is right; and if this principle were established throughout the world, the freedom of our own country and of the whole of the British Commonwealth of Nations would be in danger. But far more than this - the peoples of the world would be kept in the bondage of fear, and all hopes of settled peace and of security of justice and liberty among nations would be ended.

This is the ultimate issue which confronts us. For the sake of all that we ourselves hold dear, and of the world order and peace, it is unthinkable that we should refuse to meet the challenge.

It is to this high purpose that I now call my people at home and my peoples across the seas, who will make our cause their own. I ask them to stand calm, firm and united in this time of trial. The task will be hard. There may be dark days ahead, and war can no longer be confined to the battlefield. But we can only do the right as we see the right, and reverently commit our cause to God. If one and all we keep resolutely faithful to it, ready for whatever service or sacrifice it may demand, then, with God's help, we shall prevail. May He bless us and keep us all.

2014年6月21日星期六

6.22 民間全民投票

昨晚於網上投了票。我明白主辦者資源有限,且當務之急為應付中國的網絡攻擊。未能顧及其餘,可以諒解。然而相比往常的投票活動,今次實在有幾個亟待改善之處:
  1. 由於主辦者並非方案的提議人,他們應該要求三個方案的提議者提供網頁,解釋方案內涵,保證網頁內容不變,並於投票網頁附上解釋三個方案的網頁連結。現時,投票網站上解釋方案內容的網頁有附註謂「資料來源: 和平佔中網站」,但不清楚是由和平佔中網站提供資料,抑或是投票主辦者自行詮釋。網頁內容,應由和平佔中網站提供為宜。
  2. 本來就應該開設多個實體票站。電子投票縱然方便,卻排拒了不諳電子產品的選民。我知,資源有限資源有限資源有限吖嘛,但既然係全民投票,就應該盡力令所有人都可以參予。今次安排,我覺得於年齡階層上,會造成很大偏差。
  3. 即使是電子投票,今次的安排也強差人意。投票者必須用智能手機 app,或者可以發出短訊的手機。若我的手機是某些不便發短訊的 feature phone 或老人手機,投票就變得很困難。若能安排用固網電話投票,才算妥善。

又一個 benchmark

從別人的網誌看到一篇做 benchmarking 的論文:A Comparison of Programming Languages in Economics,其中有些令人驚奇的結果。

比較不同程式語言的執行效率,往往引起極大爭議。一來,作比較時,實際上比較的不單單是語言本身,還牽涉了 compiler 或者 interpreter,以及程式庫。二來,各種語言均有其獨特的 features。如何用不同語言來實作同一個算則才算公平,並無定論。幾年前 Google 有人寫了篇 Loop Recognition in C++/Java/Go/Scala,對所涉各種語言,都找來熟悉該語言的工程師,先用最自然的寫法來實作同一個算則,然後再優化程式。照道理這樣做已經很公道,可是還是有工程師事後表示,若早知程式是用來做 benchmarking 的話,寫法就會不同云云。可見無論是再公平的程序,亦說服不了所有人。

三來,許多時於網上見到的都是 micro-benchmarks,它們實作的,往往都是生安白造兼且過份簡單的算則,而非來自現實問題、難度適中的算則。今次這篇論文,和前述 Google 工程師所用的算則,皆有現實背景,既不太難,亦不太易,很適合 benchmarking 用。

我自己寫的程式通常都是做科學計算,用得較多的語言中,我最熟悉的是 Matlab 和 C++,其次是 Python 和 Java,再而是 R。印象中,若計算以矩陣為主(我指的是「矩陣」matrix,不是「陣列」array),則前四種語言的表現皆差不多一樣,原因是除了 C++(但 C++ 也可以)外,Matlab, Python 或 Java 基本上都只是呼叫 BLAS 程式庫。若程式的瓶頸並非矩陣計算,則各種語言分別很大。通常若執行一個 C++ 程式要花一個時間單位,那麼 Java 就要大約 2-3 倍時間,Matlab 不用 Mex 則 6-10倍,而 Python 則時快時慢,但粗略地說,和 Matlab 同級。R 則慢過蝸牛,若講求速度的話,完全不用考慮。

那今次這篇 benchmarking 論文的結果又如何?答案是仍是 C++ 最快。各實作程式所花的時間(以 C++ 為 1.0)如下:

C++ (1.00) < Fortran (1.07) < Matlab, Mex (1.29) < Python/Numba (1.57) < Java (2.10) < Julia (2.70) < Mathematica (3.83) < Pypy (45.16) < CPython (155.31)。

以 C++, Matlab 和 R 來說,結果和我的經驗相符。然而,Julia 和 Python 的表現卻令我意外。如本網誌舊文所說,Julia 這種語法和 Matlab 有點相似的新語言可視為 "a general purpose programming language with a bias towards scientific computing"。其設計者曾於公式網站上,吹噓 Julia 有接近 C++ 的速度,然而網站上的 benchmarks,都不是來自現實問題。因此,今次 Julia 的超卓表現,應有助其宣傳攻勢。

Python 則既慢得意外,也快得意外。PyPy 和 CPython 皆比 C++ 慢了接近兩個數量級,實在始料不及。與此同時,一個我以前未聽過的 Python package,叫 Numba,卻做出 1.57 這個難以置信的結果。若其他範疇的 Python/Numba 程式皆有此表現,何止 Julia 活不了,相信連 Java 及 C++ 皆可殺掉。

不過話說回來,這個 benchmark 未必公正。從它的源程式所見,瓶頸位似乎是二維陣列的 array access。然而用各語言實作時,作者似乎一律假設二維陣列為 column-major 的。這樣就對 Fortran, Matlab 和 Julia 有利,卻不利使用 row-major convention 的 C++ 與 Python 了。無論如何,benchmark 只能作參考,不能一概而論,但今次 Julia 和 Python/Numba 的表現均相當優秀,值得關注。