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)?

IMSoP
  • 885
  • 1
  • 7
  • 12
  • 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 '20 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 '20 at 14:11

2 Answers2

83

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%.

Stephen Kitt
  • 121,835
  • 17
  • 505
  • 462
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.

Brian H
  • 60,767
  • 20
  • 200
  • 362
  • 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 '20 at 14:16
  • Yeah, it's a subtle distinction - "came from Netscape" vs. "came from a Netscape Navigator release". My impression of the transition is that many of the same developers just kept working on what they had been working on in Netscape. It was more of an organizational transition. Not really a change in the people/minds behind the actual code. – Brian H Mar 27 '20 at 16:49
  • Like I say, I think this is a great find, but I think it's a fairly clear question whether something dates to at least Communicator 4.0 code, or whether it was created from scratch for an experimental codebase that wasn't released to production until after the Mozilla project took over. It would be interesting to compare the earliest available Layout and NGLayout sources, and see if these "foundational" pieces were indeed shared. – IMSoP Mar 27 '20 at 18:41
  • 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 '20 at 23:28
  • 1
    @CJDennis I wonder what the oldest code published is. Can I copy a blank line from a Grace Hopper paper and say my code traces back to 1953? – mbrig Mar 28 '20 at 02:30
  • 2
    @mbrig Only if Git blame says it does! – CJ Dennis Mar 28 '20 at 02:46
  • 2
    How's this possible if Git came out in 2005? – Morgan Mar 28 '20 at 03:20
  • 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. – user9811991 Mar 28 '20 at 06:15
  • 2
    @Morgan: Even if Git didn't allow you to simply pass the date as an argument, which it does, you could always just change your system realtime clock. – Jörg W Mittag Mar 28 '20 at 09:10
  • @user9811991 what version control software did they use in 1998 that supported commits and stuff? – Morgan Mar 28 '20 at 13:28
  • 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 '20 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. – Jörg W Mittag Mar 28 '20 at 16:33
  • 1
    @Morgan: while CVS manages changes to individual files, Mozilla already had a tool (Bonsai) that groups changes to several files in changesets for easier viewing. How well repo history ends up after importing depends on the importing tool, and possibly effort made by the people doing the importing to fix any screwups of the importing tool. Mozilla moved from CVS to Mercurial, and Mozilla obviously had the expertise to fix any screwups made by whichever importing tool they used. – ninjalj Mar 28 '20 at 17:47
  • @ninjalj I've done imports into Mercurial and IIRC it had some smarts to combine individual check-ins to different files which had the same or similar timestamps into one commit. – StayOnTarget Mar 30 '20 at 13:36