今天跟同事討論一個問題: "Is asynchronous interface good?"

我的觀點是『server interface 應該採用 synchronous model,而由 client 來決定是否採用 asynchronous model 』。會有這樣的結論是因為我認為 "async is hard"asynchronous model 強迫 client 去做許多不同於 synchronous model 的特別處理才能確保程式的正確性;但是根據我的觀察,大多數 programmer 的思考邏輯都習慣了 synchronous model,要他們突然換成 asynchronous model 來思考非得花一番時間嘗試及偵錯才能達到 100% 的正確性。換句話說,我認為一個容易讓 client 端出錯的 interface 並不是好的 interface。

我向來是 "Make simple things easy and hard things possible" 這句話的信徒。