Safari 誕生秘話

iPhoneやMacで毎日使われているWebブラウザの「Safari」は2003年に登場しました。

当時のWebブラウザといえば今や亡きInternet Explorerの全盛で、Mozilla(後のFirefox)がオープンソースで開発されており、Chromeはまだ生まれていませんでした。IEの世界シェアはなんと95%に達していました。

Safariの登場はいくつかの点で画期的でした。ひとつはアップルがブラウザ開発に参入した事で、マイクロソフトが圧倒的シェアを握る中で無謀な挑戦と思われました。

もうひとつはアップルがオープンソースを採用した事、さらに一番有名だったMozillaのGeckoではなく、誰も聞いたことがなかったKHTMLというレンダリング・エンジンを採用した事です。今やアップルにとって最重要技術のひとつであるWebKitですが、マイナーだったLinuxのKonquerorブラウザのレンダリング・エンジンが元になっています。

Safariの開発に携わった Ken Kocienda がKTHMLを採用した理由や、Safariの驚くべき開発方針、そしてスティーブ・ジョブズについて Inside Apple Software Design で語っています。

Ken: The way Apple worked in this period, during the Steve Jobs era, is that he would set this vision. His vision was that Apple needs its own web browser. This exciting new technology, the Web, was something that wasn't under its own control. We considered writing a browser from scratch, and we also considered going out and licensing from a company like Opera. But we looked at open source because we were a team of two people. And web browser is a pretty complicated thing. We thought that if we could make a compelling case to use open source to jump ahead in the effort, it would get us to a point where we would have something sooner. That was really the goal.

2002年当時、MacOSにはマイクロソフトのInternet Explorerがバンドルされていました。キーテクノロジーの内製化にこだわるジョブズがこの状況を変えるべく、ブラウザ開発のプロジェクトをスタートさせました。

Ken自身も含めてわずか2名しかいかなったブラウザ開発チームはフルスクラッチの開発、Operaブラウザなどのライセンスなど様々な選択肢を検討したそうですが、最終的にオープンソースのコードベースを採用する事に決めたそうです。より早く製品を世に出すために、当時のアップルとしては例外的にオープンソースを採用したのです。

Andreessen: Interestingly, the two codebases that you considered to get Safari off the ground were Mozilla and Konqueror, and they were both open source.
Ken: Neither Mozilla nor Konquer worked on the Mac. It just came down that Konqueror was just 1/10th of the size of Mozilla. As a two-person team, this was just the easiest way to get from where we were to where we wanted to be.

聞き手のAndreessenがMozillaとKonquerorの違いについて聞くと、KenはKonquerorはコード量がMozillaの10分の1であり、最終的にはそれが決め手になったと答えました。

実際、当時のMozillaはかなり肥大化しており、その動作はお世辞にも軽いものとは言えませんでした。またWindows, Mac, Linuxなどマルチプラットフォームに対応しており、コード量が多かったことは容易に想像できます。

Andreessen: Pretty early in the development process, you ended up building a stop watch. Talk a little bit about why they decided to do that.
Ken: It was really Don Melton's idea. He said, "if we check in code, and if it doesn't make any speed regression, only two things can happen. Either the code will remain the same speed, or it will get faster." It's just one of these simple things just turned out to be this profound truth. As we go over hundreds of check-ins, that's what happened. Eventually, Safari, when it was released, was three times faster than IE at loading webpages.

Safariが発表された当時、スティーブ・ジョブズは「Macで一番速いブラウザだ」と豪語しましたが、そのスピードは偶然生まれたわけではなかったようです。

Safariの開発者がソースコードをコミットする際に自動的にページロードテストが実行され、パフォーマンスが劣化するコードはコミットできない仕組みだったようです。これはプロジェクトマネージャーのDon Meltonによって考案され、その結果、SafariはIEよりも3倍速くWebページを読み込む事ができたとの事です。現代のソフトウェア開発の現場でも取り入れたい手法ですね。

実は2003年のSafari発表当時、私はネット中継でMacWorldを見ていました。スティーブ・ジョブズがKHTMLを採用したと話した時には、本当に狐につままれたような気分でした。あれから17年経った今、その経緯を知る事ができて非常に感慨深いです。このMacWorldの様子はYouTubeでも見れるので、興味のある方はぜひ。

Kenはその後、初期のiPhone開発チームに参加してモバイル版Safariの開発に携わるのですが、その話は次回にします!

今回紹介したPodcast:
a16z Podcast: Inside Apple Software Design

この記事が気に入ったらサポートをしてみませんか?