The Old Blog Archive (Traditional Chinese), 2004-2009

碳與C語言的重要

WWDC 2006的相關影片前陣子陸續發布到了iTMS上,WWDC的與會者可以下載回來看。

雖然說OS X裡有越來越多Cocoa相關的程式庫,但是大多數 Core- 開頭的東西還是以 C 言為基礎的 API。意思是說,任何想在OS X深入一點的開法者,起碼還是得了解 CFRelease、NS- 與 CF- 開頭的資料結構的免費橋接 (“toll-free” bridging),這一類 CoreFoundation 的基礎。

有人曾經問我:到底 OS X 上能不能用 C++ 來開發?更進一步的問題是:難道一定得在 C (Carbon) 和 Objective-C (Cocoa) 間做選擇?

我本來還真找不到什麼好的說法,結果意外在 survey Managed C++ 的時候,讀到這一段 Microsoft 的人寫於 2001 年的話,我笑了:

Unfortunately, as powerful and flexible as managed C++ is, it’s not the native language of .NET, which means that books, articles, courses, code samples, and so on, are not going to be written in managed C++—they’re going to be written in C#. But this should come as no surprise. C++ has never been the native language of any popular platform. Unix and Win32® have C. The Mac has Pascal. NeXT had Objective C (of all things). COM has Visual Basic. Only the BeOS has C++ as its native language, and when was the last time you wrote any BeOS code? The fact that .NET favors C# merely means that another language will be translated into the C++ equivalent, as has been done since 1983.

斜體是我加的。NeXT “had” Objective C. Now OS X has Objective-C. :)

2 Responses to “碳與C語言的重要”

  1. on 26 Jan 2007 at 09:30鳥毅

    昨天在qing的場次聽到,現在C++/CLI也是標準,目前mono還沒有對應的compiler。
    http://www.ecma-international.org/publications/standards/Ecma-372.htm

  2. on 28 Jan 2007 at 01:38whiteg

    戰場拉到mobile的話,I think Symbian is written by C++… The funny part is, when we learn mobile programming, we use Java.:P