Live data from Hacker News

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

github.com

111–120 of 163 posts

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

#111
post #86
post #42

Earlier quoted context omitted.

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…

No, the names are fine and self evident after glancing through K&R for 15 min. 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…

It made more sense in an era when computers hadn't settled on 8-bit bytes yet. A better idea (not mine) is to separate the variable type from the storage type. There should be only one integer variable type with the same width as a CPU register (e.g. always 64-bit on today's CPUs), and storage types should be more flexible and explicit (e.g. 8, 16, 32, 64 bits, or even any bit-width).

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

#112
post #95

Earlier quoted context omitted.

And he was almost certainly using ed(1) as his editor and a mechanical teletype at 7.5 or 10.0 characters per second as his terminal... The C language (and all of Unix) was designed to be very terse as a consequence.

That period lasted what, 10 years after Unix was created? And we'll be stuck with those decisions decades if not centuries. Similar story with the design of QDOS / MS-DOS / Windows and nowadays with Android. Both designed for super underpowered machines that basically went away less than a decade after they were launched and that will be hobbled because of those early decisions for a long, long time.

We will be hobbled with these decisions for a long time precisely because the complete package of trade offs the designers made were so successful.

If they had gone for wart-free on properly powered hardware, they would be stuck back in Multics land or living with the gnu Hurd—cancelled for being over budget or moving so slowly that projects that actually accomplish what the users need overtake them.

Do I wish that C had fixed its operator precedence problem? Sure. But the trade offs as a total package make a lot of sense.

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

#113
post #105
post #66

Earlier quoted context omitted.

> 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…

It's about cognitive load. The more jargon diverges from concepts you already have learned and used for years, the more difficult it is to adapt. As an experiment, try replacing all of your variable names and types with numbered variables: v1, v2, v3, etc. Then compare to replacing them with words: not completely random words, but with completely misleading words, like the complete opposite of what they represent, le…

Jargon that builds on intuition can be its own problem. Jargon, by its very definition, has explicit technical meaning in a specific domain. Intuition in words is based on vernacular usage. It is vanishingly unlikely that the vernacular usage aligns with the domain-specific usage of a given term. This leads to plenty of false assumptions, and forces people to disambiguate jargon-usage vs vernacular-usage, which may both be found in a single piece of writing.

See economics for a great example of jargon-vernacular crossover.

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

#114
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?

I’m not aware of any basic that is implemented in itself. There must be one or two somewhere, but typically for systems like the apple ii or Commodore PET, basic was implemented always in assembly.

So most weren’t exactly bootstrapped the way we are talking here.

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

#115
post #108
post #90

Earlier quoted context omitted.

An int in C was 16 bits until about 1980 when Unix started being ported to larger machines. C and Unix were originally just for the PDP11.

Unix was originally written for an 18-bit machine.

That was before C which is what we are talking about.

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

#116
post #105

Earlier quoted context omitted.

It's about cognitive load. The more jargon diverges from concepts you already have learned and used for years, the more difficult it is to adapt. As an experiment, try replacing all of your variable names and types with numbered variables: v1, v2, v3, etc. Then compare to replacing them with words: not completely random words, but with completely misleading words, like the complete opposite of what they represent, le…

Jargon that builds on intuition can be its own problem. Jargon, by its very definition, has explicit technical meaning in a specific domain. Intuition in words is based on vernacular usage. It is vanishingly unlikely that the vernacular usage aligns with the domain-specific usage of a given term. This leads to plenty of false assumptions, and forces people to disambiguate jargon-usage vs vernacular-usage, which may b…

> Jargon that builds on intuition can be its own problem.

Sure it can, which is why you gotta be double-careful naming things and not try to take metaphors too far. A jargon term needs to crisply identify the crux of the concept and not confuse with irrelevant or misleading details.

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

#117
post #69
post #64

Earlier quoted context omitted.

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

here it means automatic storage duration

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

#118
post #90

Earlier quoted context omitted.

Unsure why you’re being downvoted, IIRC the original C programmers reference spoke explicitly about how “int” meant the most efficient unit of storage on the target machine. Admittedly I read that more than 30 years ago :-O

An int in C was 16 bits until about 1980 when Unix started being ported to larger machines. C and Unix were originally just for the PDP11.

As this paper [0] explains, the initial version of the C compiler for PDP-11 Unix was finished in 1972. And less than a year later (1973), people had ported the C compiler (but not Unix) to Honeywell 6000 series mainframes, and shortly thereafter to IBM 370 series mainframes as well. (Note the text of the paper says "IBM 310" in a couple of places – that's a typo/transcription error for "370".) Both were "larger machines" – the Honeywell 6000 had 36 bit integer arithmetic with 18 bit addressing; the IBM 370 had 32 bit integer arithmetic with 24 bit addressing.

Alan Snyder's 1974 masters thesis [1] describes the Honeywell 6000 GCOS port in some detail. In 1977, there were three different ports of Unix underway – Interdata 7/32 port at Wollongong University in Australia, Interdata 8/32 port at Bell Labs, and IBM 370 mainframe port at Princeton University – and those three had C compilers too.

[0] https://www.bell-labs.com/usr/dmr/www/portpap.pdf

[1] https://apps.dtic.mil/dtic/tr/fulltext/u2/a010218.pdf (his actual thesis was submitted to MIT in 1974; this PDF is a 1975 republication of his thesis as an MIT Project MAC technical report)

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

#119
post #41

Earlier quoted context omitted.

Can't return in a ternary.

Correct, return is not an expression. But then again, he could if he wanted to, as the language designer ;)

Wouldn't it be wonderful if we could write

    a = return b;
Post reply on HN