Having talked my way into using the local university EE dept's 11/45, I found the source tree was mounted (they had a 90MB CDC "washing machine" drive) and decided to print it out on the 132-col Tally dot-matrix printer.
Some minutes into this, the sysadmin bursts into the terminal room, angrily asking "who's running this big print job".
I timidly raise my hand. He asks what I'm printing. I tell him the C compiler source code because I want to figure out how it works. He responds "Oh, that's ok then, no problem, let me know if you need more paper loaded or a new ribbon".
if (peekc) {
c = peekc;
peekc = 0;
} else
if (eof)
return(0); else
c = getchar();dmr was one of, if not the first C programmer(s).
The C language (and all of Unix) was designed to be very terse as a consequence.
return(0); else
makes a bit of sense.E.g.:
if (peekc) {
c = peekc;
peekc = 0;
} else
eof ?
return(0) :
c = getchar();
The first else clause sill looks weird, but the final part isn't nearly as out of place (well i guess assigning in a ternary would be weird, but in terms of indentation) and its not like we actually changed anything.This triggers me because many people jump on “bad c0de” in the forums, but then you read some practical code on github, and it is (a) not as perfectly beautiful as they imagine at all and (b) is still readable without nightmares they promised and (c) the algorithms and structure itself requires programmer’s perception and understanding levels far beyond the “it’s monday morning so i feel like missing an end of statement in a hand-written scanner” anyway.
“auto” exists in the initial version.
Edit : I know it’s also storage specifier but it also does type deduction here, hope I’m not confused with the terminology
Interestingly, long was commented
If you don't believe me, ask a non programmer friend what kind of thing an "integer" is in a computer program. Then ask them to guess what kind of thing a "long" is.
The only saving grace of these terms is they’re relatively easy to memorise. int_16/int_32/int_64 and float_32/float_64 (or i32/i64/f32/f64/...) are much better names, and I'm relieved that’s the direction most modern languages are taking.
(Edit: Oops I thought Microsoft came up with the names WORD / DWORD. Thanks for the correction!)
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.
"Word" as a term has been in the wide use since at least 50s-60s, you can't really blame MS for that
The PDP-9, PDP-10, and PDP-18 have 18 bits registers. The world had not settled on 16/32/64 bits at all.
Even the intel 80286 far/fat pointers are 24 bits.
"long" was commented out.
The real mistake in retrospect is that int and long are platform dependent. This is an amazing time sink when writing portable programs.
For some reason C programmers looked down on the exact width integer types for a long time.
The base types should have been exact width from the start, and the cool sounding names like int and long should have been typedefs.
In practice, I consider this a larger problem than the often cited NULL.
Also, don’t forget about short, it feels so sad and alone!
I think you misunderstood. There's no explanatory comment. The "long" keyword is commented out, meaning that it was planned but not yet implemented.
...
init("int", 0);
init("char", 1);
init("float", 2);
init("double", 3);
/* init("long", 4); */
init("auto", 5);
init("extern", 6);
init("static", 7);
...for is missing too.
Later, the language would be retargeted to the PDP-11 while on the PDP-7. Various changes, like byte-addressed rather than word-addressed memory, led to it morphing into C after it was moved. There was no clear line between B and C -- the language was self-hosting the whole time as it changed from B into C.
Mr. Ritchie wrote a history from his perspective published in 1993. I've mostly just summarized it above. It's available here: https://web.archive.org/web/20150611114355/https://www.bell-...
- Rewrite B compiler in B (generating threaded code)
- Extend B to a language Ritchie called NB (new B). This compiler generated PDP assembly There is no version of the NB compiler known to exist.
- Continue extending NB until it became the very early versions of C.
You can read the longer version of this history here:
I'm not even sure it's the first C compiler written in C, though - it just says in the github description "the very first c compiler known to exist in the wild."
Regardless, if it's from 1972 it's a very early version.
https://github.com/mortdeus/legacy-cc/blob/master/prestruct/...
The feeling dissipated somewhat when our guide explained that it’s a treasure map
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?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 :-) )
The full compiler is super compressed. Hundreds of lines per file. It would be great if there was an explanation of the general idea of the design somewhere.
Edit: Elsewhere in-thread, retrac posted a detailed summary of how C developed from B.