84

Inspired by comments on the previous question Is it true that Netscape Navigator eventually became Mozilla Firefox? (Answer: Yes).

In 1998, Netscape released a large amount of their existing source code as open source, and this became the basis of the Mozilla and eventually Firefox code bases. Over the years, large sections of this have been rewritten, although some of those rewrites were themselves started within Netscape (e.g. the "NGLayout" engine which became "Gecko").

Are there any sections of code in Firefox version 74.0 (released March 2020) which are basically unchanged from code which was actually part of pre-Mozilla Netscape releases (Communicator 4.0 or earlier)?

2
  • 1
    The question is a bit unclear (when does it count? does already a comment line about some past maintainer resolve it?) as well as kind of superficial, after all more than 20 years have past since then. Still I've voted for keeping open, as I'm curious if someone digs deep enough to find some obscure example, which in itself is a feat. Brian already made a good point.
    – Raffzahn
    Mar 27, 2020 at 13:51
  • 3
    @Raffzahn Yes, there's definitely a judgement call as to what would be considered "significant" code. But I'm not expecting a yes or no answer, so if someone says they've scoured the code base and they can't find anything more substantial than a one-line comment, that would be a good answer IMO.
    – IMSoP
    Mar 27, 2020 at 14:11

2 Answers 2

82

A number of components still present in Firefox date back to the first code drop in 1998 and were probably present before that. One of these is nsprpub, the NetScape Portable Runtime library, and it has some code snippets which are still identical to those in the first public CVS commit (as verifiable from the VCS archives). For example, ptthread.c’s _PR_InitializeStack:

/*
** Initialize a stack for a native pthread thread
*/
static void _PR_InitializeStack(PRThreadStack *ts)
{
    if( ts && (ts->stackTop == 0) ) {
        ts->allocBase = (char *) &ts;
        ts->allocSize = ts->stackSize;

        /*
        ** Setup stackTop and stackBottom values.
        */
#ifdef HAVE_STACK_GROWING_UP
        ts->stackBottom = ts->allocBase + ts->stackSize;
        ts->stackTop = ts->allocBase;
#else
        ts->stackTop    = ts->allocBase;
        ts->stackBottom = ts->allocBase - ts->stackSize;
#endif
    }
}

hasn’t changed at all in 22 years. _PR_InitThreads, further down, has large portions which haven’t changed either. Over half of the original ptthread.c is still present in the current version.

In fact, if my calculations are correct, out of 65,745 lines in the original nsprpub, 36,046 are present unchanged in the current version of nsprpub, i.e. 54.8%.

7
  • 5
    Who wrote this method? Mar 28, 2020 at 1:52
  • 4
    Good code is good. :)
    – Vilx-
    Mar 28, 2020 at 21:40
  • 5
    @Kamran a certain ltabb committed the code in the first public commit, but there’s a decent chance the code’s author is someone different. I suspect only a Netscape developer familiar with the code at the time would know for sure... Mar 28, 2020 at 22:25
  • it would be valuable for computer science history to know who wrote what. If you write a book, everyone would know you did it even after you've died but unfortunately it's not the same for your code. I wish my great-great-great grandchild could see who I was by reading my code. Mar 29, 2020 at 3:08
  • 1
    In that code snippet, couldn't ts->stackTop = ts->allocBase; be moved outside the #ifdef block? Mar 29, 2020 at 22:15
17

Firefox has seen a great deal of development over the last 22 years, both in maintaining the original code and in re-writing large portions. Currently, much of Firefox is being converted from C++ to modern Rust code.

That said, there are certain core pieces to the browser that maintain code from the time it was open-sourced. A reasonable place to look is the HTML Parser within the Gecko engine. This makes sense because even early versions of Netscape Navigator need to be built out around the basic functionality of parsing the HTML standard, which itself has evolved over the years in a backwards compatible manner.

Using the current Git repository for Gecko, located on Github at mozilla/gecko-projects, you can view the revision history of the HTML parser. The linked file, CParserContext.cpp is part of that original HTML parsing core, and you can see the history goes back 22 years.

enter image description here

My impression of the transition is that many of the same developers just kept working on what they had been working on within Netscape. This was more of an organizational transition and not a real change in the people/minds behind the actual code. I think this is an important point to make, if one is interested in history as a story about the people who made it, rather than just a collection of the artifacts the people made.

This is just an example, and I am sure you can find lots of code in the Github repository (which incidentally mirrors the "official" repository that uses Mercurial for source control). that originated with the release of the Navigator source code in 1998. Just focus on "foundational" functions like parsing and processing of the document model, and much of the already mature code from Netscape's days are likely to still survive.

14
  • 2
    This is a good start, but as mentioned in the question, Gecko itself descends from the experimental NGLayout engine, which wasn't part of any pre-Mozilla release; so to see if this was copied from Netscape 4.0 or earlier, we'd need to find corresponding lines in the old layout engine. As a side note, Mozilla's official repository is in Mercurial, what you've linked to is just a read-only mirror.
    – IMSoP
    Mar 27, 2020 at 14:16
  • 12
    Um, so the comment on line 1 hasn't changed for 22 years, nor have the two blank lines at 6 & 7, or the #include on line 9. How about executable code?
    – CJ Dennis
    Mar 27, 2020 at 23:28
  • 11
    @Morgan It is possible to back-date commits in Git and then push them back to GitHub or other sources. This is often done when converting a project from one source code management system to another, and has occasionally been used to manually create Git representations of historical code. Mar 28, 2020 at 6:15
  • 3
    Git is very good at importing from legacy version control.Mozilla code, like most code, probably passed through CVS and Subversion on its way to Mercurial and the Github clone. Exporting and re-importing generally includes all the history from the prior version control system.
    – Brian H
    Mar 28, 2020 at 13:45
  • 4
    @Morgan: SCCS (1972), RCS (1982), CVS (1986), CVSNT (1998), Vesta (1993), maybe early versions of BitSCCS (the core of what would later become BitKeeper). Also note that there is no need for them to actually have used a version control system at all, in order to construct a repository that represents the history of the project. E.g. the historical Linux repositories were created by taking all the patches from the mailing list, and turning each patch into a commit with the date of the mail as the commit date, the sender as the committer and the text of the mail as the commit message. Mar 28, 2020 at 16:33

Not the answer you're looking for? Browse other questions tagged or ask your own question.