Live data from Hacker News

C Questions and Answers

kukuruku.co

111–120 of 135 posts

Re: C Questions and Answers

#111
post #52

Earlier quoted context omitted.

I think the opinions "c is too complicated and buggy and, therefore, obsolete" and "javascript is a 'shiny' language for amateurs" are just as narrow-minded as each other.

> javascript is a [...] language for amateurs He never said that or implied it.

In fact, my point was the complete opposite.

Re: C Questions and Answers

#112
Why the heck was the name of this post changed? It rather conveniently puts the author in a better light by downplaying the anti-intellectual nature of the article I commented about above. I thought the general rule was that posts should be titled with the title of the linked article, which was the case before but now is not the case.

EDIT: To answer my own question, the submitter is clearly the author based on his submission history. So yes, this was an act of self-censorship to try to hide the author's disgusting attitudes.

Re: C Questions and Answers

#113

Why the heck was the name of this post changed? It rather conveniently puts the author in a better light by downplaying the anti-intellectual nature of the article I commented about above. I thought the general rule was that posts should be titled with the title of the linked article, which was the case before but now is not the case. EDIT: To answer my own question, the submitter is clearly the author based on his s…

The title was changed by one of the admins, "dang", and he posted in this thread that the reason for the change was that the original title was "controversial".

Re: C Questions and Answers

#114
post #81
post #9

Well apparently I do know C. If the author wanted to be as contrived a possible there are certainly more devious edge cases which could have been trotted out. The fact that e.g. the compiler may optimize out a NULL check after you've already dereferenced the darn thing shouldn't be surprising. Just fix your silly bug.

Clever pseudonym mr Sweeney ;)

Ha, I wish! I just happen to work for another 'Epic'ly named company.

Re: C Questions and Answers

#115

I just got the first one wrong and haven't written C code in a decade. I have to admit I haven't seen that construct used in any programs. I guess, no harm no foul, but still seems like an odd construct to allow.

The first one would appear when using global variables which are shared across files, you just wouldn't see it as the pieces would usually be in separate files.

Something like:

    /* file.h */
    int global_i;
and you have:

    /* file.c */
    int global_i = 0;
Then if file.c includes file.h both will be in the same file during compilation.

Re: C Questions and Answers

#116

Although most comments use these examples to argue that C is a bad language, I would argue the opposite, that these examples show how C is an extremely useful language. C has occupied a niche position as the lowest commonly-used language that is both human-readable (at the level of expressing algorithms, data structures, functionality, and control flow) but not specific to any one instruction set architecture (and th…

#1. Tentative definitions are historical baggage from Fortan Common blocks ( https://blogs.oracle.com/ali/entry/what_are_tentative_symbol... ), which may have helped adoption of C by Fortran users. Although it remains in the C language specification, this feature can be ignored. #2. Treating dereferencing a NULL pointer as undefined behavior means that the compiler is not required to generate additional instructions…

5. size_t doesn't necessarily have to be the width of an address. An address (say, a value of type void* or char) has to be able to refer to any byte of any object. A size_t only has to be able to represent the size of any single* object. The limit on the size of a single object and the limit on the total size of memory are often the same on modern systems, but C allows them to be different (think segments).

6. size_t is required to be unsigned.

9. C requires wraparound behavior for unsigned integers.

10, 11, 12. It's not just the result of an overflowing signed integer arithmetic operation that's undefined, it's the behavior. `INT_MAX + 1` can yield `INT_MIN`, or it can yield 42, or it can crash your program and reformat your hard drive (at least in principle).

Re: C Questions and Answers

#117

Earlier quoted context omitted.

#1. Tentative definitions are historical baggage from Fortan Common blocks ( https://blogs.oracle.com/ali/entry/what_are_tentative_symbol... ), which may have helped adoption of C by Fortran users. Although it remains in the C language specification, this feature can be ignored. #2. Treating dereferencing a NULL pointer as undefined behavior means that the compiler is not required to generate additional instructions…

Good comment, but I'd like to add that int is not really the "natural arithmetic width of an instruction set" any more. We will never see 64-bit ints. The sizes of int and long seem to be "whatever works, and is compatible with what it used to be".

I've seen 64-bit ints (on Cray systems).

One disadvantage of making int 64 bits, even if that's the natural size, is that if char is 8 bits, then short has to be either 16 or 32 bits (or 64) -- which means that you can't have predefined types covering all the common sizes (8, 16, 32, 64).

That's not quite true, since C99 introduced extended integer types -- but I don't know of any C compiler that has provided them.

(The intN_t and uintN_t types in don't solve this; they still have to be defined in terms of existing types.)

Re: C Questions and Answers

#118
post #96
post #3

Earlier quoted context omitted.

What is your main programming language; in which you do most of the work?

C, actually, at the moment. But I don't use C for work or web development.

I hope this thread gave you some idea how important these thing really are.

Re: C Questions and Answers

#119
post #5

He's discussing subtle points of the C language and yet there is no mention of which compiler he's using, whether the results might be different for different compilers, hardware platforms, and how they correlate with multiple C standards (C89, C99, C11/C1X, etc). He succeeded in convincing me that he does not know C!

Do you see anything that depends on which edition of the C standard is being used? I don't.

Re: C Questions and Answers

#120
post #15

Earlier quoted context omitted.

Some would twitch at this: for(i = length - 1; i but it is completely valid.

The twitchers are right. Whoever wrote that line of code is a smartass who is deliberately obfuscating stuff. Don't work with these people!

I prefer to learn, rather than stay ignorant, when I find new tech.

The only people I would not want to work with are ignoramuses and ironically, smart-asses. So you.

Post reply on HN