Live data from Hacker News

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

github.com

101–110 of 163 posts

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

#101

Earlier quoted context omitted.

If you judge the coding style of the early 1970s with modern standards, it isn't going to look great. 50 years is a loooong time. dmr was one of, if not the first C programmer(s).

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.

I try ed(1) once in a while and I find it pretty usable (and even rather efficient if you know what you are doing). cat(1) also works if you just want to type a new text.

Speaking of terseness, I love the the fact that C does not have 'fn'.

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

#102

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.

I try ed(1) once in a while and I find it pretty usable (and even rather efficient if you know what you are doing). cat(1) also works if you just want to type a new text. Speaking of terseness, I love the the fact that C does not have 'fn'.

We used to speak of a great Unix systems programmer as someone who could write device drivers with cat and have them compile and run the first time.

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

#103
post #91

Earlier quoted context omitted.

Can't say for sure if it's the reason in this particular situation, but that would require dynamic memory allocation, and while it may seem backwards to reserve more memory than potentially needed on old memory-constrained systems, it is a pattern you see very frequently because on those systems, you actually know exactly how much memory you have. As a result, you know exactly how much memory you can "waste". Especia…

External arrays are static, they do not involve any dynamic allocation.

It's not clear from the question whether GP just wonders about the strange syntax used to reserve the space or about allocating a fixed amount of memory. The "however-many-bytes-are-needed" part sounded to me like they thought that a dynamic amount of memory should be allocated.

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

#104
post #72
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…

Good variable names (and type names) matter for legibility. They should be clear, unambiguous, short, memorable and suggestive. Unambiguous is usually more important than short and memorable. The word 'long' is ambiguous and unmemorable. And the type "word" is actively misleading. If you called a variable or class 'long', it wouldn't pass code review. And for good reason. 'Power' is an excellent example of what good…

You really need to consider the context before making broad statements like this.

By your own standards, "word" and "long (word)" are actually excellent terms, because they're conventions used by the underlying hardware, and using the same conventions absolutely makes sense for a programming language that's close to the hardware:

https://en.wikipedia.org/wiki/Word_(computer_architecture)

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

#105
post #66
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…

> 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, length/height, mass/speed, etc. You'll find the latter is maddeningly hard to deal with, because your brain keeps bringing a whole lot of context that is just wrong, so you are constantly fighting your own brain.

Intuitive things come from prior experience. They are a kind of inertia that you just have to work with.

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

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

(a) FORTRAN used ‘DOUBLE PRECISION’ since the '50s, so ‘double’ would be immediately obvious.

(b) Many important machines had word sizes that were not a multiple of 8.

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

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

That made me curious. From section 2.2 of the 2nd edition of K&R, 'long' is not a type but a qualifier that applies to integers (not floats though), so you can declare a 'long int' type if you prefer.

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

#108
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.

Unix was originally written for an 18-bit machine.

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

#109
post #93
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…

> Ask a non-golf player what is an eagle or ask a physicist, a mathematician and a politic (sic) the meaning of power. All those fields could do with less jargon. Especially since in many cases there is a common word. Lawyers especially give me the impression that they use jargon to obscure their field from regular folks. Our field, being new, should not make the same mistakes, but yet, here we are, where the default…

Dejargonification is great; I agree that jargon is a real barrier to entry. However, after having dealt with lawyers (and doctors of all stripes: MDs, PhDs, ...), I've come to see jargon for what it is: a weakly typed pointer. It's exactly analogous to a struct of function pointers with a user cookie in C.

Jargon lets you summarize whole concepts in one word. A lot of jargon is functional in the math/programming sense: you can pass 'arguments' to the jargon. The jargon adds levels of abstraction that let the users communicate faster, with less error, and higher precision.

For instance, the distinction between civil and criminal matters; or the distinction between malfeasance, misdemeanor, and felony.

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

#110
post #11

Earlier quoted context omitted.

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.

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…

IBM's COBOL was implemented in PL/X, which traces its heritage to PL/S. PL/S itself was developed as a replacement for using assembler.
Post reply on HN