Hacker News new | ask | show | jobs
by threatripper 2374 days ago
What is the probability of something like this appearing in a normal program written by somebody who is unaware of trigraphs?

I am also not aware of any professional who would use multiple question marks in any kind of serious code that could be read by anybody else because that kind would reflect negatively on the perception of his professionalism.

5 comments

The article mentions that they had to explicitly enable it with a compiler flag to get it to work. I doubt any modern compiler would still support these by default.
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.
> What is the probability of something like this appearing in a normal program written by somebody who is unaware of trigraphs?

A good compiler (eg: gcc) will warn if any token is interpreted as a trigraph

Edit: digraph works a bit differently [0]

[0] https://en.wikipedia.org/wiki/Digraphs_and_trigraphs#C

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 question marks appear unprofessional and are therefore avoided. (Or would you concur???)

* I could not find a counterexample in my memory.

If this can be interpreted in a "no true Scotsman" way then it would be: "All Scotsmen who showed the behavior have been denied the citizenship." and then in turn they really wouldn't be true Scotsmen anymore because they lost the citizenship.

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

Please refrain from misusing fallacies.
Pro dev here. I am working on a codebase that is large and juvenile. The original authors didn't know about functions or something; it's pure spaghetti PHP.

I definitely add comments with tons of questions and potential trigraphs when I use punctuation in lieu of actual cursing. Don't get me wrong. I curse a lot in comments, too.

TL/DR: bad code -> angry comments

Similar here. Deepest sympathies.

However: https://www.jetbrains.com/help/phpstorm/refactoring-source-c... ?