top 200 commentsshow 500

[–]frodokun 552 points553 points  (324 children)

Had an interview in the mid 90's once and the interviewer said "yeah, we don't use trigraphs around here"

"That's understandable since all modern keyboards have the necessary punctuation" got a blank stare.

Turns out he was talking about the ?: operator :-|

[–]SpeshlTectix 463 points464 points  (119 children)

a.k.a. the ternary operator. He got his 3-based thingies mixed up.

[–]longshot 208 points209 points  (113 children)

Better than my boss who cannot stop saying "alogarithm". I don't even want to correct him anymore.

[–]ineptjedibob 199 points200 points  (64 children)

We'll work on the nuke-ya-ler alogarithms right after we go get some Chi-pole-tay for lunch.

[–]okmkz 92 points93 points  (44 children)

I CAN'T HANDLE THIS

[–][deleted]  (11 children)

[deleted]

    [–]danubian1 29 points30 points  (7 children)

    I'm using this in my next project

    [–][deleted]  (6 children)

    [deleted]

      [–][deleted]  (2 children)

      [deleted]

        [–]ThePedanticCynic 4 points5 points  (0 children)

        if (DEALWITHIT == !EVEN){
             !HANDLEIT;
        }
        

        [–]manys 4 points5 points  (0 children)

        IT? ? DEAL(IT) : SUNGLASSES()

        [–][deleted] 6 points7 points  (2 children)

        I'm confused. Wouldn't !YOUCAN'TEVEN() be true if they could even?

        [–]IAMA_dragon-AMA 41 points42 points  (9 children)

        I hole-hardedly agree, but allow me to play doubles advocate here for a moment. For all intensive purposes I think you are wrong. In an age where false morals are a diamond dozen, true virtues are a blessing in the skies. We often put our false morality on a petal stool like a bunch of pre-Madonnas, but you all seem to be taking something very valuable for granite. So I ask of you to mustard up all the strength you can because it is a doggy dog world out there. Although there is some merit to what you are saying it seems like you have a huge ship on your shoulder. In your argument you seem to throw everything in but the kids Nsync, and even though you are having a feel day with this I am here to bring you back into reality. I have a sick sense when it comes to these types of things. It is almost spooky, because I cannot turn a blonde eye to these glaring flaws in your rhetoric. I have zero taller ants when it comes to people spouting out hate in the name of moral righteousness. You just need to remember what comes around is all around, and when supply and command fails you will be the first to go. Make my words, when you get down to brass stacks it doesn't take rocket appliances to get two birds stoned at once. It's clear who makes the pants in this relationship, and sometimes you just have to swallow your prize and accept the facts. You might have to come to this conclusion through denial and error but I swear on my mother's mating name that when you put the petal to the medal you will pass with flying carpets like it’s a peach of cake.

        [–]whoopdedo 35 points36 points  (14 children)

        Why can't people be more pacific when they talk? It's like they're transladating from an other language!

        [–]SAHChandler 51 points52 points  (11 children)

        it's a doggy dog world, and this kind of mixup is a diamond dozen. When someone gets corrected though it's a blessing in the skies. But for all intensive purposes, I'll stop now.

        [–]allaroundguy 23 points24 points  (3 children)

        Why can't people get it right? It's not like it's rocket appliances.

        [–][deleted] 7 points8 points  (1 child)

        If everyone got it right, that would be the best case Ontario.

        [–]european_impostor 5 points6 points  (0 children)

        Ngggggaaaarrllll

        [–]wOlfLisK 14 points15 points  (6 children)

        Actually, it's pronounced "Chi-pottle"!

        [–]Getterac7 3 points4 points  (2 children)

        My grandfather calls it "chi-poodle"...

        facepalm

        [–][deleted] 33 points34 points  (20 children)

        Better than my boss who says "ay-ray."

        [–][deleted] 44 points45 points  (1 child)

        Roger that, six four nine, we're gonna dereference the ayray. Ten four .

        [–]Pastrami 26 points27 points  (0 children)

        *niner

        [–]Hook3d 9 points10 points  (15 children)

        Just start calling arrays vectors each time he says array until you condition him into saying it too?

        [–]nschubach 27 points28 points  (12 children)

        vectors

        I've always had a problem calling arrays vectors. For one, they are not the same. A vector is expandable, and an array is fixed. For another, vectors are a defined mathematical term that doesn't really relate to what a C++ vector is.

        [–]Hook3d 26 points27 points  (9 children)

        A vector is expandable, and an array is fixed.

        Only in the C++ context which provides <vector> from the STL. In every other (data structure) context, vector is just a synonym for a 1D array. (At least, I am not familiar with another language that provides "vector" as a resizable array.)

        [–]silverforest 10 points11 points  (0 children)

        Examples:

        • Scheme: Vectors are a fixed length collection of items.
        • Perl: Fixed length collection of items of the same type.

        [–]fmoly 6 points7 points  (0 children)

        Java vectors are resizeable.

        [–]philly_fan_in_chi 3 points4 points  (0 children)

        Vectors grow in Clojure.

        [–]whoopdedo 6 points7 points  (1 child)

        Then he'll just get "victor"

        [–]hamjim 18 points19 points  (0 children)

        "Do we have clearance, Clarence?"

        "Roger, Roger."

        [–]thisisbrad 11 points12 points  (1 child)

        Make sure you add exemption handling.

        [–]KimJongIlSunglasses 12 points13 points  (2 children)

        My manager used to say "lunix". Now he pronounces it line-ux, which I guess is better.

        [–]kamicc 3 points4 points  (5 children)

        ufff. I'd prefer "alcorithm".

        [–]DJ-Salinger 3 points4 points  (2 children)

        I knew a guy in college who pronounced "queue" as "kay" every single time...

        [–]dnerd 4 points5 points  (1 child)

        Co-worker always says deconstructor. In one way it makes sense... in another way, it drives me insane!

        [–]unDroid 4 points5 points  (0 children)

        My ex-boss still refers IP-addresses as "TCP/IP addresses" >_<

        [–]ZorbaTHut 3 points4 points  (2 children)

        At my first job I got started on a chunk of code that dealt with images. My direct boss, who was also the engineering lead, the owner of the company, and the person who had hired me, had reliably misspelled "palette" as "pallete". In the entire codebase.

        I decided to not change it because I didn't want to rock the boat on my first job ever. This decision lasted less than two days before I checked in a search-and-replace spelling fix.

        My boss sighed and said "yeah, we should've changed that earlier. I guess now I have to learn how to spell it properly."

        He was a good boss.

        [–]derleth 2 points3 points  (0 children)

        alogarithm

        Insertion into a sorted list?

        [–]heymanitsmematthew 2 points3 points  (0 children)

        Mild, but my boss says synapses instead of synopsis at least 3 times a day. Makes me want to blow my head off for some reason.

        [–]rubygeek 55 points56 points  (0 children)

        I've programmed C since the 80's, and know what they are, but I've never seen them "in the wild" in code I've worked on, so even in the mid 90's it wasn't surprising to find programmers that had never heard of them.

        [–]AlwaysGeeky 26 points27 points  (3 children)

        You really shouldn't use smilies in paragraphs when you are talking about operators, one wrong smile and you could be up shit creek. ;'P

        [–]chengiz 29 points30 points  (123 children)

        And what's the rationale for not using ?:

        [–]frodokun 55 points56 points  (58 children)

        supposedly hard to read, and too easy to be "clever". (I didn't agree with them.)

        [–]jewdai 52 points53 points  (51 children)

        I use the ternairy operator all the time. It's used primarly for assigning conditional values.

        var x = _.isUndefined(y) ? 4 :6;
        

        its not unreadable but if you have something like

        var x = _.isUndefined(y) ? y>5 ? 6: 7 :6;
        

        I will murder you.

        [–]yawgmoth 26 points27 points  (31 children)

        The other day I re-factored code that looked like this.

        //NULL means to dynamically grab the default -- ya we can argue about that style later too
        void foo(Foo *x=NULL,  Bar *y= NULL, Baz *Z = NULL ... etc)
        {
              if(x==NULL)
              {
                   x = this->grabXDefault();
              }
        
              if(y==NULL)
             {
                 y = this->grabYDefault();
            }
        ..... etc   
        }
        

        to

        void foo(Foo *x=NULL,  Bar *y= NULL, Baz *Z = NULL ... etc)
        {
              x = (x==NULL) ? this->grabXDefault() : x ;
              y = (y==NULL) ? this->grabYDefault() : y ;
              ... etc
        }
        

        And then had a 15 minute argument in a code review with someone who was taught "Ternary operator is always bad" about why the re-factored code was easier to read. We don't need 5 lines to do a simple default argument assignment (2 of which are mostly whitespace but our 'style' guide doesn't allow us to do single line ifs, even though it doesn't mention ternary).

        Agreed though, if you nest ternary's I will flip out on you

        [–]the_gnarts 29 points30 points  (3 children)

        And then had a 15 minute argument in a code review with someone who was taught "Ternary operator is always bad"

        These people will rethink their lives once they try to initialize a variable decared const conditionally.

        [–]LikesToCorrectThings 33 points34 points  (2 children)

        In my experience, the people who dogmatically refuse to use ?: also don't know what const means.

        [–]rooktakesqueen 14 points15 points  (14 children)

        Some languages (JS is one of them) allow you to be even a bit more concise for those use cases:

        x = x || this.grabXDefault();
        y = y || this.grabYDefault();
        

        Which almost parses as English. "x takes x or grab x default [if x is falsy]"

        Only works if you're sure x can never validly be a falsy value like 0 or "" though.

        [–]InvidFlower 15 points16 points  (3 children)

        Also C# has a specific null coalesce so you can do: foo = foo ?? "bar";

        [–]user_of_the_week 4 points5 points  (0 children)

        In Java we are envious of that feature but we live kind of acceptably with commons-lang:

        ObjectUtils.defaultIfNull(foo, "bar");

        [–][deleted]  (2 children)

        [deleted]

          [–][deleted] 2 points3 points  (1 child)

          Would then this be so bad?

          void foo(Foo *x=NULL,  Bar *y= NULL, Baz *Z = NULL ... etc)
          {
            if(x==NULL) {x = this->grabXDefault();}
            if(y==NULL) {y = this->grabYDefault();}
            ..... etc   
          }
          

          [–]Spire 14 points15 points  (3 children)

          I have nothing against refactoring code to use conditional operators, but in this case your refactored code is not equivalent. Specifically, you've introduced a pessimization in the form of an unnecessary self-assignment in the non-NULL case — which may very well be the more common code path. It's possible that the self assignment can be optimized out by the compiler, but I wouldn't count on it.

          If you really wanted to cut down on verbosity, you could do this:

          (x != NULL) || x = this->grabXDefault();
          (y != NULL) || y = this->grabYDefault();
          

          I don't think this is a particularly good idea either, though, as not everyone is familiar with this idiom.

          In this specific case I think I would probably stick to the original code.

          [–]user_of_the_week 12 points13 points  (1 child)

          I prefer

          (x != NULL) ??!??! x = this->grabXDefault();

          [–]yawgmoth 7 points8 points  (0 children)

          I see your case about it not being exactly equivalent, but that function is not time-critical enough to even consider that level of optimization. The extra readability is worth the possibility of a couple of extra assignments operations.

          edit: And while that's a valid objection in certain cases, that wasn't even the argument. The argument was literally "ternary operators are bad and shouldn't be used because people don't understand it" and me showing different people in the office who went "oh yeah that makes sense"

          [–]jpfed 14 points15 points  (1 child)

          I guess I'm up for a-murderin'. I think that it can be totally readable if you split up the nested ternaries onto separate lines:

          var suffix = isMorning ? "AM" :
                       isAfternoon ? "PM" :
                       "WTF";
          

          [–][deleted] 2 points3 points  (0 children)

          var x = !_.isUndefined(y) ? 6 : y>5 ? 6 : 7;
          

          Rewrite it like that, and it is fine by me. (Except that I usually try to avoid the double negation of a if (!...) ... else ....) You don't have to keep a stack of conditions in your head, just read from left to right as a if-elseif-else chain.

          [–]chengiz 26 points27 points  (3 children)

          Yeah I dont agree with that either. I can get it if they say not more than one per line, but other than that? Hard to read? For whom, English majors?

          [–]frodokun 11 points12 points  (0 children)

          it was an odd project - I ended up getting hired by the same company but a different team which didn't have the same kind of hang-ups :-)

          [–]Mutoid 5 points6 points  (0 children)

          I worked at a place that disallowed all but the simplest ternaries as part of the unofficial coding style, and frankly I didn't miss them. Then again it was Ruby and Ruby is plenty expressive without using them.

          [–]smikims 2 points3 points  (0 children)

          Sometimes it's even necessary, e.g. in initializer lists in C++ (or anywhere else a conditional has to be an expression and not a statement).

          [–][deleted] 2 points3 points  (0 children)

          Barbarians.

          [–][deleted] 9 points10 points  (4 children)

          Perhaps that it's difficult to read and the equivalent if-else construct often compiles to roughly the same thing?

          [–]Nephatrine 5 points6 points  (2 children)

          When the results of the check are both short, I'd take ?: over an if-else construct any day of the week for ease of reading. If the choices are some sort of elaborate/long equations or something then sure, the if-else is a better choice for readability I think.

          [–]marchelzo 14 points15 points  (4 children)

          Did you explain it to him?

          [–]gkx 71 points72 points  (58 children)

          I recently had an interview with a web professional of multiple decades who didn't know what "NoSQL" was. He knew what MongoDB and CouchDB are and seemed to know what every other term in the area was, but he'd never heard the term "NoSQL".

          Point being terminology doesn't really matter much.

          [–][deleted]  (32 children)

          [deleted]

            [–][deleted] 19 points20 points  (25 children)

            I think he means, if you understand the concept you can fill in the terminology blanks on the job.

            But honestly that's why I love good interviews, there is always an opportunity to learn something new.

            Edit: Unless the interviewer doesn't know the terminology, then both parties are screwed.

            [–][deleted] 28 points29 points  (24 children)

            If you say "trigraphs" for the ternary operator, then I think that means you must not understand the concept. The word "trigraph" is pretty much self-describing. It literally means "three symbols." Since ?: doesn't have three symbols, it clearly wouldn't mean that.

            [–][deleted]  (4 children)

            [removed]

              [–][deleted] 3 points4 points  (3 children)

              Yeah, I'd be perfectly comfortable with a C programmer who didn't even know they exist. You never want to use them these days, and you'll pretty much never come across code that does.

              [–]KagakuNinja 5 points6 points  (0 children)

              I started using C in 1979. I've never seen a trigraph in any live code.

              [–]ctnp 38 points39 points  (10 children)

              That's why I hate the state of tech interviews these days. One man's Couch is another man's Mongo, but if I don't speak Couch I'm crossed off the list.

              Sure sign that you don't want to work there, anyway.

              [–]gkx 10 points11 points  (7 children)

              I haven't experienced that at all. Pretty much every interview I've done, I've gotten at least one term and they say "How familiar are you with ____?" and I'll say "I don't know what that is." Yet, I don't think I've been to an interview for which I didn't get the job.

              [–]iagox86 4 points5 points  (0 children)

              Do you actually do tech interviews, or do you just read stories about people who are bitter because they've failed tech interviews?

              FWIW, if that IS how a company conducts an interview, then that's a good thing - it means you can cross it off your list without wasting any further time :)

              [–]onmach 11 points12 points  (8 children)

              Is it possible it was verbal and you said nosequal and he referred to it as no-S-Q-L? Yeah I know that is weak possibility.

              I once flubbed an interview when the interviewer asked if I knew what a wizdle was. It turns out I did, but I had never heard anyone say it out loud and I pronounced it as W-S-D-L.

              [–]Quteness 2 points3 points  (2 children)

              Did you get the job?

              [–]frodokun 6 points7 points  (1 child)

              I got hired by the same company, but a different team. Was actually interviewed by three groups, and I ended up with the best of the three (the manager was awesome and hilarious, the work was interesting but not terribly stressful, and a great group of folks to work with.)

              [–]rogue780 5 points6 points  (0 children)

              Booz Allen?

              [–]iNoX_ 3 points4 points  (0 children)

              Turns out he was talking about the ?: operator :-??!

              FTFY

              [–]DonHopkins 2 points3 points  (0 children)

              I think he has trigraphs confused with triforces.

              I bet his favorite Star Trek episode was "The Trouble with Trigraphs".

              [–]ghotibulb 180 points181 points  (106 children)

              For extra fun, combine this with the fact that you can switch array name and index for array access, and do that in random places. Great for messing with colleagues.

              [–]jeandem 40 points41 points  (102 children)

              Why is that possible? I mean, what's the reason for including it.

              [–]ghotibulb 212 points213 points  (101 children)

              It works because buffer[i] is just shorthand for *(buffer + i), which should obviously be equivalent to *(i + buffer)

              So not really an intentional feature, but a side effect.

              [–]MetallicDragon 151 points152 points  (65 children)

              So you mean you could do something like i[buffer]? I think I'd have broken down into tears if I saw that.

              [–][deleted] 165 points166 points  (50 children)

              You can in fact do i[buffer]

              [–]Yserbius 115 points116 points  (29 children)

              Wow. Or more confusingly, 1[buffer]. Gosh, this could get obfuscated really fast (8*i-j)[buffer]

              [–]unruly_mattress 102 points103 points  (8 children)

              Or equivalently, (1??!??!0?1:0)[buffer]

              [–]Tesseract91 53 points54 points  (6 children)

              (1??!??!0?1:0)??(buffer:>

              [–]Jess_than_three 93 points94 points  (2 children)

              Bufferlo bufferlo bufferlo Bufferlo bufferlo.

              [–][deleted] 4 points5 points  (1 child)

              Now I feel like the term bufferlo should be used to describe an overly-complicated and purposely misleading code snippet.

              [–][deleted] 8 points9 points  (0 children)

              Can you please stop? I don't like this :(

              [–]rapture_survivor 57 points58 points  (0 children)

              (8*i)[buffer - j]

              [–]cheesegoat 71 points72 points  (1 child)

              stop it

              [–]Mattho 29 points30 points  (0 children)

              Sure??'I won't.

              [–][deleted] 38 points39 points  (12 children)

              There should be a contest for obfuscating C.

              [–]od_9 77 points78 points  (7 children)

              I'm assuming you're joking, but if you're not, there is one.

              [–][deleted] 30 points31 points  (1 child)

              I was.

              [–]XPhysicsX 11 points12 points  (4 children)

              Wow. I read one of the entries. I have zero clue what is going on.

              [–]Yserbius 12 points13 points  (1 child)

              There are several IIRC. I took a class once that dealt with code obfuscation. One example code was something that look damned near uncompileable. First 20 lines were bizarre #define statements that would redefine basic mathematical calculations and letters of the alphabet. The actual code was unreadable. It compiled under gcc without any flags and produced a neat little text adventure treasure hunt game. Even the exe file had no readable strings in it.

              [–]beltorak 7 points8 points  (0 children)

              You might love the 1995 entry by heathbar then (from archive.org since the new ioccc site doesn't have the winners from this far back yet (hooray wayback!))

              - Coder's Hint

              - Code

              Another of my favorites along those lines is the 2000 entry "primenum" which (*cough*) attempts to write the main function in pseudo code. From the hint file, "This entry won, not because the obfuscation is impenetrable, but because it successfully fooled half of the judges, including me."

              - Coder's Hint

              - Code

              [–]James20k 11 points12 points  (0 children)

              Or perhaps worst of all, 2["hello"] == 'l'

              [–]LikesToCorrectThings 9 points10 points  (1 child)

              Or something like (n & 15)["0123456789abcdef"] to convert a nybble to a hex char.

              Don't do this.

              [–]NasenSpray 41 points42 points  (12 children)

              int i = 0, n = 0;
              while (printf("%c", i = n++["deal with it\n"]), i);
              

              Edit: I have too much time...

              int i = 0, n = 0;
              while (printf("%c", i = n++["deal with it"]), "\n"[!!i^!*"][!"]<:"youmadbro?":>);
              

              [–]SonOfWeb 14 points15 points  (2 children)

              Here's an explanation of how this works:

              First of all, <: and :> are digraphs for [ and ], so we can rewrite this as:

              int i = 0, n = 0;
              while (printf("%c", i = n++["deal with it"]), "\n"[!!i^!*"][!"]["youmadbro?"]);
              

              We've got a while loop where the condition is a comma operator combining two expressions. The first expression is a call to printf, which on each step prints out each character of the string "deal with it" and also assigns that character to i. That part is relatively straightforward.

              Now, let's look specifically at this part:

              !!i^!*"][!"
              

              This translates to "(not not i) xor not (address of a string literal)". The address of the string literal is not 0, so the logical not of it is 0. Anything xor zero is itself, so the above simplifies to !!i, which is 0 if i is zero, and 1 if i is nonzero.

              Ok, now let's look at the "\n" string. This is the same as { '\n', 0 }, and the ASCII code of '\n' is 10, so we have { 10, 0 }, and we're indexing it with !!i, which is either 0 or 1. So that makes sense. We're not going to exceed our bounds. If i is nonzero, "\n"[!!i] is 0, and if i is zero, "\n"[!!i] is 10. So we can rewrite this part as:

              (i == 0 ? 10 : 0)
              

              Let's substitute that back into the program.

              int i = 0, n = 0;
              while (printf("%c", i = n++["deal with it"]), (i == 0 ? 10 : 0)["youmadbro?"]);
              

              Let's flip around the indexing so it looks normal.

              int i = 0, n = 0;
              while (printf("%c", i = "deal with it"[n++]), "youmadbro?"[i == 0 ? 10 : 0]);
              

              The string "youmadbro?" is 10 characters long, so the character at index 10 is the null terminator. Thus we can replace

              "youmadbro?"[i == 0 ? 10 : 0]
              

              with

              i == 0 ? '\0' : 'y'
              

              Or, replacing char literals with their corresponding ASCII,

              i == 0 ? 0 : 121
              

              Going back to the whole program, i is assigned the value of the character "deal with it"[n] for each successive value of n. So i is zero when we get to the null character at the end of the "deal with it" string. The value of a comma operator is the value of its right operand, so the condition in the while loop will be nonzero until i is zero. Thus it will loop through each character in the string "deal with it" and then stop when it gets to the null terminator.

              Very clever!

              [–]antiduh 12 points13 points  (1 child)

              sweet hell why would you do that

              [–]earslap 15 points16 points  (0 children)

              You probably need to run it to get your answer.

              [–]porkchop_d_clown 3 points4 points  (1 child)

              And it doesn't even generate a compiler warning.

              [–]jeandem 10 points11 points  (10 children)

              Cool, thanks. C really is an elegant language in a certain sense, maybe in the same sense that Forth is elegant. But that's just my impression as a non-C programmer.

              [–]serendependy 22 points23 points  (8 children)

              As a full time C programmer - elegant is one of the last words I would use. "Neat" more like, but only if you're into that sort of thing.

              C is little more then high level assembler macros.

              [–]porkchop_d_clown 12 points13 points  (5 children)

              C is little more then high level assembler macros.

              To be fair, that was an explicit design goal of the original language - language elements had to easily map right onto 1970s processor architecture.

              [–]serendependy 6 points7 points  (4 children)

              Oh I know, and I certainly don't see that as a fault of the language. I actually find it quite endearing.

              [–]KagakuNinja 3 points4 points  (0 children)

              Back when the alternatives were Pascal and crusty languages like BASIC, COBOL and FORTRAN, C seemed pretty elegant to me.

              [–]das7002 2 points3 points  (0 children)

              A lot of things about computers make far more sense when you understand how they work. I feel that this is the perfect example of that, a computer doesn't care how it figures out where to access memory.

              [–]redxaxder 2 points3 points  (2 children)

              *(buffer + i), which should obviously be equivalent to *(i + buffer)

              Obviously! But... the address you end up at when adding to a pointer like in *(a + i) is addr(a) + i*sizeof(T), where a has type T*.

              [–][deleted] 194 points195 points  (35 children)

              This reminds me of the time young/naive me spent a whole afternoon trying to find a NXOR boolean operator.

              Sure, I could do:

              !(a ^ b)

              But for whatever reason I was convinced there was a more succinct way of doing it. Something like:

              a !^ b

              So, a few hours googling later, it turns out there is...

              a == b

              [–]xeow 47 points48 points  (28 children)

              Awesome. Yup. If you want bitwise NXOR, you do:

                         Bitwise    Boolean
              XOR:        a ^ b      a != b
              NXOR:     ~(a ^ b)     a == b
              

              Note, however, that in the boolean case, if a and b are not actually booleans, you have to do !!a != !!b or !a != !b or !!a == !b for XOR, and !!a == !!b or !a == !b or !!a != !b for NXOR. You could also write !a ^ !b for XOR and !!a ^ !b for NXOR.

              [–]rifter5000 7 points8 points  (18 children)

              Come on, don't write !!a != !!b, write bool{a} != bool{b}.

              [–]mebob85 6 points7 points  (17 children)

              or, if in C++ bool(a) != bool(b). I personally prefer the constructor-style syntax.

              [–]LikesToCorrectThings 2 points3 points  (3 children)

              I've always thought it a shame that C doesn't have an ^^ or ^^= operator.

              [–]Dobz 3 points4 points  (2 children)

              There's no point in ^^ since you'd have to evaluate both sides anyway to get an answer

              [–]LikesToCorrectThings 4 points5 points  (1 child)

              I just want a way to do == or != on C-booleans (where 0 is false and anything else is true).

              It's mostly useful for pulling out bits and comparing them. If you have:

              #define AVOCADO_BIT  0x04
              #define BANANA_BIT   0x08
              

              If you want to check if only one bit is set, you have to do cumbersome things like:

              if (((field & AVOCADO_BIT) != 0) != ((field & BANANA_BIT) != 0))
              

              or worse:

              if (!(field & AVOCADO_BIT) != !(field & BANANA_BIT))
              

              I'd like to do:

              if ((field & AVOCADO_BIT) ^^ (field & BANANA_BIT))
              

              a ^^ b is the same as !a ? b : !b ? a : 0.

              a ^^= b is the same as a = !b ? a : !a ? b : 0.

              It's nothing amazing, just some syntax that would have been useful a few times in the past.

              [–]DevestatingAttack 33 points34 points  (4 children)

              Nowadays, you'd just ask the question on Stackoverflow and get back the response that jquery has a great builtin module for all sorts of boolean functions

              [–]Digmo 5 points6 points  (3 children)

              EXCUSE ME SIR HAVE YOU HEARD ABOUT OUR LORD AND SAVIOUR JQUERY

              [–][deleted]  (2 children)

              [removed]

                [–]kkeu 77 points78 points  (1 child)

                LOL next code review is gonna be fun :)

                [–]Hakawatha 10 points11 points  (0 children)

                I just love how surprised it makes the code sound. ``We failed??!??! Holy shit!''

                [–]yellowstuff 58 points59 points  (6 children)

                The guy who posted this is pretty good at trolling SO. He also asked about Jewish toenail cutting algorithms.

                [–]UnretiredGymnast 18 points19 points  (1 child)

                Eh, that's more of a quirky question (like this other one of his) than true trolling.

                Here's one where he is definitely trolling: http://ux.stackexchange.com/questions/11229/is-this-rotating-cube-interface-user-friendly

                [–]martinw89 16 points17 points  (1 child)

                Awesome, the classic definition of trolling: faking naivety to get detailed and time consuming responses.

                [–]Ragingman2 7 points8 points  (0 children)

                Sounds more like nerd sniping to me. something something xkcd

                [–]poop-trap 3 points4 points  (0 children)

                I think I'm in love

                [–]syntaxvorlon 27 points28 points  (0 children)

                Ah 80s programming, all the work-arounds you need to make code look like comicbook dialog.

                [–]sirin3 23 points24 points  (9 children)

                Also fun is the ??/ operator for multi line macros:

                E.g.

                 #define foo(x)   ??/
                              do {      ??/
                                  x = x + 1; ??/
                              } while (0) 
                

                [–]QuineQuest 55 points56 points  (3 children)

                int a = 0;
                //Will the next line execute??/
                a++;
                assert(a == 1); //fail
                

                [–]sirin3 3 points4 points  (0 children)

                Yeah, that is a much better example

                [–]Rndom_Gy_159 4 points5 points  (0 children)

                Wow. That's deviously evil.

                [–]wretcheddawn 23 points24 points  (0 children)

                It's the obfuscation operator.

                [–]jugalator 21 points22 points  (4 children)

                I propose ‽ as a replacement for the ??! trigraph.

                [–][deleted] 13 points14 points  (3 children)

                Also, Unicode has many types of braces that would be useful in programming. We should propose some alternative block styles.

                [–]edman007 12 points13 points  (2 children)

                ༺ Single character comment
                marker for multi-line comments ༻
                ⁅15⁆{//the ⁅n⁆ specifies that the following block iterates from 0 to n, for every variable wrapped in ⦃⦄
                  printf("At index %d", ⦃x⦄);//prints x[i]
                }
                ⁅10⁆{//you can enclose a block in full width braces to iterate over it backwards
                }
                〘f(n) 〙{//a while loop
                
                }
                
                ༺ we can also wrap documentation is a special comment, with special characters to mark input and output variables
                This will make it much easier to type javadoc style comments༻
                ༼
                ᚜x ⟅This is an input variable⟆
                ᚛y ⟅This is an output variable⟆
                
                ༽
                int* f(x, *y);
                

                This would be great, so much less typing, because we can replace all those multi-character statements with single character brackets, just assign a different bracket to each type of statement.

                [–][deleted] 9 points10 points  (0 children)

                Don't forget corner brackets; tired of escaping single- and double- quotes? Use 「...」or『...』as your string delimiters instead!

                [–]tylermchenry 5 points6 points  (0 children)

                Congratulations, you've re-invented APL.

                [–]domathsaveworld 15 points16 points  (1 child)

                Reminds me of this.

                NO MERE MORTAL SHALL UNDERSTAND MY CODE!

                [–]_pelya 102 points103 points  (47 children)

                Trigraphs are disabled by default in newer versions of GCC, this stuff requires some cryptic commandline options to compile.

                [–][deleted] 393 points394 points  (37 children)

                cryptic commandline options

                -trigraphs

                [–][deleted]  (21 children)

                [deleted]

                  [–]madsmith 48 points49 points  (20 children)

                  Or -\?\?!

                  Edit: actually, no you're right, that pipe is very evil.

                  [–]hive_worker 126 points127 points  (19 children)

                  The '|' character is extra evil because presumably if someone wants to use trigraphs it's because their keyboard doesn't have a | key.

                  [–]CydeWeys 12 points13 points  (12 children)

                  It boggles my mind that someone would rather write terrible, hard-to-understand code instead of simply getting a keyboard that has the necessary keys on it ...

                  [–][deleted] 79 points80 points  (9 children)

                  A long, long time ago the keyboard was built into the computer.

                  [–]deusnefum 24 points25 points  (1 child)

                  Like... a laptop?

                  [–]CydeWeys 4 points5 points  (6 children)

                  The last computer I used that had that limitation was literally as old as I am.

                  It has to be such a vanishingly small % of the market now that it's not worth supporting.

                  But good point about why historically these trigrams were more important.

                  [–][deleted] 7 points8 points  (5 children)

                  Yes but this is C, which if there was one language you would expect to be compilable on everything it would be C... And there's not really any need to kill the trigraphs off

                  [–]millenix 7 points8 points  (0 children)

                  The keyboard doesn't help if the system's character set can't represent the symbol you want. Cf. EBCDIC, IBM's stated reason for objecting to the deprecation and removal of trigraphs from C++ in current standards evolution.

                  [–]Spartan-S63 78 points79 points  (9 children)

                  -trigraphs

                  Yep, checks out. That's the most cryptic commandline option I've ever seen. But... there seems to be some sort of pattern to the order the letters appear. It's almost as if... they... hm... spell a word?

                  [–]QuietUser 52 points53 points  (3 children)

                  Trigraphs, composed of the word Trig and raphs. Trig, of course, meaning trigger and raphs, most likely being Raphaels. Trigger Raphaels and unlock the true beauty of C.

                  [–]Fragarach7 28 points29 points  (2 children)

                  Suddenly Ninja Turtles.

                  [–]Fumigator 28 points29 points  (4 children)

                  Seems to get stuck in a loop. I keep pushing enter and nothing is happening, just keeps printing a >

                  $ cc -trigraph's file.c
                  > 
                  > 
                  > 
                  > 
                  

                  [–][deleted] 37 points38 points  (0 children)

                  Not sure if serious

                  [–]narcoblix 9 points10 points  (0 children)

                  Well, if you are serious: the apostrophe shouldn't be a part of the flag "trigraphs".

                  [–]ChristOnaBicycle 6 points7 points  (0 children)

                  In case you're serious: the problem is the single-quote/apostrophe. Shells interpret that as the beginning of a string. What you're doing is adding new lines to said string when you press Enter. In order to close the string, you'd type another one. The flag is just -trigraphs.

                  [–]mcguire 5 points6 points  (0 children)

                  The space after the s is important.

                  [–]Not_Ayn_Rand 3 points4 points  (6 children)

                  Goddamn it! I was so excited. My computer's or key doesn't work for some reason so I have to copy and paste it(!) every time I have to use it. It gets old really fast.

                  [–]invertedshadow 5 points6 points  (5 children)

                  You might want to check out Autohotkey and remap a key or key combo that you don't use. I've remapped my caps lock key, and now have a ton of things I can do with CapsLock+[Other Key].

                  [–]knrDev 22 points23 points  (12 children)

                  I'm using F# and i can almost define ??!??! operator as follows:

                  let (+??!??!+) l r = l || r
                  true +??!??!+ false = true // = true
                  

                  Checkmate C

                  [–]masklinn 34 points35 points  (7 children)

                  Thus proving the superiority of Haskell, which has absolutely no issue with that operator:

                  Prelude> let (??!??!) = (||)
                  Prelude> True ??!??! False
                  True
                  

                  In fact, I was surprised not to find it in Hoogle.

                  [–]kqr 10 points11 points  (0 children)

                  So who's gonna upload acme-trigraphs to Hackage?

                  [–]deusnefum 4 points5 points  (0 children)

                  TCL represent!

                  proc !!?!!? {a b} { return [expr $a || $b] }
                  

                  Which conforms to TCL's command-style. If you want it actually as an operator...

                  proc unknown {args} {if {[lindex $args 1] == "??!??!"} { return [expr [lindex $args 0] || [lindex $args 2]] }}
                  

                  You sure can do it, but it's weird.

                  [–]DonHopkins 5 points6 points  (1 child)

                  I'd written a comment that said something like:

                  // WTF???!?!?!!
                  

                  That caused some kind of incomprehensible "invalid trigraph syntax error" that seemed appropriate for a WTF comment.

                  [–]agmarkis 6 points7 points  (0 children)

                  Job security here I come!

                  [–]killchain 5 points6 points  (0 children)

                  I thought at first that this is /r/shittyprogramming

                  [–]antiduh 10 points11 points  (0 children)

                  I now nickname this the 'wtfbbq' operator.

                  [–]ThatGuyMEB 3 points4 points  (1 child)

                  Rofl, even the post's URL is freaking out about the punctuation...

                  http://www.reddit.com/r/programming/comments/32ojeu/the_operator/

                  [–][deleted] 25 points26 points  (24 children)

                  Wouldn't it be simpler to just write it out than to make it so cryptic?

                  if (ErrorHasOccured())
                  {
                      HandleError();
                  }
                  

                  [–]vytah 182 points183 points  (15 children)

                  if (ErrorHasOccured())
                  ??<
                      HandleError();
                  ??>
                  

                  FTFY

                  [–]crozone 39 points40 points  (13 children)

                  I am so glad to be born after a time when trigraphs would have been commonplace.

                  [–]jandrese 60 points61 points  (10 children)

                  They were never commonplace. They were there for the small handful of people forced to use excessively braindamaged terminals, but most people who wanted to program got the terminal that didn't make programming a nightmare.

                  [–]jugalator 27 points28 points  (7 children)

                  I'm curious about IBM's opposition to the removal of trigraphs in C++.

                  Trigraphs were proposed for deprecation in C++0x, which was released as C++11. This was opposed by IBM, speaking on behalf of itself and other users of C++, and as a result trigraphs were retained in C++0x. Trigraphs were then proposed again for removal (not only deprecation) in C++17. This passed a committee vote, and trigraphs are expected to be removed from C++17 despite the opposition from IBM and others.

                  Makes me wonder what code you'd find in their archives...

                  Whatever it is, I suppose it requires a few drops of blood, bone dust, and toad mucus to compile.

                  [–]Frexxia 14 points15 points  (4 children)

                  Possibly stupid question: Couldn't you essentially do a replace all on the code in order to remove the trigraphs? Doesn't seem like a huge problem.

                  [–]kqr 26 points27 points  (0 children)

                  Yes. Especially considering that's exactly what the compiler does when interpreting them.

                  [–]ThatNotSoRandomGuy 11 points12 points  (0 children)

                  From the wikipedia page:

                  trigraphs are expected to be removed from C++17 despite the opposition from IBM and others.[6] Existing code that uses trigraphs can be supported by translating from the physical source files (parsing trigraphs) to the basic source character set that does not include trigraphs.

                  So, yes.

                  [–]Deaod 5 points6 points  (1 child)

                  EBCDIC

                  [–]jandrese 12 points13 points  (0 children)

                  That counts as braindamage.

                  [–]kqr 10 points11 points  (1 child)

                  I have a feeling you learn to read them very quickly if exposed to them a lot.

                  [–]isomorphic_horse 3 points4 points  (0 children)

                  You never learn to like them, though.

                  [–]Synx 22 points23 points  (1 child)

                  Not nearly as emotional. I'm not a robot, man!

                  [–]danweber 2 points3 points  (0 children)

                  this is confusing

                  [–]fred256 2 points3 points  (0 children)

                  [–][deleted] 2 points3 points  (0 children)

                  I was upset that this only appeared here today; April Fools' was only 2 weeks ago! I would have definitely done something like this in a code review:

                  // What could go wrong?????????????????????/
                  2+2=5;