Live data from Hacker News

C, what the fuck??!

bowero.nl

21–30 of 38 posts

Re: C, what the fuck??!

#21
post #10

Earlier quoted context omitted.

Nice "No true Scotsman" logic there. Sure, if you see multiple question marks as an indicator of unprofessionalism, then by definition, no professional would use that. At the same time, your definition of professional is not one that is useful in any other context. In code written by people whose job it is, in part, to write code, i.e. what I would call professionals, multiple question marks do sometimes occur.

Did I really produce a Scotsman there? I would break it down like this: * Professionals want to appear professional to the people who pay them. * People who read the code can have an influence on the people who select which professional gets hired. (At least negatively if they find examples of poor practices.) * Professionals therefore avoid any behavior that would be interpreted as unprofessional. * Multiple questio…

I think that last point illustrates the problem: you base your idea of "professional" on the professionals you have worked with or whose code you have read, who might not write such things. At the same time, in code I have read, I have seen it in ways that did not look out of place to me. What that tells me is that this is not a professional vs. unprofessional thing, it is just different programming norms. It is similar to how I think we can agree that neither tabs nor spaces are unprofessional, but insisting on either in a codebase already written using the other style is.

Re: C, what the fuck??!

#22
post #5

This is about that ancient EBCDIC (IBM's ASCII "competitor") specific hack called trigraphs, which in modern compilers are opt-in anyhow: "To understand this, I have to admit one thing: I have to pass -trigraphs to a modern version of gcc before this actually works. " C++17 actually removed support for these.

Trigraphs were not specific to EBCDIC: they were also a bad accommodation for the ISO 646 ASCII variants that supported European languages, which used characters {\|} etc. for letters. This is why the newer better header with alternate spellings for restricted character sets is called

https://en.wikipedia.org/wiki/ISO/IEC_646

Re: C, what the fuck??!

#23
post #6

Earlier quoted context omitted.

The chance of this accidentally happening is almost 0. This is what `gcc` does: `test.c:6:31: warning: trigraph ??/ ignored, use -trigraphs to enable [-Wtrigraphs]`

So it would take some clueless developer who adds the compiler flags to get rid of the warnings during the yearly code cleanup season. Therefore the probability of this happening by accident is 0 but the probability of this happening by incompetence (after the trigraph already slipped in undetected) hovers around 82%.

Sadly, you might have a very good point here.

Re: C, what the fuck??!

#25
post #10

Earlier quoted context omitted.

Nice "No true Scotsman" logic there. Sure, if you see multiple question marks as an indicator of unprofessionalism, then by definition, no professional would use that. At the same time, your definition of professional is not one that is useful in any other context. In code written by people whose job it is, in part, to write code, i.e. what I would call professionals, multiple question marks do sometimes occur.

Did I really produce a Scotsman there? I would break it down like this: * Professionals want to appear professional to the people who pay them. * People who read the code can have an influence on the people who select which professional gets hired. (At least negatively if they find examples of poor practices.) * Professionals therefore avoid any behavior that would be interpreted as unprofessional. * Multiple questio…

> Multiple question marks appear unprofessional and are therefore avoided.

Seems like a really weak assumption to me. Seen enough swear words etc in actual code bases, "???" in bug trackers, ... to think people would worry about the number of "?" they use in comments.

Re: C, what the fuck??!

#27
post #8

Seriously, at this point C should be considered dangerous and should be actively discouraged. I would even go so far as to legislate it. We can't have this sort of thing in 2019.

We don't really have this in 2019. All modern C compilers disable trigraphs by default, so you have to go out of your way to see this in person.

They only existed because really old terminals sometimes didn't have various punctuation characters used by C so they needed the ugly workaround so people trapped on those terminals wouldn't be left out in the cold.

Re: C, what the fuck??!

#28
post #8

Seriously, at this point C should be considered dangerous and should be actively discouraged. I would even go so far as to legislate it. We can't have this sort of thing in 2019.

Please don't comment on the state of programming in 2019 if you're an Angular developer.

Re: C, what the fuck??!

#29
post #22
post #5

This is about that ancient EBCDIC (IBM's ASCII "competitor") specific hack called trigraphs, which in modern compilers are opt-in anyhow: "To understand this, I have to admit one thing: I have to pass -trigraphs to a modern version of gcc before this actually works. " C++17 actually removed support for these.

Trigraphs were not specific to EBCDIC: they were also a bad accommodation for the ISO 646 ASCII variants that supported European languages, which used characters {\|} etc. for letters. This is why the newer better header with alternate spellings for restricted character sets is called https://en.wikipedia.org/wiki/ISO/IEC_646

The reasonable accommodation is to substitute with characters that are available in the ISO 646 ASCII variant being used, preferably the characters with the same binary representation as in US ASCII.

Outside of silly games like IOCCC, did anybody actually use trigraphs? I find it really hard to believe that anybody tolerated trigraphs for serious C programming. Was there an obscure European government agency that actually wrote code with trigraphs?

Post reply on HN