https://github.com/fwcd/worldwideweb-cocoa
Experimental port of Tim Berners-Lee's original WorldWideWeb browser for NeXTStep to modern macOS (Cocoa/AppKit)
https://github.com/fwcd/worldwideweb-cocoa
appkit cern cocoa nextstep nexus worldwideweb
Last synced: about 2 months ago
JSON representation
Experimental port of Tim Berners-Lee's original WorldWideWeb browser for NeXTStep to modern macOS (Cocoa/AppKit)
- Host: GitHub
- URL: https://github.com/fwcd/worldwideweb-cocoa
- Owner: fwcd
- License: other
- Created: 2024-05-20T23:28:30.000Z (12 months ago)
- Default Branch: main
- Last Pushed: 2025-03-10T21:20:23.000Z (2 months ago)
- Last Synced: 2025-03-10T21:31:11.439Z (2 months ago)
- Topics: appkit, cern, cocoa, nextstep, nexus, worldwideweb
- Language: Objective-C
- Homepage:
- Size: 2.66 MB
- Stars: 0
- Watchers: 2
- Forks: 1
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# WorldWideWeb Cocoa
A port of Tim Berners-Lee's original [WorldWideWeb](https://en.wikipedia.org/wiki/WorldWideWeb) web browser from the early 1990s to modern macOS.
![]()
| NeXTStep | macOS |
| -------- | ----- |
||
|
> [!IMPORTANT]
> This project is in its early stages and, while it does compile and even render basic web pages, there are still a number of features that don't work. Additionally, many of the parsing routines are not safe against untrusted inputs e.g. triggering buffer overflows, so don't log into your bank account with this.That said, anyone interested is highly encouraged to explore the codebase and hack on it though.
## Getting Started
Open [`WorldWideWeb.xcodeproj`](WorldWideWeb.xcodeproj) in Xcode, then build and run the WorldWideWeb target.
This should open a browser window displaying [the welcome page](WorldWideWeb/Resources/default.html). To follow a link, double-click it, but be warned: Some of these links point to the internet (info.cern.ch) and while pages served via IPv4 and HTTP/1.1 should work, note that especially more modern pages often cannot be parsed properly.

You can also open a local page via the menu bar (`Document` > `Open file...`) or by pressing Cmd + O. For an example that the browser can parse, try one of the HTML files from this repo, e.g. [`Documentation/SourceFiles.html`](Documentation/SourceFiles.html).
## Background
This port is mainly motivated by academic curiosity, specifically learning about the implementation of the first web browser (how HTML rendering works etc.) and the history of the NeXTStep API. The goal is to eventually have a working Cocoa application that stays faithful to the original code and design while adopting modern conventions where they make sense[^1]. This is not a small goal and may even be infeasible given the complexity of the project and potential need to replace or reimplement removed APIs.
### The NeXTStep API vs. Cocoa/AppKit
While the original NeXTStep API and modern AppKit still share substantial similarities, many things have changed over the last 30 years. The most noticeable difference is perhaps the `NS` prefix, which replaced the older `NX` prefix. More subtle changes exist too, specifically classes like [`NSParagraphStyle`](https://developer.apple.com/documentation/uikit/nsparagraphstyle?language=objc) or [`NSText`](https://developer.apple.com/documentation/appkit/nstext), which are more encapsulated than back in the NeXTStep days. Although good from a software design standpoint, these differences unfortunately complicate the migration, because much of the original rendering engine (see e.g. the [`HyperText`](https://github.com/fwcd/worldwideweb-cocoa/blob/8418220bc109a5ae43c257f94e9a74f3dd141534/WorldWideWeb/HyperText.m) class) relies on these internals of NeXTStep's [`Text`](https://www.nextop.de/NeXTstep_3.3_Developer_Documentation/GeneralRef/02_ApplicationKit/Classes/Text.htmld/index.html) and related classes.
Fortunately, [`NSTextView`](https://developer.apple.com/documentation/appkit/nstextview), [`NSTextStorage`](https://developer.apple.com/documentation/appkit/nstextstorage) and [`NSAttributedString`](https://developer.apple.com/documentation/foundation/nsattributedstring), the classes taking on these responsibilities in modern Cocoa, still map surprisingly well to the NeXTStep API on a conceptual level. Additionally, Cocoa's attributed strings handle many things under the hood that previously had to be done manually, such as merging attribute ranges.
For more information, see [issue #2](https://github.com/fwcd/worldwideweb-cocoa/issues/2).
### The Interface Builder NIB Format
Another major hurdle to overcome is the legacy Interface Builder NIB format. This format has changed a few times over the years, from the original `NXTypedStream` (see [this Python reimplementation](https://github.com/dgelessus/python-typedstream)) to the modern XML-based XIB format. While Xcode is capable of reading older versions of the XML-based format, the [`WorldWideWeb.nib`](https://github.com/fwcd/worldwideweb-cocoa/tree/4276fe7bd1e70c24a6d70fc96a13e06aa5f6fc67/WorldWideWeb/WorldWideWeb.nib) turned out to be too old even for versions of Project Builder, the predecessor of Xcode. Our approach here is to use [a custom Python script](Scripts/convert-nib-to-xib) to convert the legacy NIB to a modern XIB.
More information on this can be found in [issue #1](https://github.com/fwcd/worldwideweb-cocoa/issues/1).
### Further Reading
- https://www.w3.org/People/Berners-Lee/WorldWideWeb.html
- https://worldwideweb.cern.ch/code/
- https://en.wikipedia.org/wiki/WorldWideWeb## Project Structure
This Cocoa port uses a standard Xcode project ([`WorldWideWeb.xcodeproj`](WorldWideWeb.xcodeproj)). The source code can be found under [`WorldWideWeb`](WorldWideWeb) and a few helper scripts (e.g. for the NIB-to-XIB conversion) under [`Scripts`](Scripts).
A few files that are not really used anymore, but kept around out of historical interest and for reference purposes can be found in the [`Legacy`](Legacy) folder. This includes the original Makefiles, Project Builder projects and the legacy NIB that we generate the modern XIB from.
[^1]: A specific example of this is the menu bar. On NeXTStep, the main menu (i.e. the root of the menu hierarchy) was displayed as a single menu, while on macOS the "main menu" is actually the menu bar. This subtility results in slightly different conventions, e.g. on macOS it would be very uncommon for the menu bar to contain a menu item that directly represents an action such as "Print" or "Quit" and not a submenu itself. We deal with this by moving the top-level actions into the application menu (i.e. "WorldWideWeb") during the conversion from NIB to XIB. More details and screenshots can be found in [#1](https://github.com/fwcd/worldwideweb-cocoa/issues/1).