Live data from Hacker News

Dennis Ritchie’s first C compiler (c. 1972)

github.com

61–70 of 163 posts

Re: Dennis Ritchie’s first C compiler (c. 1972)

#63
post #11

Earlier quoted context omitted.

Yes, bootstrapping with regard to languages is the trick of getting that first compiler running so you can compile the rest of the compiler. It has been done many times. The first assemblers were written directly in machine language. The first compilers were written in assembly. Many implementations of FORTRAN, ALGOL, COBOL, etc. As late as the 1970s it was not unknown to write a new high level language directly in m…

> Steve Woz's BASIC for the Apple II was "hand-assembled", as he put it. Very cool - so basically (haha) Woz's integer BASIC was bootstrapped by writing it in assembly language and translating it into machine code by hand. I wonder if someone (Woz?) has written a 6502 assembler in integer BASIC to allow it to bootstrap itself?

The Apple ][ has a monitor in ROM that allows to enter machine code directly. The legend says that for the Apple I, Woz knew the complete integer basic machine code and could type it live into the monitor.

Re: Dennis Ritchie’s first C compiler (c. 1972)

#65
post #59

So how do you "bootstrap" compile this? I mean without cheating, say on a rebuilt computer after all computers where destroyed?

Hand-compile it for the initial bootstrap would be one way to go. That, or write a minimal C in assembler, then make it self-hosting, then expand it into the full implementation.

Edit: Elsewhere in-thread, retrac posted a detailed summary of how C developed from B.

Re: Dennis Ritchie’s first C compiler (c. 1972)

#66
post #42

The original keywords - https://github.com/mortdeus/legacy-cc/blob/master/last1120c/... Interestingly, long was commented

It makes sense long would have needed a comment. It needs a comment because “long” and “double” are terrible names for data types. Long what ? Double length what ? Those type names could easily have opposite meanings and meant long floating point / double length integer. WORD/DWORD are nearly as bad - calling something a "word" incorrectly implies the data type has something to do with strings. If you don't believe m…

> ask a non programmer

Why should a non programmer understand programming terms? Words have different meanings in different contexts. That's how words work. There is no need to make these terms understandable to anyone. The layman does not need to understand the meaning of long or word in C source code.

Ask a non-golf player what is an eagle or ask a physicist, a mathematician and a politic the meaning of power.

Word and long may have been poor word choices, but asking a non-programmer is not a good way to test it.

Re: Dennis Ritchie’s first C compiler (c. 1972)

#67

This is gold. I like how the files are named 00 01 10 11 because long filenames are scary. hshsiz 100; hshlen 800; /* 8*hshsiz */ hshtab[800]; These were at file scope. I assume they default to int, but when was the demand for = added?

For those who wonder, the extract comes from https://github.com/mortdeus/legacy-cc/blob/ccbe90a2803e2cc7e...

IMO, it is close to Assembly:

* you reserve space and possibly set an original value with "hshsiz DB 100" or "paraml DB ?"

* assignment is a different business which involves a runtime instruction (MOV)

Hence the same difference (no = sign for the first, passive, compile-time operation; an = sign for the second, active, runtime operation) in this proto-C.

(Of course, this doesn't answer your question of "when" did the syntax of those 2 operation fuse :-) )

Re: Dennis Ritchie’s first C compiler (c. 1972)

#68
post #9

Earlier quoted context omitted.

It was written in B. And B was written in B. To trace the bootstrap up into the high level, you have to go further back than the PDP-11. To bootstrap B on the PDP-7 and GE-635 machines he had access too, Ritchie wrote the minimum subset required to compile a compiler in B, in a language known as TMG (in the vein of, and a big influence on, Yacc and similar). This minimal bootstrap was then used to compile a B compile…

When people say bootstrapping, is this how all computer languages came to be? Or there has been multiple attempts at bootstrapping? What I’m getting at is whether all languages have a single root.

Chuck Moore is an interesting example of someone who has bootstrapped several languages without touching a C compiler. He has written systems directly in machine code, and has gone as far as designing his own chips to directly run Forth and ColorForth.

Re: Dennis Ritchie’s first C compiler (c. 1972)

#69
post #64
post #58

https://github.com/mortdeus/legacy-cc/blob/ccbe90a2803e2cc7e... “auto” exists in the initial version.

And what does it mean there? (automatic storage duration)

Do you mean automatic type deduction?

Edit : I know it’s also storage specifier but it also does type deduction here, hope I’m not confused with the terminology

Re: Dennis Ritchie’s first C compiler (c. 1972)

#70
post #64
post #58

https://github.com/mortdeus/legacy-cc/blob/ccbe90a2803e2cc7e... “auto” exists in the initial version.

And what does it mean there? (automatic storage duration)

It means it lives on the stack, so it "exists" until the function returns.
Post reply on HN