Hacker News new | comments | show | ask | jobs | submit login
The earliest known versions of Dennis Ritchie's first C compiler (github.com)
114 points by jnord 9 months ago | hide | past | web | favorite | 15 comments

The Living Computer museum provides logins to several old pieces of hardware. I wonder how many people are going to request logins to the PDP-11 to try to build the C compiler?

You may have your very own PDP-8, PDP-11, or PDP-10 simply by running SIMH.

Emulation's useful, but it's something that I've been doing in various forms for over half of my life. There'd be a novelty to actually running something on a 40 or 50 year old piece of refurbished hardware, adapted to run as a host on the Internet.

No doubt. I had a few raised eyebrows back when my company ditched a VAX 11/730 and I took it, but it was a VAX that ran on 110 and it was my very own. Made a damn fine usenet node for the limited feed that went to it.

There's type inference everywhere!

Or rather, undeclared types are assumed to be int. Is that what you are talking about?

The keyword "auto" means int?

It means automatic storage duration (i.e., on the stack). https://stackoverflow.com/questions/2192547/where-is-the-c-a...

'auto' means 'automatic storage duration' and does not carry type information.

Holy heck. 1972. The year I was born.

And that PDP-11 emulator is a blast.

    Use, duplication or disclosure is subject to
    restrictions stated in Contract with Western
    Electric Company, Inc.

How was this compiler bootstrapped?

By extending Ken Thompson's B compiler. The B compiler was initially written in TMG before Thompson rewrote it in B. Then Richie added types like 'char' and 'int' and called it NB ("new B"), then he added structs and C was born.

The TMG interpreter used by Thompson to create B was implemented for the PDP-7 by Doug McIlroy in PDP-7 assembly language: http://minnie.tuhs.org/pipermail/tuhs/2014-September/005149....

This is what TMG looked like: http://multicians.org/tmg.html

For some reason, I was a bit suprised for the extensive use of gotos. Thanks for sharing this pearl!

This is cute:

  	switch (o=symbol()) {
  /* short constant */
  	case 21:
		*cp++ = block(1,21,ctyp,0,cval);
		goto tand;

   .... elsewhere in the switch ....

        		cval = -cval;
				goto case21;

Guidelines | FAQ | Support | API | Security | Lists | Bookmarklet | Legal | Apply to YC | Contact