Live data from Hacker News

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

github.com

151–160 of 163 posts

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

#151

Earlier quoted context omitted.

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…

Is there an explanation on why C’s operator precedence is weird? Such as: why does the bitwise AND have higher precedence than logical AND?

> why does the bitwise AND have higher precedence than logical AND?

Why is this precedence weird? Bitwise AND tends to be used to transform data while a logical AND tends to be used for control flow.

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

#152

Earlier quoted context omitted.

Is there an explanation on why C’s operator precedence is weird? Such as: why does the bitwise AND have higher precedence than logical AND?

> why does the bitwise AND have higher precedence than logical AND? Why is this precedence weird? Bitwise AND tends to be used to transform data while a logical AND tends to be used for control flow.

I meant equals having a higher precedence than bitwise AND.

As in:

    if (x & 2 == 2)
...is actually parsed as:

    if (x & (2 == 2))
...which isn’t intuitive.

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

#153

Earlier quoted context omitted.

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…

Is there an explanation on why C’s operator precedence is weird? Such as: why does the bitwise AND have higher precedence than logical AND?

There is, and it is amusing

“In retrospect it would have been better to go ahead and change the precedence of & to higher than ==, but it seemed safer just to split & and && without moving & past an existing operator. (After all, we had several hundred kilobytes of source code, and maybe 3 installations....)“

https://www.lysator.liu.se/c/dmr-on-or.html

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

#154

Earlier quoted context omitted.

Is there an explanation on why C’s operator precedence is weird? Such as: why does the bitwise AND have higher precedence than logical AND?

> why does the bitwise AND have higher precedence than logical AND? Why is this precedence weird? Bitwise AND tends to be used to transform data while a logical AND tends to be used for control flow.

See the above example from dmr himself

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

#155
post #95

Earlier quoted context omitted.

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…

Some would say,

https://multicians.org/history.html

Instead we pile mitigations on top of mitigations, with hardware memory tagging being the last hope to fix it.

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

#156

Earlier quoted context omitted.

Yeah, those languages were IIRC designed to be edited offline (as a deck of punch cards) and submitted to a mainframe via high-speed card reader as a batch job.

Very interesting when you think about it. A language created in 2009 (Go) owes its syntax to a language from 1969 (B), and the latter looks like it does because it was designed during a short transition period between offline editing (1960s) and electronic terminals (1970s). And there are people claiming that computer scientists are not conservative :) To what extend this explanation is correct is another question...…

B was a descendant of Bootstrap CPL, a language never intended to be used for anything other than making a CPL compiler, really a butterfly effect.

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

#157

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?

You can join files together.

    $ cat foo bar > baz
will join the files foo and bar together into a single file called baz

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

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

(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.

Fortran has been using `int8`, `int16`, `int32`, `int64`, and `real32`, `real64`, `real128` kinds officially for at least 2 decades. `double precision` has been long declared obsolescent, although still supported by many compilers. Regarding types and kind, (modern) Fortran is tremendously more accurate and explicit about the kinds of types an values.

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

#159
post #129

Earlier quoted context omitted.

> A jargon term needs to crisply identify the crux of the concept and not confuse with irrelevant or misleading details. Agreed. I've never seen a vernacular term fill this role well. If you need to learn the technical concepts either way to be effective, might as well give them a name that doesn't conflict with another definition most people know.

I think "binary tree" is a decent example. It's not only a visual depiction of how the data structure is laid out, but the metaphor of "leaves" does also transfer over. It is possible to take it too far, trying to fit "bark" into the concept, which is of course, silly. Calling it a "dubranchion" or some such would be a disaster, IMHO.

"Binary tree" is not a vernacular term.

In economics, "cost" is a good example. This is a distinct concept from "price". "Comparative advantage" is another term in economics; this is perhaps not used in vernacular conversation, but I can tell you from personal experience that it certainly doesn't convey to most people the definition understood by someone with an education in economics -- the vernacular reading doesn't imply the jargon definition.

It seems to me that the difference is how the jargon is used. I imagine that someone without a CS background would quickly realize, when overhearing a conversation about binary trees, that the subject is something other than a type of flora.

I can tell you with confidence borne from frustrating experience that using economics jargon, such as that I mentioned above, with a lay audience gives the audience no such impression that the terms mean anything other than what they perceive them to mean.

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

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

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

Hmm, given its position in that sequence, it looks like it means a floating-point type larger than a double.
Post reply on HN