Live data from Hacker News

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

github.com

131–140 of 163 posts

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

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

> It makes sense long would have needed a comment.

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);
    ...

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

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

In C, long is not the name of a data type, it is a modifier. It turns out that C standard type is integer, so if you say long without another data type (such as double, for example), this means long int.

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

#133

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?

Long filenames are scary when your system has a 2.5MB disk.

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

#134
post #79
post #72

Earlier quoted context omitted.

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…

"long" and "short" are adjectives in C. The types are "long int" and "short int" and the "int" is implied if it's not present. A declaration like auto long sum; Declares a variable named "sum" of type "long int" and of automatic storage duration. The "double" comes from double-precision floating point. In the 1970s and 1980s anyone who came near a computer would know what that meant. Anyone who ever had to use a log…

Well, you can certainly think of "long" and "short" as adjectives, but the grammar doesn't treat them that way.

"long", "short", "signed", "unsigned", "int", "float", and "double" are all type specifiers. The language specification includes an exhaustive list of the valid combinations of type specifiers, including which ones refer to the same type. The specifiers can legally appear in an order. For example, "short", "signed short", and "int short signed", among others, all refer to the same type. (They're referred to as "multisets" because "long" and "long long" are distinct.)

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

#135

Earlier quoted context omitted.

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.

Before I look up `man cat`, what can you do with `cat` other than just see what's in a file?

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

#136
post #80
post #60

Earlier quoted context omitted.

String doesn’t make sense either. But that’s how words acquire new meanings.

It's short for "Hollerith string". Nobody wants to type out that man's name every time they want to deal with the data type. Also, most programmers know zero about computer science.

That seems to be inaccurate. According to Wikipedia, string constants in FORTRAN 66 were named in honor of Hollerith, and the actual wording in the standard is: "4.2.6 Hollerith Type. A Hollerith datum is a string of characters. This string may consist of any characters capable of representation in the processor. The blank character is a valid and significant character in a Hollerith datum." Apparently the term "string of characters" is assumed to be self-explanatory here, and independent of the "Hollerith" nomenclature. The connection to Hollerith is via punched cards, for which the _encoding_ of characters as bit patterns (hole patterns) was defined; but Hollerith doesn't seem to be directly related to the concept of character strings as such.

It is probably rather by chance that we ended up with the term "string (of characters)", as opposed to for example "sequence of characters". In a different universe we might be talking about charseqs (rhymes with parsecs) instead of strings.

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

#137

Earlier quoted context omitted.

Yes, int_16/int_32 or something like that makes a lot more sense. Today, not when this compiler was written. 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.

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

C’s type naming had real value when it was first designed, at a time when the industry hadn’t yet fully standardised on the 8-bit byte, 32/64-bit words, IEEE floating point, etc.

The fact that “int” could be 16-bits on a PDP-11, 32 on an IBM 370, 36 on a PDP-10 or Honeywell 6000 - that was a real aid for portability in those days.

But nowadays, that’s really historical baggage that causes more problems than it solves, yet we are stuck with it. I think if one was designing C today, one would probably use something like i8,i16,i32,i64,u8,u16,u32,u64,f32,f64,etc instead.

When I write C code, I use stdint.h a lot. I think that’s the best option.

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

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

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

Here’s something cool: the source code to Snyder’s compiler: https://github.com/PDP-10/Snyder-C-compiler

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

#139

Earlier quoted context omitted.

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.

Before I look up `man cat`, what can you do with `cat` other than just see what's in a file?

When not given a file, cat will just read from stdin, so you can use "cat > file.c", write some text, and send EOF with ^D when you're done.

Obviously, there's no way to go back and edit anything mid-stream, you have to write the whole thing out in one shot.

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

#140

Earlier quoted context omitted.

Before I look up `man cat`, what can you do with `cat` other than just see what's in a file?

When not given a file, cat will just read from stdin, so you can use "cat > file.c", write some text, and send EOF with ^D when you're done. Obviously, there's no way to go back and edit anything mid-stream, you have to write the whole thing out in one shot.

The backspace does work within the line.
Post reply on HN