6 ms·
The original keywords - https://github.com/mortdeus/legacy-cc/blob/master/last1120c/c00.c#L44 https://github.com/mortdeus/legacy-cc/blob/master/last1120c/... I
by astroanax 6y ago
The original keywords - https://github.com/mortdeus/legacy-cc/blob/master/last1120c/c00.c#L44 https://github.com/mortdeus/legacy-cc/blob/master/last1120c/...
Interestingly, long was commented
- josephg 6y agoIt 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 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!)
- zokier 6y ago> Microsoft’s WORD/DWORD are nearly as bad. Don’t call something a “word” if it doesn’t store characters. "Word" as a term has been in the wide use since at least 50s-60s, you can't really blame MS for that https://en.wikipedia.org/wiki/Word_(computer_architecture) https://en.wikipedia.org/wiki/Word_(computer_architecture)
- hakanai 6y agoA 'word' on an x86 is 32-bit, but a WORD is 16 bits. You can _absolutely_ blame Microsoft for using it to mean something that it isn't.
- innocenat 6y agoFloat doesn't make sense either. What is floating? (I know it's floating point, but it's the same as long/double).
- layer8 6y agoString doesn’t make sense either. But that’s how words acquire new meanings.
- bregma 6y agoIt'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.
- OGWhales 6y ago> Also, most programmers know zero about computer science. What made you say that?
- Koshkin 6y agoI have known a very good programmer, I'd say one of the best I have met, and he had extremely, surprisingly little knowledge of computer science and math (not having a formal education may have been a contributing factor). He coded in JS and Ruby.
- layer8 6y agoThat 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.
- wruza 6y agoint is neither 32 nor 64. Its width corresponded to a platform’s register width, which is now even more blurred because today’s 64 bit is often too big for practical use and CPUs have separate instructions for 16/32/64 bit operations, and we agreed that int should be likely 32 and long 64, but the latter depends on a platform ABI. So ints with modifiers may be 16, 32, 64 or even 128 on some future platform. intN_t are different fixed-width types (see also int_leastN_t, int_mostN_t, etc in stdint.h; see also limits.h). Also, don’t forget about short, it feels so sad and alone!
- Symbiote 6y agoIt could not be clearer that you didn't read the page referenced by the comment you replied to. "long" was commented out.
- yiyus 6y ago> 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 and long may have been poor word choices, but asking a non-programmer is not a good way to test it.
- josephg 6y agoGood 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 technical terms look like. "Power" has a specific technical meaning in each of those fields, but in each case the technical meaning is suggested by the everyday meaning of the word "power". Ask a non-physicist to guess what "power" means in a physics context and they'll probably get pretty close. Ask a non-programmer to guess what "integer" means in programming and they'll get close. Similarly computing words like "panic", "signal", "file", "output", "stream", "motherboard" etc are great terms because they all suggest their technical meaning. You don't have to understand anything about operating systems to have an intuition about what "the computer panicked" means. Some technical terms you just have to learn - like "GPU" or "CRDT". But at least those terms aren't misleading. I have no problem with the term "double precision floatingpoint" because at least its specific. "long", "double", "short" and "word" are bad terms because they sound like you should be able to guess what they mean, but that is a game you will lose. And to make matters worse, 'long', 'double' and 'short' are all adjectives in the english language, but used in C as nouns[1]. They're the worst. [1] All well named types are named after a noun. This is true in every language.
- bregma 6y ago"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 table or slide rule (which was anyone doing math professionally) would know exactly what that meant. There are good sound reasons for the well-chosen keywords. Just because one is ignorant of those reasons does not mean they were not good choices.
- iasmseanyoung 6y agoYes, 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.
- doctor_eval 6y agoUnsure 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
- fanf2 6y agoAn 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.
- kps 6y agoUnix was originally written for an 18-bit machine.
- fanf2 6y agoThat was before C which is what we are talking about.
- skissane 6y agoAs 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 https://www.bell-labs.com/usr/dmr/www/portpap.pdf [1] https://apps.dtic.mil/dtic/tr/fulltext/u2/a010218.pdf 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)
- bpgate 6y agoNo, 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 have been typedefs. In practice, I consider this a larger problem than the often cited NULL.
- jeffrallen 6y agoAnd that creat has no e on the end.
- Koshkin 6y agoIt's a perfectly good word in Romanian.
- flohofwoe 6y agoIt 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).
- deleted 6y ago[deleted]
- kps 6y ago(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.
- TheRealKing 6y agoFortran 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.
- elvis70 6y agoThat 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.
- _kst_ 6y ago> 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); ...
- hakanai 6y agoHmm, given its position in that sequence, it looks like it means a floating-point type larger than a double.
- coliveira 6y agoIn 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.
- rightbyte 6y agoThere is no short or unsigned either. Maybe int modifiers were pending work? for is missing too.