Slashdot Mirror


Visual Studio Gets Achievements, Badges, Leaderboards

bonch writes "Microsoft has introduced a gamification plugin for Visual Studio that lets users win achievements and badges as they compete on leaderboards by writing code. The full list of achievements includes gems like 'Go To Hell' for using goto, and 'Potty Mouth' for using five different curses in one file. This is another example of Gamification, one of the latest trends to hit social media."

353 comments

  1. I miss GOTO...there I said it by elrous0 · · Score: 5, Insightful

    I know that the established programmer hierarchy would have me burned at the stake for even hinting at it, but I miss my old GOTO statement. Call it sloppy if you like, but a simple one line statement beats the shit out of the acrobatics I often have to do in Java to SIMPLY JUMP OUT OF THIS METHOD/LOOP TO A SINGLE SPECIFIC POINT IN THE PROGRAM.

                      break;}
              break;}
          break;}
    return;} //shit, still doesn't go where I need it to

    Now, cue the voices of 1,000 programmers looking for a non-existent "disagree" mod and screaming at the top of their girlie lungs on why GOTO is EVIL, EVIL, EVIL--as they parrot the professors who taught them that.

    --
    SJW: Someone who has run out of real oppression, and has to fake it.
    1. Re:I miss GOTO...there I said it by The+MAZZTer · · Score: 5, Insightful

      I would skip GOTO in favor of putting some of that logic into a function. Then I can simply return; from it instead of using a GOTO to break out of as many levels of logic as I need, back to the calling function.

    2. Re:I miss GOTO...there I said it by Robadob · · Score: 4, Informative

      You can use labels in java to break out of nested loops?

    3. Re:I miss GOTO...there I said it by piripiri · · Score: 5, Insightful

      Maybe you shouldn't nest these control structures like this... Flat programming, rings a bell?

      Oblig. KXCD

    4. Re:I miss GOTO...there I said it by Anonymous Coward · · Score: 2, Informative

      What's your problem? Java supports loop labels.

    5. Re:I miss GOTO...there I said it by Anonymous Coward · · Score: 0

      Try the 'continue' statement

      http://docs.oracle.com/javase/tutorial/java/nutsandbolts/branch.html

    6. Re:I miss GOTO...there I said it by Anonymous Coward · · Score: 0

      I'll accept that there may be cases where goto is a good solution. But there's also the possibility that you need to rethink the flow of the function so it's more straightforward.

      Or you could hack an alternative to GOTO with an abuse of exceptions

    7. Re:I miss GOTO...there I said it by gilwooden · · Score: 5, Funny

      You can use labels in java to break out of nested loops!

    8. Re:I miss GOTO...there I said it by Bigfield · · Score: 2

      I agree that goto has it place. Used in a right place it may result in much more readable and maintainable code. But, when used unwisely it will result in spaghetti code. You _can_ write all your code without goto but when your code screams for a goto, use it!

      In you example, however, that deep nesting is just asking for trouble; goto or no goto. ;-)

    9. Re:I miss GOTO...there I said it by elrous0 · · Score: 0

      Maybe you missed the //shit, still doesn't go where I need it to.

      --
      SJW: Someone who has run out of real oppression, and has to fake it.
    10. Re:I miss GOTO...there I said it by dokc · · Score: 1

      Try the 'continue' statement

      http://docs.oracle.com/javase/tutorial/java/nutsandbolts/branch.html

      'continue' statement allies only to one loop level. He wants to jump out from several nested loops.

      --
      In love, war and slashdot discussions, everything is allowed.
    11. Re:I miss GOTO...there I said it by Anonymous Coward · · Score: 0, Troll

      But the fact you were calling break 3 times already suggested you aren't a particularly experienced with Java, if you were you may have thought ahead when designing the algorithm.

    12. Re:I miss GOTO...there I said it by Viol8 · · Score: 1

      Maybe you should try writing a serious program without nested control structures then and show us how it should be done or are you going to suggest just making endless function calls so the code is unintelligable and the cost of push and popping on the stack becomes huge?

    13. Re:I miss GOTO...there I said it by Anonymous Coward · · Score: 5, Informative

      Was why GOTO is a bad idea every explained to you?

      The honest fact is that, if you go low level enough, it (equivalent) is the only method of not proceeding to the next instruction, so you'd think that it would make sense to have it in all the higher languages.
      However, the difference there is each label is (generally) only used once, and the state of all registers will be the same before and after. The problem with goto is that it requires the compiler to work out the meaning of all the variables at the point it jumps to, and to deal with loading those all into memory as part of the jump operation. At least with breaking out of a loop, you're going to be in the same scope as leaving it through the loop's condition becoming false. Returning from that context will move up (or, if you view things the other way, down) a scope, which is reasonable to deal with

      GOTOs, on the other hand, used to allow jumps into noticeably different scopes, where variable contexts could lead to information not having the right meaning. And, that's where the raptors break through.

      [citations needed]

    14. Re:I miss GOTO...there I said it by Sponge+Bath · · Score: 5, Funny

      ...when your code screams for a goto, use it!

      When your code anthropomorphizes, hit the delete key.

    15. Re:I miss GOTO...there I said it by Anonymous Coward · · Score: 0

      Good programmers know when to use (not abuse) the GOTO statement.
      Even Djikstra didn't advocate to the elimination of the GOTO.

      Unfortunately people just took the extreme view on Dijkstra's analysis so we had entire generations of programmers taught to despise and never, ever use the GOTO statemente even in the rare cases where it would have been the fastest and easiest and more readable solution.

    16. Re:I miss GOTO...there I said it by jps25 · · Score: 4, Informative

      The Linux kernel uses goto statements. About 95000 times..

    17. Re:I miss GOTO...there I said it by dkf · · Score: 2

      I know that the established programmer hierarchy would have me burned at the stake for even hinting at it, but I miss my old GOTO statement. Call it sloppy if you like, but a simple one line statement beats the shit out of the acrobatics I often have to do in Java to SIMPLY JUMP OUT OF THIS METHOD/LOOP TO A SINGLE SPECIFIC POINT IN THE PROGRAM.

                        break;}

                break;}

            break;}
      return;} //shit, still doesn't go where I need it to

      Now, cue the voices of 1,000 programmers looking for a non-existent "disagree" mod and screaming at the top of their girlie lungs on why GOTO is EVIL, EVIL, EVIL--as they parrot the professors who taught them that.

      While I'm not averse to using goto as necessary where available, I do try to avoid it as it is distinctly easy to make unclear code with it. With Java you do have the ability to label (and break/continue) loops, and of course you have exceptions and finally clauses to make various cleanup patterns simple. You also have private methods that are really cheap. All that sort of horrible mess that would lead to the precise thing that you're complaining about should be refactored so that it conveys its exact intention clearly instead of spreading complexity all round the place. If all those good things I just mentioned are not sufficient to handle your specific case, I want to know what's going on. (Or maybe I don't; it sounds really scary-bad!)

      Of course, if your real problem is that you're working somewhere with a strict "no break in loops, no return from functions except at end" policy, there's no hope for you. You're doomed by someone in charge who hasn't understood a single thing written about how to analyze programs for the past 30 years.

      --
      "Little does he know, but there is no 'I' in 'Idiot'!"
    18. Re:I miss GOTO...there I said it by TheNinjaroach · · Score: 1

      Not a Java developer, but a quick search for "java break statement" shows you can set labels in your code and then specify them when you break.

      --
      I went to eat some animal crackers and the box said, "Do not eat if seal is broken." I opened the box and sure enough..
    19. Re:I miss GOTO...there I said it by swillden · · Score: 5, Insightful

      The Linux kernel uses goto statements. About 95000 times..

      In the absence of exceptions, goto is a great tool for simplifying and clarifying error handling.

      In a language with exceptions, goto is much less useful. I won't say it's never useful, but if I'm ever tempted to use goto for anything other than jumping to an error handling block, I know I need to take a step back and rethink the structure of the code, because there's almost certainly a better way.

      --
      Note to ACs: I usually delete AC replies without reading them. If you want to talk to me, log in.
    20. Re:I miss GOTO...there I said it by Anonymous Coward · · Score: 1

      Linus Torvalds defends "goto" in the Linux kernel. http://kerneltrap.org/node/553/2131

      "Any if-statement is a goto. As are all structured loops."

    21. Re:I miss GOTO...there I said it by SuricouRaven · · Score: 2

      I don't know about Java, not being a coder in it myself, but in C you can inline small function calls so they don't pushpop. You don't even need to on the very small ones - any decent optimising compiler will do it for you transparently.

    22. Re:I miss GOTO...there I said it by Hentes · · Score: 1

      Exactly that's maybe the only low-level feature where Java is better than C++.

    23. Re:I miss GOTO...there I said it by ilguido · · Score: 1

      That's why the use of the GOTO statement is accepted by the Linux kernel coding style (Chapter 7: Centralized exiting of functions).

    24. Re:I miss GOTO...there I said it by randomsearch · · Score: 2

      Interesting comment, but I'm with Dijkstra on this one:

      http://www.ifi.uzh.ch/req/courses/kvse/uebungen/Dijkstra_Goto.pdf

      RS

    25. Re:I miss GOTO...there I said it by Anonymous Coward · · Score: 1

      Oddly enough, GOTO does have a legitimate use in C#. Switch statements in C# don't fall through. If you want a switch statement to fall through, you have to use a goto ; to force the fall through.

    26. Re:I miss GOTO...there I said it by ifrag · · Score: 2

      The way it's described in the kernel coding style is probably one of the very few "correct" uses of it. In fact, I know we have code here that does exactly that, goto cleanup; then it has a return right after taking care of whatever buffers and such. Initially I was somewhat offended looking at it but after a while I've started to agree with it. In fact, I'd say that use pretty much justifies its continued existence.

      --
      Fear is the mind killer.
    27. Re:I miss GOTO...there I said it by Anonymous Coward · · Score: 1

      Fear not the wrath of your fellow programmers! The COMEFROM statement is a safe and perfectly fine alternative to GOTO.

    28. Re:I miss GOTO...there I said it by tomhudson · · Score: 1
      goto is not evil - it's just hidden inside modern languages. Every switch statement is really a goto, with the case: being a label (target). Anyone who's ever programmed in assembler knows that jmp is not evil.

      Does goto: lead to spaghetti code? That's up to the programmer - not the language feature. You want to see REAL spaghetti code? Look at some of the horrors coming out of Java.

    29. Re:I miss GOTO...there I said it by bstrobl · · Score: 1

      I consider any language which does not have gotos simply crippled.
      Gotos are bad if you have retarded labeling systems (coding on a graphing calculator in BASIC *shudder*) or if you jump all over the code like a kid with ADD.
      But they are great for things such as nested loops.

      Simple example:
      I have an array with ten values which I scan through. If a value in the array matches an expression/whatever, the whole loop can be skipped and a small amount of code following the loop (which would be executed by default if the loop fails to find something) can be skipped as well.
      With Java you can break out of the loop but you would still need to set some stupid variable etc. in order to ignore the code right after the loop.

      Feel free to correct me on this situation. I have been using exactly this for a game I am creating so I think gotos have been very valuable. Then again, I am coding everything in C so there might be OOP equivalents.

    30. Re:I miss GOTO...there I said it by Rhacman · · Score: 1, Insightful

      +1 Why do I never seem to have mod points when I actually care to use them.

      --
      Account -> Discussions -> Disable Sigs
    31. Re:I miss GOTO...there I said it by Dhalka226 · · Score: 2

      I'm not a purist. I don't believe there is anything in a programming language that works fine and yet should never, ever be used. If it is appropriate, use it.

      Obviously I only see the fragment of code you put there (and in all probability you made it up on the spot rather than taking it from an existing codebase) but when I see that level of nesting and then you're still not happy with where the code ends up my first instinct isn't "gosh, a goto would work great here." It's "is this program really structured well?" I'm honestly having trouble thinking of why you would need to nest three levels deep and yet do so in a function without a return value. It sounds like a goto here would just be taking the place of a return value and a switch.

      In any event, my main objection is your attitude. You dismiss calls that it may be sloppy and then declare you use a goto because you want to do exactly what goto does (well no shit, why else would you use it?) and then go on some rant about potential moderations and insult people who might disagree with you as girlie parrots incapable of arriving at a conclusion without regurgitating something they were told by a professor and yet don't understand. I wonder if there is any kind of middle ground to be had? Naaaah.

      Gotos usually are sloppy. If there really is no way to refactor something into a way that doesn't need one, or it is really so egregiously difficult to do that it is not worth the time to do so at any point, so be it -- use it. Usually they are a crutch for bad flow. Insulting people for acknowledging that does not change it. If you are one of those magical programmers who use gotos and yet never misuse them, congratulations. Without knowing you or anything about you, though, I am more inclined to think it's a case of illusory superiority.

    32. Re:I miss GOTO...there I said it by MacGyver2210 · · Score: 1

      If only someone would tell Cyberdyne that!

      --
      If the only way you can accept an assertion is by faith, then you are conceding that it can't be taken on its own merits
    33. Re:I miss GOTO...there I said it by Anonymous Coward · · Score: 0

      I like GOTO, use it in C#. Of course you should not use it often and only in small jumps.

    34. Re:I miss GOTO...there I said it by MacGyver2210 · · Score: 2

      Is it written entirely in ASM?

      --
      If the only way you can accept an assertion is by faith, then you are conceding that it can't be taken on its own merits
    35. Re:I miss GOTO...there I said it by VGPowerlord · · Score: 4, Informative

      Oddly enough, GOTO does have a legitimate use in C#. Switch statements in C# don't fall through. If you want a switch statement to fall through, you have to use a goto ; to force the fall through.

      Unless it's an empty switch statement. Those are allowed to fall-through.

      --
      GLaDOS for President 2016! "Well here we are again. It's always such a pleasure." -- GLaDOS, 2011
    36. Re:I miss GOTO...there I said it by Twylite · · Score: 5, Informative

      Judicious use of GOTO can dramatically simplify resource cleanup when exception handling is not supported. A function that must grab N resources in order (and free them in reverse order on success or failure) requires N nested blocks if you don't use GOTO (and no nesting if you do use GOTO). Often the only way to refactor such logic into sub-functions is by using continuation passing style, which is clear as mud.

      --
      i-name =twylite [http://public.xdi.org/=twylite], see idcommons.net
    37. Re:I miss GOTO...there I said it by Anonymous Coward · · Score: 0

      As Robadob suggested, go read about loop labels.

      Your example did not use labels, so your "//shit ..." is irrelevant to Robadob's post.

    38. Re:I miss GOTO...there I said it by gbjbaanb · · Score: 1

      that might be true today, the the 'goto considered evil' has been around for a lot longer than CPUs with L2 cache.

      The problem was that it used to be used for program flow like it was an while statement. That led to some pretty convoluted and impossible to understand code, and we won't even go into jumping to other function code.

      Nowadays, the idea of using goto as a 'jump to function end' is reasonable, and a lot less expensive than throwing an exception to do the same thing... yes, I've seen them used for that.

    39. Re:I miss GOTO...there I said it by Anonymous Coward · · Score: 0

      Too bad that the main exceptionful languages are C++ and Java where they bring more trouble than worth.

      Java has checked exceptions which means that you need to litter the whole call stack with useless remarks about what each method might throw and using exceptions in C++ eventually forces the whole "C++ way" of coding starting with RAII first, then smart pointers, then templates, stl and finally madness when you end up fixing logic-defying constructor memory leaks in the night while thinking about how easy it would have been to simply "return -1".

    40. Re:I miss GOTO...there I said it by gstoddart · · Score: 4, Informative

      Interesting comment, but I'm with Dijkstra on this one:

      One of my profs once laughed at me when I said his code had a goto and we shouldn't do it that way (because that's what we'd been taught in class).

      Then he sat me down and walked through the code, and explained what the code was doing, and the failure modes that made it necessary to use a goto. This was OS-level code, and performing some very fiddly things, and several layers deep in looping structures. You'd have had to put in twice as much code to check the error conditions necessary to peel out of that, and since it was essentially working on bare metal, there was simply no room to add much more overhead.

      He did manage to convince me that a goto isn't something you do because it's convenient, but that in some code, in some languages there simply isn't a better alternative to bail out of some code in the event of a failure.

      I have worked in a couple of languages (one being C, the other proprietary) in which a goto was the cleanest/only way to get out of the code, and get to a place where you could do all of your cleanup and get out cleanly.

      It has its place, but it should definitely be used sparingly. Blindly saying never use a goto doesn't always give you the best solution.

      --
      Lost at C:>. Found at C.
    41. Re:I miss GOTO...there I said it by Chris+Mattern · · Score: 1

      when your code screams for a goto, use it!

      When my code screams at me, it's time to go home and get eight hours sleep.

    42. Re:I miss GOTO...there I said it by Anonymous Coward · · Score: 0

      C without libc pretty much is assembler...

    43. Re:I miss GOTO...there I said it by Anonymous Coward · · Score: 0

      Try refactoring to call functions instead of GOTO.

    44. Re:I miss GOTO...there I said it by nahdude812 · · Score: 2

      There are a handful of times where goto is simply the most elegant solution, and a handful of times where performance really matters, so encapsulating logic into a function to avoid a goto will be too costly. I've used it once since my high school BASIC days; interestingly it was only a few months ago.

      We had a costly operation working against arbitrary precision numbers, with some nondeterministic aspects. Part of the data produced is very publicly visible, and because of the nondeterministic aspects of things, we had an incident where some undesirable output was produced (valid by system design, but humans found it offensive). So rather than restart the whole operation to let the nondeterministic side of things produce something more desirable, we want to change just a chunk of the data and jump back into the middle of things to recompute the downstream results.

      I know I'm being vague, I have to be. I wrote the procedural equivalent, and not only did it separate tightly related logic, the performance cost was significant at this scale, even for the non-exception scenarios, and the amount of markup to support it was prohibitive. It also actually upped the CRAP score (which was already unusually high because the focus was on performance optimization). The goto alternative was literally two lines: one label and one goto, and introduced essentially no overhead for the most common use case (the vast majority of the time the produced data contains nothing offensive).

      I'm still embarrassed by it, but even now going back and looking at it, I'm not sure how I would do it in a more readable or performance equivalent manner. I made sure to include a link to this comic in the source next to it, along with a clear description of why that was the path chosen over a more traditional approach.

      I could be that I just fundamentally structured the flow wrong. Maybe there there was a better path through this. My team mates ribbed me for using the goto, but agreed that it was both more readable in the end, and observed the performance cost of the alternate approach; a rare exception was made in code review to allow this.

    45. Re:I miss GOTO...there I said it by ais523 · · Score: 3, Informative

      The purpose of goto is to stand in for whatever control structures your language needs but doesn't have. Goto for error cleanup in C is one of those examples: it's the best way to do it in C, but if the language had better support for doing that, a goto wouldn't be necessary.

      --
      (1)DOCOMEFROM!2~.2'~#1WHILE:1<-"'?.1$.2'~'"':1/.1$.2'~#0"$#65535'"$"'"'&.1$.2'~'#0$#65535'"$#0'~#32767$#1"
    46. Re:I miss GOTO...there I said it by AaronLS · · Score: 4, Insightful

      Sometimes algorithms have complex break conditions. You are arrogant to judge so quickly when all you have is a code snippet. I love these people who glance at some code and then say "you should refactor/redesign that" and offer no more than vague suggestions. In situations where I have the authority, I respond by assigning them the task they themselves suggested. Guess what I do when they fail at the very task they themselves so derogatorily suggested?

    47. Re:I miss GOTO...there I said it by Lumpy · · Score: 1

      I use GOTO all the time. In fact all low level language programmers do.

      JMP is the Goto of Assembly

      --
      Do not look at laser with remaining good eye.
    48. Re:I miss GOTO...there I said it by Anonymous Coward · · Score: 0

      There are three schools of programmers. Ones who actually know what they are doing and are skilling enough to use goto sanely and properly. There is the egotistical programmer who things they are much better than they actually are and THINK they have the intelligence and skills to use goto sanely. And then there are those who simply tote the company line and just follow best practices. There is nothing wrong with the first and last group. The real problem is the second group which gives the first group a really bad name and keeps the third group in check because of the problems the second group creates.

      In other words, nobody ever got fired for NOT using goto.

      Contrary to popular myth, use of goto can occationally be benefitial and even produce cleaner, terser code. But that middle group has to screw it up for everybody. Which ultimately means, goto winds up being shunned.

    49. Re:I miss GOTO...there I said it by Synerg1y · · Score: 1

      Goto is great when nothing else is / was available, but in any modern object oriented language, if you can't properly adjust your variable's exposures then you don't need to code imho.

    50. Re:I miss GOTO...there I said it by alexo · · Score: 2

      shit, still doesn't go where I need it to

      Allow me to introduce you to the modern wonders of indoor plumbing.

    51. Re:I miss GOTO...there I said it by Tsingi · · Score: 0

      OK, I'll say it. Programming languages provide semantics for control that encourage consistently predictable program flow. No one says you have to use it, or use any other features that a language provides. The features are there to provide structure and readability for humans, not the computer. If your code is always perfect and you don't make mistakes, I might suggest you try assembly, or even better, machine code. You can do anything you want and are completely relieved of these nuisance language features.

      If you do make the occasional mistake, the first thing you should stop doing is using goto, it seems that throwing the instruction pointer around in unpredictable ways can mess up stack pointers. After that, you might look at avoiding the use of pointers. Pointers cause the majority of security problems. That would fall to goto, but most people are smart enough to avoid using it.

    52. Re:I miss GOTO...there I said it by Karrde712 · · Score: 3, Informative

      GOTO is certainly very useful in some circumstances. For example, a common pattern in the samba and SSSD sources is this (taking advantage of the talloc() hierarchical memory allocator):

      tmp_ctx = talloc_new(parent_ctx).
      *allocate memory on tmp_ctx *
      do stuff or fail and goto done.
      *allocate more memory on tmp_ctx *
      do stuff or fail and goto done.

      done:
                      talloc_free(tmp_ctx);
                      return result;

      It's really handy to be able to just jump directly to the done: tag on any error and know that any memory you allocated is cleaned up appropriately.

      --
      You may treat all information submitted above as wild speculation.
    53. Re:I miss GOTO...there I said it by forkfail · · Score: 1

      State variables are your friend.

      --
      Check your premises.
    54. Re:I miss GOTO...there I said it by DrXym · · Score: 1
      This code tests if i == j and breaks out of the unlabelled inner loop and goes to the labelled "outer" loop. Works a bit like a goto in this case. Otherwise flatten out your nesting, set and test boolean flags to drop out or if necessary decompose your function into several functions.

      outer: for (int i = 0; i &lt; 100; i++) {
      for (int j = 0; j &lt; 100; j++) {
      if (i == j) {
      break outer;
      }
      // Some other code
      }
      }

    55. Re:I miss GOTO...there I said it by DrXym · · Score: 1

      Gah and replace the < entities with the less than sign

    56. Re:I miss GOTO...there I said it by Anonymous Coward · · Score: 0

      To me the way i would code this;
      if(!arraysearch(array, value)){
      //code to execute when item is not found.
      }

      The possible downside of this would be that you don't wish to create/use a separate method for searching arrays, however it makes the code more readable for my eyes and allows you to call it from elsewhere as necessary.

    57. Re:I miss GOTO...there I said it by DrXym · · Score: 1

      That's what the finally keyword is for. If you have to free resources, write a finally block. Granted it can still be a pain in the arse in Java especially with input or output streams where to free a resource you have to close() it, but close() throws its own exceptions so you need to nest try / catch blocks inside the finally block. Java 7 improves the syntax but that isn't much use for older code.

    58. Re:I miss GOTO...there I said it by JoeCommodore · · Score: 1

      in many forms of early BASIC GOTO was necessary, case in point many conditionals were limited to a single line (IF THEN statements) and if you had code that could not fit in that line you needed to use a GOTO to skip over the code. You could have hacked it in with a GOSUB, but it starts looking more like spaghetti code on top of poor formatting of line number BASIC.

      Moving past BASIC to C, other languages, you had lest restrictive syntax limitations so GOTOs are not necessary anymore.

      --
      "Enjoy what you're doing! If it becomes drudgery, you're doing it wrong!" - Jim Butterfield
    59. Re:I miss GOTO...there I said it by Anonymous Coward · · Score: 0

      You can always allocate resources in order and set a variable to say how far you got. Then use a drop through switch statement on that variable to free the resources (obviously listed in reverse order). Fundamentally you're using the switch statement as a goto with a set of labels with the jump determined by the variable, the important thing is that it doesn't set off the company GOTO detectors.

    60. Re:I miss GOTO...there I said it by MozeeToby · · Score: 1

      If a goto would improve the flow of your program odd are high (think: 99.9%) that your program wasn't designed correctly.

    61. Re:I miss GOTO...there I said it by vgerclover · · Score: 2

      Blindly saying never use a goto doesn't always give you the best solution.

      Blindly saying never do X hardly ever gives you the best solution.

    62. Re:I miss GOTO...there I said it by Anonymous Coward · · Score: 0

      > but in C you can inline small function calls
      Source for this?

    63. Re:I miss GOTO...there I said it by devman · · Score: 1

      You can use break and continue with labels in Java to esacape out of more than one level.

    64. Re:I miss GOTO...there I said it by Twylite · · Score: 5, Informative

      [citations needed]

      Citations won't be found, because the explanation is incorrect. There is no technical issue with compilers implementing 'goto' so long as the destination is in the same lexical scope (C has this limitation). Nor is it worth considering execution context at the level of the CPU, as any high-level loop or branch instruction must be translated into one of a limited number of conditional or non-conditional, relative or absolute jumps. Ultimately whether you use 'goto' or some other control construct you are attempting to express the same programmatic flow, and the compiled instruction stream will be sufficiently similar that it's not worth splitting hairs over.

      The reason 'goto' is "considered harmful" is because structured programming theorizes that any computable function can be expressed by combining simpler programs using sequence, selection and iteration; and this provides the opportunity for a constructive approach to program correctness. Dijkstra argues that we are cognitively limited and can benefit from code that is structured so that we can tell at any point where we are and where we have come from (a gross paraphrasing of what Dijkstra calls "coordinates"). But "[t]he unbridled use of the go to statement has as an immediate consequence that it becomes terribly hard to find a meaningful set of coordinates in which to describe the process progress". In other words careless use of 'goto' makes it hard to reason about your code.

      Knuth contended that one could created structured programs with 'goto' statements, and provided examples of how 'goto' make the program more elegant.

      It is important to realise that the claimed advantages of structured programming are undone by the use of break, continue, or exception handling. There are limited forms of goto, and using them prevents proofs of correctness (under the assumptions of structured programming; other techniques may be available) and reasoning using Dijkstra's "coordinates".

      --
      i-name =twylite [http://public.xdi.org/=twylite], see idcommons.net
    65. Re:I miss GOTO...there I said it by Anonymous Coward · · Score: 0

      array find { x => val t = frobnicate(x); t>x } getOrElse { calculate(default) }

      Functional way FTW.

    66. Re:I miss GOTO...there I said it by Twylite · · Score: 1

      Suit yourself, but I'll take Knuth over Dijkstra: http://pplab.snu.ac.kr/courses/adv_pl05/papers/p261-knuth.pdf.

      --
      i-name =twylite [http://public.xdi.org/=twylite], see idcommons.net
    67. Re:I miss GOTO...there I said it by tepples · · Score: 1

      A function that must grab N resources in order (and free them in reverse order on success or failure) requires N nested blocks

      If you have to free resources, write a finally block.

      A function that must free N resources in reverse order still requires seven nested try blocks, each with its own finally block.

    68. Re:I miss GOTO...there I said it by Robadob · · Score: 1

      http://msdn.microsoft.com/en-us/library/06tc147t.aspx
      The Microsoft documents actually tell you to use goto in this case.
      I'll accept that when the language documentation tell you to use goto in a case it's acceptable and their examples keep the code readable. However i've always been taught from when i started to program that goto's were bad and to be avoided and i've never come across situations where i have had to use them.

    69. Re:I miss GOTO...there I said it by Lumpy · · Score: 1

      Because of GoTo my embedded code runs 2X faster than any of the noobs here at work that have to code in all the extras to avoid using a goto.

      When my chip processes incoming data 2X faster than the other guys, Mine makes it into the final product, not theirs.

      Yes, there are a LOT of situations where every single byte and instruction counts.

      --
      Do not look at laser with remaining good eye.
    70. Re:I miss GOTO...there I said it by Anonymous Coward · · Score: 0

      Honestly, when it comes to understanding program flow, exceptions are worse than goto. At least there's only one place goto goes (assuming your language doesn't allow variables for goto). Throw an exception, and you'll have to figure out where you were called from, see if it handles it, where that was called from see if it handles it where that was ...

    71. Re:I miss GOTO...there I said it by DrXym · · Score: 2

      No it doesn't need 7 (assuming N = seven) nested blocks. You could put the variable declaration outside the block assigned to null and then test if the value is null inside the finally, if its not null then do what you have to do to release it. If the values were all the same type it would be trivial to write a loop to do this 7 times. Or write some kind helper method that you call 7 times to do the job. But if you really have 7 resources, then maybe it's time to think about decomposing the code into more manageable chunks.

    72. Re:I miss GOTO...there I said it by Twylite · · Score: 1, Interesting

      Mmm. Yes. Very good class. Let's try again shall we?

      Judicious use of GOTO can dramatically simplify resource cleanup when exception handling is not supported

      And what is finally? That's right, it's part of the exception handling system. The concept of a "finally block" only makes sense if there are multiple paths by which the block can be reached (the normal path and the exceptional path); otherwise it would just be a statement at the end of the normal path.

      Now, what about C? This is an important question because there are still (shock, horror!) some embedded environments that don't have a Java runtime environment. Why not, you may ask? Because they have 2kb code space and 512b memory!

      So, what about C? Well, it doesn't have exception handling built in (more shock, more horror!). Instead, C programmers must check the result of each function call and branch to cleanup block if the result indicated an error.

      </condescending >

      --
      i-name =twylite [http://public.xdi.org/=twylite], see idcommons.net
    73. Re:I miss GOTO...there I said it by Anonymous Coward · · Score: 0

      While ( 0 == 0)
          {
              System.out.println("You can use labels in java to break out of nested loops!");
        }

    74. Re:I miss GOTO...there I said it by Viol8 · · Score: 1

      Misusing inlining dozens is a piss poor way to program not least because it'll lead to huge binary sizes and the code will still be impossible to follow.

    75. Re:I miss GOTO...there I said it by emandres · · Score: 1

      Sounds a lot like the use case for a try/finally block (obviously not available in C). I agree that GOTO has its uses, but you better have a dang good justification. The above code is one of them.

      --
      The only way to tell the difference between a hamster and a gerbil is that the hamster has more white meat.
    76. Re:I miss GOTO...there I said it by NoSleepDemon · · Score: 1

      From a technical standpoint though, function calls are fairly expensive so maybe you should avoid calling the function in the first place if you're going to just hit a return in it. Also if you have a lot of returns in a function that break out of several nested loops or if statements it can be tricky to follow the program's execution without stepping through it with a debugger.

    77. Re:I miss GOTO...there I said it by Twylite · · Score: 3, Insightful

      Yes. We used to do that in some of our source code bases. I always like how "important programmers" at "big companies" think 'goto' is verboten, but don't notice switch statements with fall-through cases. Because they're sooo much safer ;)

      So I reversed that situation, and our incidence of resource handling errors went down markedly. As did our incidence of logic bugs from failing to break out of a switch.

      In my opinion, obscuring the logic you're trying to express by using a workaround involving an arbitrarily "approved" keyword, obscures the logic.

      --
      i-name =twylite [http://public.xdi.org/=twylite], see idcommons.net
    78. Re:I miss GOTO...there I said it by tepples · · Score: 1

      If you do make the occasional mistake, the first thing you should stop doing is using goto, it seems that throwing the instruction pointer around in unpredictable ways can mess up stack pointers.

      As I understand it, in C-like languages, goto within a function is guaranteed to fix any changes to the stack pointer that the start and end of a scope may have introduced. Especially in C, it's probably the cleanest way to simulate exceptions for cleaning up allocated resources.

      After that, you might look at avoiding the use of pointers.

      In Java, everything that isn't a primitive is a pointer. If by "pointers" you meant pointers in the C sense, or values on which one can do pointer arithmetic, dropping "pointers" entirely would mean accepting the RAM bloat and throughput penalty that a profiler shows for managed code compared to native code. There are some cases where you really do need your code to be as fast as C, especially on a handheld device.

    79. Re:I miss GOTO...there I said it by NoSleepDemon · · Score: 1

      Yes but at that point you're taking a really convoluted path to a solution simply to avoid the use of goto when perhaps it might have been warranted. If you're really adamant in not using goto, you probably shouldn't be designing unwieldy surrogates for it either.

    80. Re:I miss GOTO...there I said it by Anonymous Coward · · Score: 0

      They did, but the code kept coming back

    81. Re:I miss GOTO...there I said it by ByOhTek · · Score: 1

      I agree, there are times where goto neatens up a bit of code without having to have all the brackets of if/else, or scrolling of function

      if(prep_function_one(...)) //true on fail
          { GOTO ONE_FAIL; }
          if(prep_function_two(...)) //true on fail
          { GOTO TWO_FAIL; }
          if(prep_function_three(...)) //true on fail
          { GOTO THREE_FAIL; }
          if(prep_function_four(...)) //true on fail
          { GOTO FOUR_FAIL; }

      FOUR_FAIL:
          cleanup_four(...);
      THREE_FAIL: //no extra work above/beyond two...
      TWO_FAIL:
          cleanup_two(...);
      ONE_FAIL:
          cleanup_one(...);

      as opposed to...

      four(...)
      { //...
      }

      three(...)
      { //...
          if(four(...))
          {
              cleanup_four();
              return true;
          } //...
      }
      two(...)
      { //...
          if(three(...))
          {
              cleanup_three(...);
              return true;
          } //...
      }
      one(...)
      { //...
          if(three(...))
          { //cleanup_two(...); //might be needed later, placeholder
              return true;
          } //...
      }

      main()
      {
          if(one(...))
              cleanup_one(...);
      }

      yeah, call me nuts, but I'll take the gotos in that situation.

      --
      Self proclaimed typo king, and inventor of the bear destroying coffee table (patent not pending).
    82. Re:I miss GOTO...there I said it by Rary · · Score: 5, Insightful

      People misunderstand the point of the whole "goto is evil" thing. It's not that jumping around in code is evil. No program of any real value can run sequentially from start to finish. You have to jump around to do anything useful. Conditional processing, iteration, function calls, and exception handling all involve jumps of one kind or another. Whether the language calls it "goto" or gives it a different name doesn't change the fact that it's a jump.

      However, there are a set of logical, structured jump patterns that have been well defined over the decades which produce readable, understandable, debuggable, extendable, logical code. These patterns include the constructs I described previously. Some languages have specific keywords for these constructs, while others rely on the keyword "goto" for their implementation. There's nothing wrong with using "goto" to implement one of these logical patterns, if that's how the pattern is implemented in that particular language.

      However, it is possible in languages that have a "goto", to execute a jump that is outside of these known patterns. These illogical, seemingly random jumps result in code that is confusingly obfuscated, and consequently more error-prone, as well as harder to extend.

      So, when people say "goto is evil", they're really saying "unstructured jumps are evil". Using such a construct might accomplish what you're trying to accomplish, but it will generally do so at the expense of readability, maintainability, and extendability of the code.

      And yes, any language, whether it has a "goto" or not, can be abused by a properly (un)skilled programmer to create a chaotic mess of spaghetti code.

      --

      "You cannot simultaneously prevent and prepare for war." -- Albert Einstein

    83. Re:I miss GOTO...there I said it by Anonymous Coward · · Score: 0

      JavaScript has an optional 'label' for its 'break' statements to break out of a specific loop. Perhaps something like this could be added to Java.

    84. Re:I miss GOTO...there I said it by Viol8 · · Score: 1

      Quite. Sometimes I wish I could just go back to just coding in C. It takes longer to write than C++ but its a damn sight less hassle to maintain in the long run.

    85. Re:I miss GOTO...there I said it by NoSleepDemon · · Score: 1

      Writing good code is like making love to a beautiful woman...

    86. Re:I miss GOTO...there I said it by Rary · · Score: 1

      Programming always involves trade-offs. Coding with a "goto" makes code more obfuscated. However, if your project prioritizes performance over maintainability of code, and a "goto" increases performance, then it's the right trade-off to make.

      --

      "You cannot simultaneously prevent and prepare for war." -- Albert Einstein

    87. Re:I miss GOTO...there I said it by blueg3 · · Score: 3, Interesting

      Parent is actually combining two different "this". Functions that don't need the full calling system can use an alternate fast calling system that's less expensive. Optimizing compilers can do this automatically. Separately, small functions (or functions called once, or non-small functions) can be inlined, usually automatically. It's usually documented in the compiler optimization options, for one.

    88. Re:I miss GOTO...there I said it by Anonymous Coward · · Score: 0

      Sometimes just returning will cause memory leaks (this is why returning early can be very bad), sometimes break won't cut it. goto cleanup; is the only option sometimes to not duplicate needlessly every line of code to be sure memory is taken care of. with out the goto every error state condition would need the same code (a call to the destructor function(s), free) duplicated. What if you (or a junior programmer) misses a free when doing maintenance. At least being in the mind set of taking the time to set cleanup: even if you don't use a goto statement, will give the function/method a better chance of not having memory issues, because all the free(s) are in one logical place before the return. I'm discussing general situations with a main/controller/handler function. Not all functions/methods are created the same or have the same design purposes. Bottom line the goto statement is still has a place when used correctly. Oh and before you ask, I use real programming languages and I subscribe to the MRR/MRC memory philosophy. All you Garbage Collector fan boys can, well, goto hell: pardon the pun.

    89. Re:I miss GOTO...there I said it by Anonymous Coward · · Score: 0

      Code like that is usually a sign you need to refactor...

    90. Re:I miss GOTO...there I said it by Tsingi · · Score: 1

      In Java, everything that isn't a primitive is a pointer. If by "pointers" you meant pointers in the C sense, or values on which one can do pointer arithmetic, dropping "pointers" entirely would mean accepting the RAM bloat and throughput penalty that a profiler shows for managed code compared to native code

      No kidding. Queue up redundant pointer/reference argument.

      If you want your code to be as fast as c, I recommend writing it in c. Every higher level language I use allows you to link it in. As for goto in c, well, you are in c, shooting yourself in the foot is something you should be constantly wary of if you are going to code in it. I expect you will be using pointers and pointers to pointers and pointers to functions and possibly even inline asm and goto statements, if the benefits are too huge to resist. But you are also going to have to be an experienced hand with these things or you are going to suffer. I don't think that this discussion targets people who have been coding c for 30 years.

    91. Re:I miss GOTO...there I said it by Borov · · Score: 1

      Maybe I misunderstand your intention, but what nesting do you need? Wouldn't this work the same way, with only one level of indentation:

      N=2
      <pre>
      res1 = grabRes();
      if (grabbed(res1))
          res2 = grabRes();
      if (grabbed(res2))
      {
          do_stuff();
          ungrab(res2);
      }
      if (grabbed(res1)
        ungrab(res1);
      </pre>

      Could be easily rewritten to have a loop that does it all (two loops to be honest, one for ungrabbing, unless you want hard to analize code with one loop doing it all ;) )

      --
      http://www.bordev.pl
    92. Re:I miss GOTO...there I said it by adonoman · · Score: 1

      That's why you use C++ and RAII. It all gets done by the descructors.

    93. Re:I miss GOTO...there I said it by TheLink · · Score: 3, Informative

      I would skip GOTO in favor of putting some of that logic into a function. Then I can simply return;

      Sometimes that makes the code harder to read - you have to go look up what each function does, when it's actually a different but simple thing each time.

      Visual Studio does make the looking up quite easy (and you can nav back to the original place from the function), but it still takes longer than just looking at everything in one page and then scrolling a bit to see the rest.

      And lastly, you often have to come up with decent names for those functions ;). Sometimes coming up with good names takes longer than just writing the code...

      --
    94. Re:I miss GOTO...there I said it by aztracker1 · · Score: 1

      Regarding the strict no function returns except at the end.. I almost unconditionally return early to avoid extra loops for any if/else condition, where the shortest is used as the if or if-not to return early. IMHO this helps mitigate deeply nested code. I also tend to use anonymous functions/lambdas where available as well.

      --
      Michael J. Ryan - tracker1.info
    95. Re:I miss GOTO...there I said it by johny42 · · Score: 2

      I don't know about Java, not being a coder in it myself, but in C you can inline small function calls so they don't pushpop.

      Whoever reads the code still has to pushpop (mentally) to understand what it does. Many programmers underestimate how much it adds to readability if you're able to just read a chunk of code line by line instead of jumping back and forth (often between multiple files).

    96. Re:I miss GOTO...there I said it by aztracker1 · · Score: 2

      Should probably link to the original source. :)

      --
      Michael J. Ryan - tracker1.info
    97. Re:I miss GOTO...there I said it by adonoman · · Score: 1

      like it was an while statement

      Or worse - combined with exclusively global variables as a replacement for function calls. I was one of the poor souls who learned to program on BASIC, using those books with programs you could type in and run. Several of the books had all variables named A1, A2, A3... B9....X, Z. Only ever used conditional gotos to change program flow, had no concept of dynamic memory...

      It was years before I dragged myself past all that - I distinctly remember my mind being blown in high school when I started C and learned about function calls, and dynamic memory, and recursion - even usefully named variables!

    98. Re:I miss GOTO...there I said it by Anonymous Coward · · Score: 0

      In C++ you can do this using a locally scoped class. Consider a hypothetical Talloc class:


      void some_func()
      {
              Talloc tmp_ctx (parent_ctx);
              * allocate memory on tmp_ctx
              * do stuff or fail and return result;
              * ...
              return successful_result;
      }

      When execution leaves the scope of some_func(), tmp_ctx is destroyed immediately, and you can do your deallocation in the destructor. Same result, no goto. This is the idea behind things like Boost's scoped_ptr and relatives. (Of course, you can't do this in Java)

    99. Re:I miss GOTO...there I said it by Anonymous Coward · · Score: 0

      Very informative, thanks!

    100. Re:I miss GOTO...there I said it by Guignol · · Score: 1

      But sometimes it does, does it not ?

    101. Re:I miss GOTO...there I said it by Anonymous Coward · · Score: 1

      No-one here has ever experienced it?

    102. Re:I miss GOTO...there I said it by aztracker1 · · Score: 1

      Agreed, embedded, OS level code, and some limited use cases should favor performance first. Also, depending on the language and language features (C for example), GOTO is probably the best option for certain types of control flow and cleanup. That said, I think if you are working in most higher level languages, it shouldn't be needed. Personally I think inline functions/lambdas tend to look nicer, but it depends on your needs.

      --
      Michael J. Ryan - tracker1.info
    103. Re:I miss GOTO...there I said it by need4mospd · · Score: 1

      Reversing the order of that analogy would be more appropriate here.

    104. Re:I miss GOTO...there I said it by Anonymous Coward · · Score: 0

      Maybe people don't like GOTO statements because they are jealous since it feels so much like teleportation, which we can't do.... yet.

    105. Re:I miss GOTO...there I said it by gbjbaanb · · Score: 1

      ah yes, I learned how to program the same way - or at least, what programming way before I learned how to do it using best practices (or mostly best practice ;) )

      Those early BASIC interpreters didn't handle much more than 2-digit variables and some of that learning is still with me - to this day, I still use x, y, and i.

    106. Re:I miss GOTO...there I said it by rwa2 · · Score: 1

      Heh, with python tkinter, it's standard practice to set up event loops by having functions call themselves (with all of its parameter objects included) at the end, and simply not worry about returning from any of the recursive function calls, ever.

    107. Re:I miss GOTO...there I said it by rwa2 · · Score: 1

      That's what you get for letting slip in an errant "import skynet" statement...

    108. Re:I miss GOTO...there I said it by Anonymous Coward · · Score: 0

      GOTO isn't all that useful in languages which support RAII-like structures. I can understand using it for that purpose when writing in C or using C libraries in C++, but I'd opt for a cleaner RAII wrapper in higher level languages.
      That said, I'm not an anti GOTO zealot and would use it if it's the best tool for the job.

    109. Re:I miss GOTO...there I said it by Mobius+Evalon · · Score: 2

      The issue with goto is that it is a supremely useful language construct that resides on the far end of Caveat Valley. Egregious use by those who are inexperienced far outnumbers proper use by those who employ it correctly, because it is somehow more attractive than the construct they really need, which is generally break.

      Goto and other program 101 are at such a basic level that those who generally require education on its proper deployment are too inexperienced to comprehend an example that displays its proper use. Instructors just take the fire and brimstone approach and declare goto is a sin just to simplify the process. It's a victim of character assassination.

      --
      Potatoes are friggin' magical. Can you power an alarm clock with a carrot? No, sir!
    110. Re:I miss GOTO...there I said it by Anonymous Coward · · Score: 0

      I remember classmates who, when introduced to functions and procedures, stubbornly refused to use arguments and insisted on passing data through global variables. Could never understand them.

    111. Re:I miss GOTO...there I said it by SuricouRaven · · Score: 1

      Sometimes speed is more important than binary size. Just so long as you remember to keep your loops small enough to fit in cache.

    112. Re:I miss GOTO...there I said it by Anonymous Coward · · Score: 0

      This is 2012. Stop using VBA in Excel 2003 and start using something which supports TRY... FINALLY or equivalent.

    113. Re:I miss GOTO...there I said it by Anonymous Coward · · Score: 0

      And that's where you get the achievement mentioned in the summary for using curse words

    114. Re:I miss GOTO...there I said it by Anonymous Coward · · Score: 0

      I can't let you do that, Dave.

    115. Re:I miss GOTO...there I said it by shutdown+-p+now · · Score: 2

      With try-blocks in Java 7, you can have a single one:

      try (
        Foo foo = new Foo();
        Bar bar = new Bar();
      ...
      ) {
      ...
      }

    116. Re:I miss GOTO...there I said it by shutdown+-p+now · · Score: 2

      One important correction: it has nothing to do about exceptions, and everything to do about RAII. If C had scope guards, you could ditch goto for resource cleanup while still returning error codes to indicate values.

    117. Re:I miss GOTO...there I said it by shutdown+-p+now · · Score: 1

      The COMEFROM statement

      You jest, but in some way, that's what virtual method overrides actually are. ~

    118. Re:I miss GOTO...there I said it by shutdown+-p+now · · Score: 1

      It's a special form of goto, though - specifically, "goto case":

      switch (n) {
      case 1:
      case 2:
      ...
      // must have break, continue, return, throw, goto or infinite loop here:
      // no implicit fallthrough allowed
        break;
      case 3:
      case 4:
      ...
        goto case 5;
      case 5:
      ...
        goto default;
      default:
        return 123;
      }

      Anyway, I always wondered why C and C++ don't let you directly target "case" in goto like that, especially given that "case" in those languages is a true label, and can be nested within a different compound statement, not necessarily immediately under "switch".

    119. Re:I miss GOTO...there I said it by Anonymous Coward · · Score: 0

      And lastly, you often have to come up with decent names for those functions

      That shouldn't be difficult, and should also solve the other problem you mentioned (looking up what the function does). If the function does one thing and does it well (as functions should), then you give it a descriptive name that explains what that one thing is. Voila. Both problems solved.

      Of course, if you're one of those crusty old-school programmers who apparently hate typing and think that all variables should be called "q" and all functions should be called "xhr()" and return some meaningless int, then feel free to grumble something about how "self-documenting code is a myth" and go back to work.

    120. Re:I miss GOTO...there I said it by Anonymous Coward · · Score: 0

      That shouldn't be difficult, and should also solve the other problem you mentioned (looking up what the function does). If the function does one thing and does it well (as functions should), then you give it a descriptive name that explains what that one thing is. Voila. Both problems solved.

      Doesn't help when you're debugging the code (which is often the reason why you're reading that part of the code in the first place).

      If you're looking for a bug in that general area, you're going to have to look inside the function anyway even if it has a descriptive reasonable sounding name. TheDailyWTF has some examples of why you have to do that.

    121. Re:I miss GOTO...there I said it by 0ld_d0g · · Score: 1

      That code might be OK for small use cases, but it is very fragile. Depending on the language used I would consider implementing transaction semantics where the failure mode implies undoing of any transactions prior to the commit.

    122. Re:I miss GOTO...there I said it by Anonymous Coward · · Score: 0

      Java exception handling is made with try catch that are essentially renamed and somewhat managed gotos...it's all a matter of what and how

    123. Re:I miss GOTO...there I said it by Tom · · Score: 2

      Then he sat me down and walked through the code, and explained what the code was doing, and the failure modes that made it necessary to use a goto.

      Exactly. To every rule there is an exception, and if you would not ever want to use a GOTO, don't you think programming languages would have removed it by now?

      For every hallowed "law" of programming, there is always a case where it doesn't hold true. I passed my assembler 101 with a self-modifying program, even though the prof told us pretty much every other lecture that self-modifying programs are a big no-no (and yes, thus the challenge was born in my mind). Because I could explain why in this particular case for this particular purpose, the specific self-modifications I made were the best solution.

      It has its place, but it should definitely be used sparingly. Blindly saying never use a goto doesn't always give you the best solution.

      Amen

      --
      Assorted stuff I do sometimes: Lemuria.org
    124. Re:I miss GOTO...there I said it by Anonymous Coward · · Score: 1

      If you're not smart enough to handle nested control blocks, you're certainly not smart enough to use goto responsibly.

    125. Re:I miss GOTO...there I said it by snemarch · · Score: 1

      ...and what if the close/dispose method of one of those resources throws an exception?

      --
      Coffee-driven development.
    126. Re:I miss GOTO...there I said it by snemarch · · Score: 1

      From a technical standpoint though, function calls are fairly expensive so maybe you should avoid calling the function in the first place if you're going to just hit a return in it.

      Just how old are the compilers/JIT'ers you're using? :-)

      --
      Coffee-driven development.
    127. Re:I miss GOTO...there I said it by snemarch · · Score: 1

      Because it's SO much better to thrown an exception - it works super well in tight inner loops, and the logic flow is always sure to a lot easier to follow than a break or goto.

      --
      Coffee-driven development.
    128. Re:I miss GOTO...there I said it by Grishnakh · · Score: 1

      I'm not a compiler expert, but don't modern compilers eliminate functions frequently if they can be optimized out? So, for instance, if you write a function that has a bunch of helper functions that are only called from that one function, wouldn't a compiler frequently optimize those helper functions out and make them inline?

    129. Re:I miss GOTO...there I said it by snemarch · · Score: 1

      Breaking up a large and unwieldy function into calls to multiple (private-scoped) functions that are inlined is going to make the resulting binary size larger just how?

      --
      Coffee-driven development.
    130. Re:I miss GOTO...there I said it by Anonymous Coward · · Score: 0

      tmp_ctx = (ctx_type)NULL;
      do {
          tmp_ctx = talloc_new(parent_ctx).
          *allocate memory on tmp_ctx *
          do stuff or fail and break.
          *allocate more memory on tmp_ctx *
          do stuff or fail and break.
      } while (false);
      if (tmp_ctx != (ctx_type)NULL) {
          talloc_free(tmp_ctx);
      }
      return result;

    131. Re:I miss GOTO...there I said it by serviscope_minor · · Score: 1

      Goto is great when nothing else is / was available, but in any modern object oriented language,

      Break is a great way of getting out of a loop early. If you have 2D or greater data, then goto is the only way of breaking out of the double for-loop early without ssing with extraneous flags or splitting up the code into micro methods.

      Goto is one of those structures that is rare to need but exceptionally useful when you do need it. Just because it was abused badly in the 60's and 70's does not mean it can't be used effectivly in the 2010s.

      --
      SJW n. One who posts facts.
    132. Re:I miss GOTO...there I said it by Grishnakh · · Score: 3, Informative

      Nowadays, the idea of using goto as a 'jump to function end' is reasonable, and a lot less expensive than throwing an exception to do the same thing... yes, I've seen them used for that.

      It's extremely common in Linux kernel code (particularly device drivers), as it's used for error handling there, so that you can perform resource-freeing operations in reverse order very simply without a lot of indentation and braces.

      ret = do_op1();
      if (!ret)
              goto fail1;
      ret = do_op2();
      if (!ret)
              goto fail2;
      ret = do_op3();
      if (!ret)
              goto fail3;
      ret = do_op4();
      if (!ret)
              goto fail4;
      return 0;

      fail4:
      undo_op4();
      fail3:
      undo_op3();
      fail2:
      undo_op2();
      fail1:
      undo_op1();
      return -1;

      Try rewriting that in C, without goto, in an unconvoluted way. And don't exceed 3 levels of indentation, and don't create any additional functions.

    133. Re:I miss GOTO...there I said it by Grishnakh · · Score: 1

      The nice thing about C++ is that it's a superset of C, so any time you want to just go back to doing something in C style, you're free to do so, while still using classes and such. AFAICT, there's nothing keeping you from writing a C++ program and using gotos to do error handling in your class methods.

      C++ is kinda like Perl that way; it can accommodate vastly different styles. It's quite possible to write very elegant and verbose Perl code, while it's also possible to write completely obfuscated and unreadable Perl code that's 1 line long. The language doesn't force you into a particular style as strongly as some other languages (like Java) do.

    134. Re:I miss GOTO...there I said it by snemarch · · Score: 1

      An assembler assembles assembly source code.

      --
      Coffee-driven development.
    135. Re:I miss GOTO...there I said it by sjames · · Score: 1

      Personally, if I am tempted to use a goto, I consider that a potential warning. I then look again to make SURE a goto is really the best way. If so, I use it.

      Goto was considered harmful mostly because some coders would sprinkle them freely over everything without even considering that there could be a better way.

      Most of the valid use cases are where it acts as a multi-level break. It's a great way to avoid multiple copies of exit code (and the associated risk of bugs that carries).

    136. Re:I miss GOTO...there I said it by Grishnakh · · Score: 1

      Probably because they just didn't think of it at the time. It's actually a pretty good idea IMO. Why they don't add it to C++, I have no idea, but the C language hasn't really changed in a long time, unlike C++ which recently released C++0x.

    137. Re:I miss GOTO...there I said it by sjames · · Score: 1

      It's also worth noting that correctness proofs have never really worked out in the real world.

    138. Re:I miss GOTO...there I said it by Anonymous Coward · · Score: 0

      Congratulations: your code is more verbose, less readable and buggy. All because you heard someone say once that "GOTO is bad" and never bothered to actually take the time to understand the context of the statement or the arguments for and against.

      I'll let you figure out where your bug is.

    139. Re:I miss GOTO...there I said it by rastos1 · · Score: 1

      One of my profs once laughed at me when I said his code had a goto and we shouldn't do it that way (because that's what we'd been taught in class).

      There once was a master programmer who wrote unstructured programs. A novice programmer, seeking to imitate him, also began to write unstructured programs. When the novice asked the master to evaluate his progress, the master criticized him for writing unstructured programs, saying: "What is appropriate for the master is not appropriate for the novice. You must understand the Tao before transcending structure". -- Tao of programming 3.2

    140. Re:I miss GOTO...there I said it by Rogerborg · · Score: 1

      Then man up and use it. For a chap whose life seems to consist of getting FRIST POTST on every second Slashdot story, you seem unduly concerned about what people might think of you.

      --
      If you were blocking sigs, you wouldn't have to read this.
    141. Re:I miss GOTO...there I said it by Grishnakh · · Score: 1

      Wrong. In C, coding with goto can make code much more concise and easy to read, depending on exactly what you're doing (such as error handling). Better performance is just a side effect of KISS.

      This isn't to say there isn't a better way to do it, but to make a better way in C, you'd have to change the language to have some other kind of control method specifically designed for these kinds of constructs, just like they added the "switch" statement so you don't have to do:

      if (condition == test1)
              goto case1;
      else if (condition == test2)
              goto case2;
      else if (condition == test3)
              goto case3;
      else
              goto default:

      when that's really all a switch statement is doing.

      C doesn't have a better construct for error handling right now (and probably never will), so goto is the most elegant way of handling the problem.

    142. Re:I miss GOTO...there I said it by Xtifr · · Score: 2

      I agree that GOTO has its uses

      Which is why the idea of automatically marking it as bad is stupid.

      I haven't used goto in over 20 years, but, looking back, there's probably a few cases where I should have--cases where it would have made the code not only more efficient, but clearer.

      (Also, in general, I think the RAII pattern is better than try/finally in most--but not all--cases, but that also requires language support.)

    143. Re:I miss GOTO...there I said it by Vanders · · Score: 1

      You're right, you should always use descriptive function names which describe exactly what the function does.

      See, the world is always ready with a bigger idiot...

    144. Re:I miss GOTO...there I said it by Anonymous Coward · · Score: 0

      I think those little gems where random chance generates data that is offensive to humans are the best.

      My place of business uses a ticket system that can involve numbers as well as letters. One of my coworkers created a ticket, and the ID for it ended in a certain four letter word. :-D (This was also the expletive he used to describe his frustration with the issue, too.)

    145. Re:I miss GOTO...there I said it by sirlark · · Score: 1

      Performance and capacity would be another reason... I've just today had to recode a python program implementing a recursive algorithm into C. The python version ran out of stack space using actual recursion, so I tried to convert the routine to use and explicit stack. The result may have worked, but the amount of nesting and extra conditions did nothing to make it more readable. If goto had been available, it would have been perfectly clear. I recoded in C, and the routine actual uses less lines than the python version, despite some fairly funky string handling. "goto" has it's place, and not just as a second best last ditch alternative in the absence of certain structured programming syntax/idioms. Sometimes, using "goto" produces better, more legible code.

    146. Re:I miss GOTO...there I said it by oreiasecaman · · Score: 1

      'Tis what I call a good troll eh... no-one discussed TFA, and you almost started a flame war. Congratulations!

      --
      This is a UDP joke, I don't care if you get it or not...
    147. Re:I miss GOTO...there I said it by UnknownSoldier · · Score: 1

      Does Java have computed goto's ? On some platforms can provide a very nice speedup in the inner loops of interpreters such as Lua, etc.

    148. Re:I miss GOTO...there I said it by shutdown+-p+now · · Score: 1

      C has actually also just been updated to ISO C11, and includes a bunch of new (albeit relatively minor) language features such as alignof, atomic types, thread_local, Unicode (char16_t, char32_t and U"" literals) etc.

    149. Re:I miss GOTO...there I said it by Volguus+Zildrohar · · Score: 1

      Never remove a penis piercing with a blender.

      Yes, sometimes it does.

      --
      When confronted with one problem, some think "I'll use recursion". Now they are confronted with one problem.
    150. Re:I miss GOTO...there I said it by Stick32 · · Score: 1

      Well the problem is that telling a programmer, "It's ok to use GoTo judiciously," is like telling a recovering drug addict, "It's ok to take that Vicodin if the headache is really bad." You might start of using GoTo judiciously and you may never end up abusing it, but there's a good chance you'll start using it to cure even your minor headaches and pains.

    151. Re:I miss GOTO...there I said it by Xtifr · · Score: 1

      Coding with a "goto" makes code more obfuscated.

      Usually, but not always. If you have a complex maze of nested if/else clauses, with temporary state variables all over the place, sometimes--sometimes--judicious use of goto can actually simplify and clarify the code. It's not common, and it's usually the sort of thing I only notice in my own code after its already gone to production and rewriting it for clarity with a goto would be more work than its worth, but there have been a few simple examples posted in this discussion already.

    152. Re:I miss GOTO...there I said it by Twylite · · Score: 1

      This is 2012. C is still used for on-the-metal programming of pretty much any embedded micro other than the Arduino. And C doesn't have try...finally. It has nested if statements, goto, or roll-your-own-goto using switch/for/while/do (which is just a style guide compliant obfuscated form of goto).

      --
      i-name =twylite [http://public.xdi.org/=twylite], see idcommons.net
    153. Re:I miss GOTO...there I said it by Anonymous Coward · · Score: 0

      But dismissing GOTO outright just handicaps yourself in the case when it is the right choice. Not that it matters when it comes to Java but back in C land I agree with the Linux kernel guy's. http://groups.google.com/group/lucky.linux.kernel/msg/279236f3e970710b

    154. Re:I miss GOTO...there I said it by K.+S.+Kyosuke · · Score: 1

      Maybe you should try writing a serious program without nested control structures then and show us how it should be done or are you going to suggest just making endless function calls so the code is unintelligable and the cost of push and popping on the stack becomes huge?

      What is this "stack" thing and what does that have to do with the question at hand? Your job as a programmer is to write the code in as clean a fashion as possible, the compiler's job is to make the code as fast as possible. Nice, well-factored source should never be abandoned for petty reasons. You're going to cry two years later when you'll have to understand why the hell you wrothe that contorted monstrosity.

      And BTW, as far as leaving some dynamic scope is concerned, I would probably use an escape continuation.

      --
      Ezekiel 23:20
    155. Re:I miss GOTO...there I said it by systemeng · · Score: 1

      I've also seen cases where it can be very good when implementing a state machine.

    156. Re:I miss GOTO...there I said it by K.+S.+Kyosuke · · Score: 1

      Even better, if you are very self-confident: "Making love to a beautiful woman is like merging two quality code branches."

      --
      Ezekiel 23:20
    157. Re:I miss GOTO...there I said it by Rary · · Score: 1

      You're not actually arguing in favour of "goto". You're arguing in favour of structured jump constructs. In some languages, such as C, "goto" just happens to be the way that certain structured constructs are implemented. Please read my other comment in this thread. When I said that coding with a "goto" makes code more obfuscated, I was referring to unstructured jumps, which is what is actually being discussed when "goto" is being criticized.

      --

      "You cannot simultaneously prevent and prepare for war." -- Albert Einstein

    158. Re:I miss GOTO...there I said it by Grishnakh · · Score: 1

      I disagree; when "goto" is criticized, it's different depending on who's doing the criticizing. Some people specifically criticize unstructured jumps, while plenty more just say "goto is bad in all cases and should never be used".

      Personally, I haven't seen any constructs that handle error handling as well as goto; the "try-catch" thing that I saw in Java years ago was a PITA and ugly, and didn't allow you to call resource-freeing functions in reverse order in a simple, concise way.

    159. Re:I miss GOTO...there I said it by Twylite · · Score: 1

      It is sometimes possible to use that style, but generally you will need nesting if you want to handle errors. I can't think of a decent embedded example that doesn't require reams of context, but here's an illustration using shared memory under Windows. Try to translate the following code snippet to the style you suggest:

      errno_t get_shared_status( LPCTSTR fileName ) {
      errno_t result = E_UNKNOWN;
      HANDLE f = INVALID_HANDLE_VALUE;
      HANDLE fMap = NULL;
      LPVOID shm = NULL;
      MEMORY_BASIC_INFORMATION meminfo;
      SIZE_T shmLen = 0;

      f = CreateFile( fileName, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING,
      FILE_ATTRIBUTE_NORMAL, NULL );
      if ( f == INVALID_HANDLE_VALUE ) {
      result = E_SHM_ACCESS;
      log( "get_shared_status: CreateFile() failed with error %08x", GetLastError() );
      goto cleanupNone;
      }

      fMap = CreateFileMapping( f, NULL, PAGE_READONLY, 0, 0, NULL );
      if ( fMap == NULL ) {
      result = E_SHM_ACCESS;
      log( "get_shared_status: CreateFileMapping() failed with error %08x", GetLastError() );
      goto cleanupCreateFile;
      }

      shm = MapViewOfFile( fMap, FILE_MAP_READ, 0, 0, 0 );
      if ( shm == NULL ) {
      result = E_SHM_ACCESS;
      log( "get_shared_status: MapViewOfFile() failed with error %08x", GetLastError() );
      goto cleanupCreateFmap;
      }

      shmLen = VirtualQuery( shm, &meminfo, sizeof(meminfo) );
      if ( shmLen == 0 ) {
      result = E_SHM_ACCESS;
      log( "get_shared_status: VirtualQuery() failed with error %08x", GetLastError() );
      goto cleanupMapView;
      }
      if ( shmLen sizeof(meminfo) ) {
      result = E_SHM_ACCESS;
      log( "get_shared_status: VirtualQuery() returned too few bytes" );
      goto cleanupMapView;
      }

      if ( meminfo.RegionSize SHM_V1_SIZE ) {
      result = E_SHM_ACCESS;
      log( "get_shared_status: Shared memory file too small to interpret" );
      goto cleanupMapView;
      } //FIXME do stuff

      cleanupMapView:
      if ( 0 == UnmapViewOfFile( shm ) ) {
      log( "get_shared_status: UnmapViewOfFile() failed with error %08x", GetLastError() );
      }
      shm = NULL;

      cleanupFmap:
      if ( 0 == CloseHandle( fMap ) ) {
      log( "get_shared_status: CloseHandle(fMap) failed with error %08x", GetLastError() );
      }
      fMap = NULL;

      cleanupCreateFile
      if ( 0 == CloseHandle( f ) ) {
      log( "get_shared_status: CloseHandle(f) failed with error %08x", GetLastError() );
      }
      f = INVALID_HANDLE_VALUE;

      cleanupNone:
      return result;
      }

      Here's the start:

      f = CreateFile( fileName, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING,
      FILE_ATTRIBUTE_NORMAL, NULL );
      if ( f != INVALID_HANDLE_VALUE ) {
      fMap = CreateFileMapping( f, NULL, PAGE_READONLY, 0, 0, NULL );
      } else {
      result = E_SHM_ACCESS;
      log( "get_shared_status: CreateFile() failed with

      --
      i-name =twylite [http://public.xdi.org/=twylite], see idcommons.net
    160. Re:I miss GOTO...there I said it by Anonymous Coward · · Score: 0

      while plenty more just say "goto is bad in all cases and should never be used"

      There will always be people who were told by someone else "always do this" or "never do that" and they don't actually understand the reasoning, and they'll cling mindlessly to what they were taught. But the general notion of "goto" being "bad" originates with Dijkstra's essay on the subject, and is based on the concepts of structured programming. When people defend "goto" by demonstrating its practical use in a structured way, they're only defending against the people who don't even know why they're supposed to avoid "goto" in the first place, and not addressing the actual point.

    161. Re:I miss GOTO...there I said it by DrXym · · Score: 2

      You have to try / catch in your finally block. It's very clumsy really but that's how to do it pre-Java 7. C# has a more elegant solution with its using keyword where disposable stuff automatically gets closed when it leaves the using block. Java 7 sort of has something analogous now by allowing a try with resources construct.

    162. Re:I miss GOTO...there I said it by Anonymous Coward · · Score: 0

      Phui.

      As far as I am concerned, DIJKSTRA is "cognitively limited".

      It is not the use of $STATEMENT that makes good / bad code, it is the PROGRAMMER. I have seen code written in so-called "structured code" which was a total mess.... and others, using GOTO, very elegant.

      For what it's worth, we had an unwritten rule: "GOTO only downwards". Seemed to work, most of the times, and created fairly neat code.

      Dijkstra is a plonker.

    163. Re:I miss GOTO...there I said it by notknown86 · · Score: 1

      Guess what I do when they fail at the very task they themselves so derogatorily suggested?

      Act like a condescending jerk?

      Granted, all I have is a snippet as the basis for that guess...

    164. Re:I miss GOTO...there I said it by tftp · · Score: 1

      Your job as a programmer is to write the code in as clean a fashion as possible, the compiler's job is to make the code as fast as possible.

      Unfortunately that's not how it works in real life. A programmer needs to help the compiler help the programmer.

      Besides, stack is a precious, limited, shared resource on embedded systems. Running out of stack is an instant crash. I use gotos in embedded code when practical - they translate into a single machine command; can't beat that.

    165. Re:I miss GOTO...there I said it by flibbajobber · · Score: 1

      so some number of operations need to be done in order, and if any of them fail then they need to be undone in reverse order... if you don't consider the comma operator to be unconvoluted (it's a bit obscure, I'll give you that) - and know how the && operator "aborts" when an operand is found to be false (*everyone* should know this) then:

      int level = 0;

      if ((++level, do_op1()) &&
          (++level, do_op2()) &&
          (++level, do_op3()) &&
          (++level, do_op4()))  // value of "level" will be equal to the number of the operation currently being attempted
      {
        return 0;
      }

      // at this point, value of "level" will be equal to the number of the operation that failed

      switch (level) // note the lack of "break"
      {
        case 4:
          undo_op4();
        case 3:
          undo_op3();
        case 2:
          undo_op2();
        case 1:
          undo_op1();
      }
      return -1;

    166. Re:I miss GOTO...there I said it by Grishnakh · · Score: 1

      The only problems here are that 1) now you have an extra variable to increment and keep track of, instead of just the PC (program counter), though this probably isn't a big deal these days; it'd most likely be done in a register anyway, and 2) this works fine if you're only calling functions, as I did in my example for simplicity and readability. In most real code I see, it's not just simple "do_op1()" functions called, it's a lot of different inline code, maybe some functions, maybe not. You could move all this out into helper functions, but now you've introduced scoping problems; what if you're just setting some variables in some of those do_op() functions? With gotos, those variables will be within the scope of your overall function here, but if you move them into a helper function, you've lost that and now you have to mess with arguments (probably with pointers), which can get complex very quickly and make your code not-so-readable.

      For my specific example, however, I'll hand it to you; yours is a very clever solution. I've never seen commas used in an if statement that way to be honest, though I have seen and used them in for statements that way.

    167. Re:I miss GOTO...there I said it by Hognoxious · · Score: 1

      Goto makes perfect sense when you're doing lots of checking and validation where there's some code specific to each possible error (logging or putting an error message) and some other code (cleanup,freeing resources) that's common to all cases.

      Putting it in a function sounds like a good idea, but depending on the language's scoping rules you might have to pass tons of local (from the POV of the main validation function) variables into it. Messy.

      The other option is to set flags every time somethings detected and have all further processing dependent on those flags. Trouble is you end up with so many if statements the code is three times as long. Messy again.

      I'd say goto isn't the best way, but there are cases where it's the least bad way.

      --
      Confucius say, "Find worm in apple - bad. Find half a worm - worse."
    168. Re:I miss GOTO...there I said it by Anonymous Coward · · Score: 0

      Well yes, that is a kind of use, that makes it easier with goto, although It is possible without it. I'll just point out first, that I am not a fanatic opponent of goto, I don't remember to ever need it, but I wouldn't hesitate if it was really the best option I could find after a long thinking ;)

      Here's how it goes: /* lets suppose that SUCCESS evaluates to true, all error statuses to false */
      result = SUCCESS;
      f = CreateFile( fileName, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING,
                                    FILE_ATTRIBUTE_NORMAL, NULL );
      if ( f == INVALID_HANDLE_VALUE ) {
              result = E_SHM_ACCESS;
              log( "get_shared_status: CreateFile() failed with error %08x", GetLastError() );
      } else {
              fMap = CreateFileMapping( f, NULL, PAGE_READONLY, 0, 0, NULL );
      }
      if ( fMap == NULL && result) {
              result = E_SHM_ACCESS;
              log( "get_shared_status: CreateFileMapping() failed with error %08x", GetLastError() );
      } else if (result) {
              shm = MapViewOfFile( fMap, FILE_MAP_READ, 0, 0, 0 );
      }
      if ( shm == NULL && result) {
              result = E_SHM_ACCESS;
              log( "get_shared_status: MapViewOfFile() failed with error %08x", GetLastError() );
      } else if (result) {
              shmLen = VirtualQuery( shm, &meminfo, sizeof(meminfo) );
      }
      if ( shmLen == 0 && result) {
              result = E_SHM_ACCESS;
              log( "get_shared_status: VirtualQuery() failed with error %08x", GetLastError() );
      } else if ( shmLen sizeof(meminfo) && result) { // not quite sure what your 'if' meant here..
              result = E_SHM_ACCESS;
              log( "get_shared_status: VirtualQuery() returned too few bytes" );
      } else if ( meminfo.RegionSize SHM_V1_SIZE && result ) {
              result = E_SHM_ACCESS;
              log( "get_shared_status: Shared memory file too small to interpret" );
      } //FIXME do stuff

      if (( shmLen == 0 ) || ( shmLen sizeof(meminfo) ) || ( meminfo.RegionSize SHM_V1_SIZE )) {
              if ( 0 == UnmapViewOfFile( shm ) ) {
                      log( "get_shared_status: UnmapViewOfFile() failed with error %08x", GetLastError() );
              }
              shm = NULL;
      }

      if (shm == NULL){
              if ( 0 == CloseHandle( fMap ) ) {
                      log( "get_shared_status: CloseHandle(fMap) failed with error %08x", GetLastError() );
              }
              fMap = NULL;
      }

      if ( fMap == NULL ){
              if ( 0 == CloseHandle( f ) ) {
                      log( "get_shared_status: CloseHandle(f) failed with error %08x", GetLastError() );
              }
              f = INVALID_HANDLE_VALUE;
      }

      return result;

    169. Re:I miss GOTO...there I said it by Anonymous Coward · · Score: 0

      Your arbitrary stipulation about the indentation makes this less clear in my opinion, but here you go.

      if (do_op1()) {
      if (do_op2()) {
      if (do_op3()) {
      if (do_op4()) {
          return 0;
      }
      undo_op4(); }
      undo_op3(); }
      undo_op2(); }
      undo_op1();
      return -1;

    170. Re:I miss GOTO...there I said it by Anonymous Coward · · Score: 0

      How about a labelled break statement to break out of a specific number of loops?

    171. Re:I miss GOTO...there I said it by Skal+Tura · · Score: 1

      wow! Never heard of for loops?

    172. Re:I miss GOTO...there I said it by Skal+Tura · · Score: 1

      How about simply trying to design your code sensibly?

      (tho, java to begin with is crap)

    173. Re:I miss GOTO...there I said it by mhelander · · Score: 1

      But that implies that the arraysearch function would also contain the code to run when a match is found in the array, which breaks the rule of least surprise.

      Perhaps simply:

      if(arraysearch(array, value)){
      //code to execute when item is found.
      } else {
      //code to execute when item is not found.
      }

    174. Re:I miss GOTO...there I said it by Anonymous Coward · · Score: 0

      Yes. We used to do that in some of our source code bases. I always like how "important programmers" at "big companies" think 'goto' is verboten, but don't notice switch statements with fall-through cases. Because they're sooo much safer ;)

      A switch with a fall-through is safer than gotos, because the jump is always forward in the code, and never moves control into a different scope.

    175. Re:I miss GOTO...there I said it by AaronLS · · Score: 1

      If I read someone's code and they threw an exception, I'd be trying to figure out what the error/exception condition was they had detected. Abusing exception handling just to break out of a loop, will lead to some very misleading code. At least with a loop label or goto, it is clear what your goal is.

      Not to mention the fact that if you are using any kind of framework that automatically performs certain tasks like logging or notification on error, then you are going to get unintended side effects by throwing an exception when there isn't really an exception.

    176. Re:I miss GOTO...there I said it by Anonymous Coward · · Score: 0

      From one dinosaur to another, "I AGREE!!!"

    177. Re:I miss GOTO...there I said it by blueg3 · · Score: 1

      No problem. Incidentally, most compilers these days treat a lot of the C and C++ keywords as either hints or things to ignore. For example, "inline" and "register". In general, the optimizing compiler is smarter than the programmer about when it's efficient to inline. (Some compilers do treat "static inline" as a hint that, if all instances of the function are inlined, it should not bother emitting a non-inlined copy of the function. You can also get this effect with "static" and the appropriate compiler flag. This makes "static" a very important keyword to put on your functions.)

    178. Re:I miss GOTO...there I said it by Ramin_HAL9001 · · Score: 1

      Try rewriting that in C, without goto, in an unconvoluted way. And don't exceed 3 levels of indentation, and don't create any additional functions.

      /* Fewer lines of code, more readable.
      * Local variables should be contained in a structure that can be passed by pointer.
      * Most compilers will optimize this code to look exactly the your code above with GOTO's.
      */
      struct local_variables { ... };
      typedef int (*local_var_update)(struct local_variables *);
      void func() {

      • local_var_update do_op[4] = { do_op1, do_op2, do_op3, do_op4 };
        local_var_update undo_op[4] = { undo_op1, undo_op2, undo_op3, undo_op4 };
        struct local_variables vars = { ... };
        int i = 0, ret = 0;
        while(i < 4) { if(! do_op[i](& vars)) { ret = -1; break; } i++; }
        if(ret == 0) { return ret; }
        while(i > 0) { undo_op[i](& vars); i--; }
        return ret;

      }

  2. This just confirms it by hedwards · · Score: 1, Funny

    MS wants code for Windows to be as inept and inefficient as possible. I never thought they would get to the point where they weren't just tolerating poor practices, but encouraging them as well.

    1. Re:This just confirms it by Anonymous Coward · · Score: 1

      The opposite could be the case, someone might be using goto not knowing it's considered bad and learn that it is from this achievement.

    2. Re:This just confirms it by CadentOrange · · Score: 2

      The opposite could be the case, someone might be using goto not knowing it's considered bad and learn that it is from this achievement.

      You'd have to be living under a rock to *not* know that GOTOs are considered bad.

    3. Re:This just confirms it by elsurexiste · · Score: 3, Funny

      The achievement for using goto is "Go To Hell". How is that encouraging, I have no idea :) . In fact, most of those achievements are just a funny take on amateur programmers. Just take a look at the list:

      • Interrupting Cow (Have 10 breakpoints in a file.Where's that bug? Could here, could be there, could be anywhere! - 5 points)
      • Stubby (Generate method stubs 9 times. You're a TDD bad ass! - 5 points)
      • Save A Tree (Print source code. My boss told me to. I swear! - 5 points)
      --
      I rarely respond to comments. Also, don't ask for clarifications: a brain and Google are faster, believe me!
    4. Re:This just confirms it by Anonymous Coward · · Score: 0

      Except Stubby is more likely to be gotten by competent programmers than amateurs...

    5. Re:This just confirms it by hedwards · · Score: 1

      Not just that, I don't recall GOTOs even being talked about in any of the intro classes I took. It could just be the classes I took, but if they aren't covering it, you're probably not going to even know about it unless you're either familiar with BASIC or your looking for new things to try. In neither case would ignorance be a legitimate defense.

    6. Re:This just confirms it by ByOhTek · · Score: 1

      Saying that they want inept code is idiotic, that wouldn't make business sense.

      This is probably from the lobotomized-and-still-able-to-talk squad, i.e. their marketing department thinking "Hey, how can we make this more fun and exciting." And, as with most of their marking, it just comes out retarded.

      Seriously, achievements were OK on MMOs, annoying on single player games, stupid on Slashdot... and RETARDED in an IDE. I hope this doesn't become a built-in component (or if it does, can be easily hidden). What a waste of time and insult to the devs.

      --
      Self proclaimed typo king, and inventor of the bear destroying coffee table (patent not pending).
    7. Re:This just confirms it by NewWorldDan · · Score: 1

      Actually, I wasn't even aware (until today) that C# had a goto statement. And I've also found a legitimate use for it as well: In a switch statement, control can not implicitly fall through from one case to the following case. Adding a goto statement deals with that problem. This can fix some awkward code I've written recently (using a lot of if statements).

    8. Re:This just confirms it by Eirenarch · · Score: 1

      Truth is it is kind of unofficial. The guys that release this do work for MS but they work on a blog called "Coding for Fun" and do other things in MS. I would hardly consider this official MS policy.

    9. Re:This just confirms it by Anonymous Coward · · Score: 0

      Wooosh.

    10. Re:This just confirms it by Algae_94 · · Score: 1

      Why not just use a break statement to get out of the switch block instead of a goto?

    11. Re:This just confirms it by NewWorldDan · · Score: 1

      I don't want to get out of the switch block. I want to continue to the following case. See the snippet below. I run into this type of situation a lot, only instead of 3 scenarios, I might be working with 20 and the alternative is a bunch of very awkward if statements. It's kind of sad that I've been working in C# for a decade and am just learning this, but you get so used to being told "don't use goto" and doing things a certain way that you overlook an option that is a bettery way of doing things.

      switch (x)
      {
          case 1: // do something then do case 2
              goto case 2;
          case 2: // do something different
            break;
          case 3: // do case 3...
              break;
      }

    12. Re:This just confirms it by Algae_94 · · Score: 1

      That makes sense now that I see a code example. Seems like a reasonable use of goto. Someone that is just dead set against using goto might chime in with other ways for you to accomplish this, but why rewrite the code if it works properly. This isn't convoluted and hard to follow, which seems to be the common complaint against goto.

  3. "Gamification" doesn't make dull things a game... by Anonymous Coward · · Score: 2, Interesting

    It just makes them dull things with out of place social media gimmicks.

    As a gamer, I am not pleased with this trend.

  4. seriously — they're totally missing the poin by mattdm · · Score: 4, Insightful

    The idea of gamification is to give little awards for postitive behavior — or at least active engagement with the site/product/tool/whatever. A few of these fit that (the badge for working on a Saturday or Friday night), but most of them are labels of shame for doing things like writing a single line of code that is several screens too wide.

  5. Re:"Gamification" doesn't make dull things a game. by Anonymous Coward · · Score: 2, Funny

    I know right? It is poor to think that only 5 'curse' words per file gets you Potty Mouth status. They obviously think that is a challenge.

  6. What Are We Shooting At? by Anonymous Coward · · Score: 1

    If this new Visual Studio is a game, then what are we shooting at? Aliens? Monsters? Zombies?

    Or is it a racing game? I hate racing games.

  7. Re:"Gamification" doesn't make dull things a game. by Anonymous Coward · · Score: 0, Insightful

    As a gamer, I am not pleased with this trend.

    As a gamer, you were never going to be affected by this were you?

  8. Re:seriously — they're totally missing the p by hedwards · · Score: 1

    Things like that are punished by having to deal with them later, and if you're not having to deal with them later then nothing is likely to get you to do it right.

    Ultimately, these things are much better enforced in person. Yes, if you're a team of one that's not going to happen, but then again if you're a team of one, you had better know what you're doing and do it right without having people mocking you for poor style.

  9. Actually... by Deus.1.01 · · Score: 1

    If it can teach me to use a debugger to its full purpose and gladly want a scout badge for it.

    (yes im horrible at everything i do!)

    --
    My -1 Troll is actually a +1 funny. And my -1 flame is actually a +1 insightfull.
    1. Re:Actually... by Deus.1.01 · · Score: 5, Funny

      *even grammar*

      --
      My -1 Troll is actually a +1 funny. And my -1 flame is actually a +1 insightfull.
  10. Just wait for the map packs! by Anonymous Coward · · Score: 0

    (Achievement Unlocked - Flying Spaghetti Code (50G) )

  11. Good idea by XrayJunkie · · Score: 3, Interesting

    I find this idea quite nice. Encourage people to have some fun while programming (boring stuff). This wont result in bad code. The gain for MS: create an account to store and publish your achievements.

    1. Re:Good idea by Speare · · Score: 2

      I find this idea quite nice. Encourage people to have some fun while programming (boring stuff).

      If writing code is the boring part of your career, why did you train yourself and get into that line of work? Most people I know who write code, because they want to write code, they feel best when given the opportunity between meetings to write code. The best developers I know tend to go home after their job, and sit down to their hobby projects where they... write code.

      --
      [ .sig file not found ]
    2. Re:Good idea by HaZardman27 · · Score: 1

      This wont result in bad code.

      I'm guessing you didn't look at the list of achievements, particularly the "Don't Try This at Home" section. It has achievements for writing a 300 character-long line of code, or for having a method with 10 overloads.

      --
      Apparently wizard is not a legitimate career path, so I chose programmer instead.
    3. Re:Good idea by Chris+Mattern · · Score: 1

      This wont result in bad code.

      Yes, it will. Many of the achievements are for using horrid code practices, and there WILL be people who just have to get them.

    4. Re:Good idea by Anonymous Coward · · Score: 0

      Depends on how it's used. If people aim to get the badges for writing terrible code (eg. 300 character line) then it will result in bad code. If they take that badge as a wake-up call, it could be a good thing.

      I'd like to use the feature on a new codebase I've inherited: let me see very quickly what programming practices have been used.

    5. Re:Good idea by Anonymous Coward · · Score: 0

      > writing a 300 character-long line of code

      I use 200 columns as soft limit and 220 as hard limit. I'm gonna need a bigger display for this one.

      > having a method with 10 overloads.

      Easy, write an embedded interpreter and you'll probably have something like "class Function { public Value call(Value x); public Value call(Value x1, Value x2); public Value call(Value x1, Value x2, Value x3) ... };"

      Woohoo, I can get'em all!

    6. Re:Good idea by RightSaidFred99 · · Score: 1

      No they aren't. Microsoft has some of the best programmers in the world. There are very few "horrid code practices" that don't fit in some situations. I think the problem is, for example, that early programming courses drilled "don't use goto" into people's heads because it's a good shorthand rule and easier to explain than the real cases where goto might be used. Now everybody has this idea that goto should never be used, which is nonsense. It's in the language for a reason.

      It's kind of like food. People rant about happy meals, or Paula Dean advocating fatty foods. Happy meals aren't unhealthy and neither are bacon-butter brownies. They are unhealthy when eaten too often. Eating a happy meal once a month isn't bad for you.

    7. Re:Good idea by Anonymous Coward · · Score: 0

      You described me exactly. I prefer to code at home, I code at work but they usually slap a bunch of bureaucracy in front of it to the point that I'm not satisfied when I go home. You see for me, I'm fulfilling a craving by coding. When they have me really busy at work, I tend to avoid coding at home because I'm "content". Most of the time it's feast and famine so I constantly go home to code.

      People around me have said I'm one of the best coders they know. Posting AC for obvious reasons, mostly because I'm not trying to toot my own horn but rather agree with you that the best coders do in fact code at home too.

  12. Do While by QBasicer · · Score: 3, Funny

    It better have one for do-whiles, I always feel like I've made a great accomplishment when I use one. It makes a day a little less sucky.

    --
    x86, oh yes, I'm pro.
    1. Re:Do While by networkBoy · · Score: 2

      That's funny. The codebase I inherited is *full* of do{}while(0); with a bunch of breaks inside of the do to jump out at any point something goes haywire. Come work for my team, your day will never suck (at least my that metric).
      -nB

      --
      whois gawk date unzip strip find touch finger mount join nice man top fsck grep eject more yes exit umount sleep dump
    2. Re:Do While by Anonymous Coward · · Score: 0

      Might I suggest walking? ... Seriously?

      That's worse than a goto.

    3. Re:Do While by alexo · · Score: 1

      The only legitimate place I encountered for a do{}while(0) is inside a #define macro.
      Using it to simulate a goto is convoluted as the problem can be better handled by putting the code into a function/method or by just using goto.

    4. Re:Do While by networkBoy · · Score: 2

      To be fair, the code is reliable, stable, and the Do{}while(0);'s are not so long as to be trouble tracing. This is all C code, not C++, and has to be cross compatible with embedded firmware, Windows, and Linux. Also, since that's close to the largest sin in the codebase, I'll not be leaving anytime soon.

      the general layout is of the general style:

      enum tonsOfStatusCodes{PASS=0,FAIL,CUSTOM,foo, bar,baz};
      tonsOfStatusCodes status = FAIL;
      do{
      status=customMalloc(ptr);
      if(status){break;}
      status=populateData(ptr);
      if(status){break;}
      status=transmogrifyData(ptr); ...
      }while(0);

      so at the end of this you either passed everything or you know where you borked.
      Are there better ways? yes.
      Does this work in a very compatible way? yes.
      Is it broken? no.
      Shall I then fix it? no.

      Every time I see an ask /. about "I hate my job" or "My job is asking foo of me but my job is bar", I count my lucky stars that my job is sane, well defined, challenging, and the worst of it is a couple (hundred) thousand lines of code that contain some dailywtf worthy examples.
      -nB

      --
      whois gawk date unzip strip find touch finger mount join nice man top fsck grep eject more yes exit umount sleep dump
    5. Re:Do While by alexo · · Score: 1

      Is it robust? no.

      This "idiom" becomes brittle once you introduce a loop into the delimited code (for example, an iterative numerical analysis method). Consider:

      do {
          status = customMalloc(ptr);
          if (status) break;
          status = populateData(ptr);
          if (status) break;
          for (int i = 0; i < NUM_ITERATIONS; ++i) {
              status = iterateOnData(ptr);
              if (status) break; /* Oops, need another check after the loop */
          }
          if (status) break; /* Good thing I remembered this */
          status = finalizeData(ptr);
      } while (0);

      Or even worse, the whole code block gets surrounded by a loop...

      You are better off calling a spade a spade and using a plain goto:

      status = customMalloc(ptr);
      if (status) goto Finish;
      status = populateData(ptr);
      if (status) goto Finish;
      for (int i = 0; i < NUM_ITERATIONS; ++i) {
          status = iterateOnData(ptr);
          if (status) goto Finish; /* Hey, it works! */
      }
      status = finalizeData(ptr);

      Finish:
      /* Continue here */

      However, a better approach would be to use a helper function:

      static inline tonsOfStatusCodes helper() {
          tonsOfStatusCodes status = customMalloc(ptr);
          if (status) return status;
          status = populateData(ptr);
          if (status) return status;
          for (int i = 0; i < NUM_ITERATIONS; ++i) {
              status = iterateOnData(ptr);
              if (status) return status; /* Hey, it works! */
          }
          status = finalizeData(ptr);
          return status;
      }

      If you disagree, I'd like to hear your reasoning about
      1) why, in your opinion, is the do{}while(0) construct better than a goto, and
      2) why, in your opinion, is the do{}while(0) construct better than a helper function.

      PS, I was not the one suggesting you leave.
      Cleaning up the code, on the other hand, can have merit.

    6. Re:Do While by networkBoy · · Score: 1

      I know you were not the one to suggest I leave, just decided to ball both responses together.

      I don't actually disagree, it's just that since this is an inherited codebase and the dev team we have in place now is relatively junior, I would rather not futz with the existing code. We avoid introducing any more code like this, but the legacy stuff is still there.

      In the case of point 1 I agree with the provision that I can ram a style guide down people's throat to limit how they do this. I am concerned that once you allow goto's into the code they will find each other and multiply, resulting in summing cithulu or the flying spaghetti monster. Humans beeing what they are, if they think a goto makes it easier to code up, they will, without a thought for maintainability in the future. As it sits now, there are three gotos in the code, all documented, all reviewed. Easy to find when you search for goto. If we use them more openly then it will be harder to find potentially bad uses. I think that is my biggest argument in favor of do while 0.

      In the case of point 2, I'm not sure if we could make that portable enough to fit on the embedded firmware. The host OS application is the bulk of the code, but the smaller portion that exists on the embedded device (and also exists on the host) is severely memory constrained.

      My current job is almost entirely code cleanup, I'm focusing on logic errors and compatibility issues, rather than style issues, largely because the former two impact functionality. If I can clean up style while I'm at it, I do.
      -nB

      --
      whois gawk date unzip strip find touch finger mount join nice man top fsck grep eject more yes exit umount sleep dump
    7. Re:Do While by Anonymous Coward · · Score: 0

      enum tonsOfStatusCodes{PASS=0,FAIL,CUSTOM,foo, bar,baz};
      tonsOfStatusCodes status = FAIL;
      do{
      status=customMalloc(ptr);
      if(status){break;}
      status=populateData(ptr);
      if(status){break;}
      status=transmogrifyData(ptr); ...
      }while(0);

      I've seen code like that before, it's classic "goto is evil but I need something that works exactly like goto". Instead of architecting it so the goto structure is unnecessary, they just wrapped the whole thing in a pointless loop and did a s/goto/break/. It's still goto, just without the gotos.

      ---
      The correct way to eliminate the "goto cleanup on error" structure from C code is:
      enum tonsOfStatusCodes{PASS=0,FAIL,CUSTOM,foo, bar,baz};
      tonsOfStatusCodes status = PASS;
      status=customMalloc(ptr);
      if(!status){status=populateData(ptr);}
      if(!status){status=transmogrifyData(ptr);}
      if(!status){ ... }
      /* cleanup here */

      Of course, you don't need to do this either (this is really only for the anal retentive), "goto cleanup" is fine (it's like throwing an exception, the label is the catch block); just don't start throwing the things around for any other purpose ("goto exit_2_or_more_nested_loops" is also an okay use for goto).

  13. Resume builder? by ashmon · · Score: 5, Funny

    So, is this going to be a good thing to put on your resume?

    * Stay focused and attentive to work.
    * Hard worker
    * Level 32 Visual Studio Achievements
    * Stays on task

    Uhhhh...

    1. Re:Resume builder? by DigiShaman · · Score: 1

      Toilet cleaning duty: Achievement UNLOCKED!

      Never thought I'd hear of a day when cleaning shit off porcelain will bring a smile to someone's face.

      --
      Life is not for the lazy.
    2. Re:Resume builder? by Anonymous Coward · · Score: 0

      I actually like seeing that stuff on the resume. It saves me a lot of time as I don't even waste a phone screen on the candidate.

    3. Re:Resume builder? by geekoid · · Score: 1

      I could look at all your achievements and talked to you why you used certain things, or didn't use certain aspects of the development environment.

      "How come you have never done a block copy?" Or "How come you have never used these types of sorts?"

      --
      The Kruger Dunning explains most post on /. http://en.wikipedia.org/wiki/Dunning%E2%80%93Kruger_effect
    4. Re:Resume builder? by Anonymous Coward · · Score: 0

      The Real WTF is when HR idiots will start to EXPECT good scores from these 'games', and it will all become a mandatory suckage when jobseeking.

  14. Obvious isn't it? by Viol8 · · Score: 5, Funny

    Huge hideous bugs!

    1. Re:Obvious isn't it? by Anonymous Coward · · Score: 0

      So it's an Earth Defence Force game?

  15. Possible badges for good code by tucuxi · · Score: 4, Interesting

    I for one would find these badges nice:

    • compiled without warnings (cumulative for "N times in a row")
    • doxygen-compliant comment coverage (percentage-wise cumulative)
    • safe programming practices (always compares constant == lvalue, initializes all values, ...)

    On the other hand, IDEs like Netbeans and Eclipse are getting better and better at nagging users about such issues (and auto-generating code to fix many of them). Do we really need the badges?

    1. Re:Possible badges for good code by greg1104 · · Score: 3, Funny

      Do we really need the badges?

      We don't need no stinkin' badges!. Or badgers.

    2. Re:Possible badges for good code by andawyr · · Score: 1

      I've always had issues with comparisons that follow the 'constant == lvalue' format. For whatever reason, it always takes me longer to grok what the comparison means. When I use 'lvalue == constant', it makes much more sense. At least to me.

      I'm not sure why you say this has anything to do with 'safety' - can you elaborate? I'm curious.

      I will say that I've noticed this coding construct more in code written by developers from Asia and India. Something in the curriculum, perhaps? In my formal education I never saw the 'constant == lvalue' construct, and I went to University in N.A.

    3. Re:Possible badges for good code by anonymov · · Score: 3, Interesting

      if(x = 1) // Valid in many languages and most probably not what you want. Compile warning in some compilers
      if(1 = x) // Doesn't compile

    4. Re:Possible badges for good code by Anonymous Coward · · Score: 0

      We could use a couple more puppies. The last batch didn't fare so well during the flight lesson.

    5. Re:Possible badges for good code by Anonymous Coward · · Score: 0

      Doesn't compile, but also is hard to read (unless you're Yoda).

      There's absolutely no reason not to use (x == 1). Just turn on the damn warnings and let the compiler complain if you mess up and put an '='.

    6. Re:Possible badges for good code by anonymov · · Score: 1

      Nah, personally,Yoda-style comparisons for pussies are I think.

      Though it's at least reasonable code style requirement for when you work in team (unlike "only one return point" or "no do{}while() loops")

    7. Re:Possible badges for good code by flynt · · Score: 1

      UHF! Only saw it once, probably 15-20 years ago, and still remember that line...

  16. War Games: "The only way to win...." by tverbeek · · Score: 1

    This makes me so very glad I didn't go into this field for a profession.

    --
    http://alternatives.rzero.com/
    1. Re:War Games: "The only way to win...." by geekoid · · Score: 2

      Achiements will be in every job in a decade.

      --
      The Kruger Dunning explains most post on /. http://en.wikipedia.org/wiki/Dunning%E2%80%93Kruger_effect
  17. I wonder if I can get an achievement by Hentes · · Score: 1

    for writing my first 1000 lines of code!

    1. Re:I wonder if I can get an achievement by Anonymous Coward · · Score: 0

      You do, if it is one file with only one main method, no indentation, no comments, no empty lines.

  18. FUN! With programming and Achievements!?!? by Etrahkad · · Score: 3, Interesting

    WTF is my first reaction. Second reaction is that that would have been awesome to work on the team that built that in because it shows that they have a bit more freedom with what goes in a program like Visual Studio. This sounds like a progressive step forward in the engineering team @ Microsoft. I can't give them kudos for this _exact_ application of listening to programmers but the idea that people are allowing for ownership and creativity is gratifying to see in a development firm. Its something different than the boring troll of debugging the application, fixing build errors, and building more.

    1. Re:FUN! With programming and Achievements!?!? by Anonymous Coward · · Score: 0

      If they listened to programmers, they would have had those devs fixing their pathetic C++11 support.

    2. Re:FUN! With programming and Achievements!?!? by phantomfive · · Score: 1

      Second reaction is that that would have been awesome to work on the team that built that in because it shows that they have a bit more freedom with what goes in a program like Visual Studio.

      They were doing this instead of getting intellisense working for C++ CLR. It's great that they have freedom, but could they at least fix the things they've broken in the latest release before playing around?

      --
      "First they came for the slanderers and i said nothing."
    3. Re:FUN! With programming and Achievements!?!? by TheLink · · Score: 1

      If they're listening to programmers they should give better error messages than "Object reference not set to an instance of an object", at least when stuff is compiled in DEBUG mode.

      Many other languages at least tell you the names of at least one offending item in a similar situation, and maybe even what was being attempted (assignation, comparison, concatenation, etc).

      --
    4. Re:FUN! With programming and Achievements!?!? by shutdown+-p+now · · Score: 1

      They were doing this instead of getting intellisense working for C++ CLR.

      Intellisense for C++/CLI is already done - you can see it for yourself in VS11 Developer Preview.

    5. Re:FUN! With programming and Achievements!?!? by Megane · · Score: 1

      If they listened to programmers, they would have C99 support.

      --
      #naabhaprzrag, #sverubfr-000, #agi-fcbafberq, negvpyr[pynff*=' negvpyr-ary-'] { qvfcynl: abar !vzcbegnag; }
    6. Re:FUN! With programming and Achievements!?!? by phantomfive · · Score: 1

      Oh good, I'm glad you told me that. Hmmmm, now I don't hate Microsoft as much; I'm not sure this is healthy.

      --
      "First they came for the slanderers and i said nothing."
  19. Gotta get 'em all by Lunaritian · · Score: 4, Insightful

    There are many players who simply have to collect every single achievement. Considering what these achievements are like (use 20 single-letter variables, write a 300-character line etc.) I hope their behavior won't carry over to programming...

    1. Re:Gotta get 'em all by Anonymous Coward · · Score: 0

      Winner of Potty Mouth goes to the author of this class.

    2. Re:Gotta get 'em all by networkBoy · · Score: 1

      meh,
      I'd make a file named achievements.h and .c, then dump all the stuff in there. Link it in once to make all the badges come up, then #IFDEF it out.
      -nB

      --
      whois gawk date unzip strip find touch finger mount join nice man top fsck grep eject more yes exit umount sleep dump
  20. Good achievements? by Anonymous Coward · · Score: 0

    Any achievements for "good" behavior? Even then, I see this encouraging people to write inconsistent code just to "win" achievements. "I need to do something with this data structure, I'll stick it in here, even though something else would probably be better..."

  21. Badges?!?! by CanHasDIY · · Score: 1

    We don't need no stinking badges!

    Somebody had to say it.

    --
    An enigma, wrapped in a riddle, shrouded in bacon and cheese
    1. Re:Badges?!?! by Megane · · Score: 1

      ISAGN for Badge Perfume.

      --
      #naabhaprzrag, #sverubfr-000, #agi-fcbafberq, negvpyr[pynff*=' negvpyr-ary-'] { qvfcynl: abar !vzcbegnag; }
  22. Only 5 curses in one file? by Coisiche · · Score: 4, Funny

    Clearly my code commenting technique is slightly different from the norm.

    1. Re:Only 5 curses in one file? by avandesande · · Score: 1

      Weird- I am from NJ and pretty foul-mouthed, but I have never once in 15 years felt the urge to put profanity in my comments.

      --
      love is just extroverted narcissism
    2. Re:Only 5 curses in one file? by Anonymous Coward · · Score: 0

      You should exercise your potty-fingers by working at my company. Developers don't last long here (I'm looking) because we're not actually allowed to fix anything - only band-aids are allowed. Everything is 100 times harder than it should be because of the lack of early design decisions - heck, I'm pretty sure that the initial idea was an afterthought.

      When you're searching for an error in 5 layers of stupidity, the urge to add a ripe comment is overwhelming.

    3. Re:Only 5 curses in one file? by geekoid · · Score: 1

      I do, but only in Klingon.

      --
      The Kruger Dunning explains most post on /. http://en.wikipedia.org/wiki/Dunning%E2%80%93Kruger_effect
    4. Re:Only 5 curses in one file? by Coisiche · · Score: 2

      I live in Scotland.

      No further qualification necessary.

    5. Re:Only 5 curses in one file? by gila_monster · · Score: 1

      /* may the addle-pated twit who wrote this abomination be covered in honey, fire ants, and Justin Bieber's spooge, run through Snooki's alimentary canal, then given to Dick Cheney as a hunting buddy */

      --
      Ad luna, Alicia! Ad luna!
    6. Re:Only 5 curses in one file? by b4dc0d3r · · Score: 1

      When you spend a week finding out that the documentation does not match the behavior of that API or library call, and finally figure out how you have to work around it, there is no "urge" it is simply frustration while you tell future people why your code does not match the examples. Even the leaked MS code was full of this, according to reports, when the Office team did something stupid and the OS team had to put in a fix for it. Of course there are patches for thousands of programs.

      I used to have the reference, appcompat.txt, but I can't find a link right now.

  23. Re:"Gamification" doesn't make dull things a game. by X0563511 · · Score: 2, Insightful

    "achievements" ruin everything - games included.

    --
    For large sets, this will be our guide even unto death, for the LORD will work for each type of data it is applied to...
  24. Yes! Facebook and twitter sharing. by Bigfield · · Score: 1

    Not only there are badges but you can share them on social media. How's that for a progress! Now we only need find a person who would willingly do that...

    Seriously, this feature must be from the clippy department. I find it very hard to see that any sane person would find any use for these "advanced" features.

    1. Re:Yes! Facebook and twitter sharing. by geekoid · · Score: 1

      Me. I will do it..if it supports G+

      You must live i a pretty small mental box if you don't see this as a way to learn more about the environment. Hopefully there will be achievements for certain coding techniques.

      --
      The Kruger Dunning explains most post on /. http://en.wikipedia.org/wiki/Dunning%E2%80%93Kruger_effect
    2. Re:Yes! Facebook and twitter sharing. by Bigfield · · Score: 1

      I guess so then. Could you explain how sharing e.g. potty mouth badge in twitter help in learning the environment? My original comment was about the social media usage.

      Using lint, klocwork and other static code analysis tools or at least using the highest compiler warning level are all beneficial in terms of learning the language and in every day work when you have learned the language and the environment.

      More over, by code reviews, pair programming etc. you can learn a lot and find many bugs and learn better ways to do things that no social media sharing can do. Twitter for example is awful media for code sharing. Consider for example the maximum tweet length.

  25. Re:seriously — they're totally missing the p by virgnarus · · Score: 5, Insightful

    There are plenty of individuals out there - including myself - that would go in a frenzy and would attempt to earn all the achievements, regardless if they're bad or not.

  26. man, not vendor by mapkinase · · Score: 4, Insightful

    Achievements should be defined by management, not the software vendor.

    --
    I do not believe in karma. "Funny"=-6. Do good and forbid evil. Yours, Oft-Offtopic Flamebaiting Troll.
    1. Re:man, not vendor by AaronLS · · Score: 1

      Even managers with former programming experience are terribly out of touch and would be ineffective at defining achievements at such a low level, much less writing software that would detect when the acheviement was acheved.

    2. Re:man, not vendor by mapkinase · · Score: 1

      We have our own set of coding guidelines and management doing excellent job by numerically assessing the fitness of the code in terms of those guidelines. Proper management does not do anything, it finds people that are suitable for that task. In this case one needs to find a person who is capable of doing the job of measuring how nicely the code is written.

      Screw generalized guidelines.

      --
      I do not believe in karma. "Funny"=-6. Do good and forbid evil. Yours, Oft-Offtopic Flamebaiting Troll.
    3. Re:man, not vendor by Tom · · Score: 1

      Achievements should be defined by management

      Yeah! We wouldn't want anyone who actually has a clue about coding to define them, would we?

      Good managers don't need this, and bad managers - will become worse.

      --
      Assorted stuff I do sometimes: Lemuria.org
    4. Re:man, not vendor by HyperQuantum · · Score: 1

      Yeah.

      One such achievement defined by management could be: Writing 10,000 Lines Of Code In One Day.

      --
      I am not really here right now.
  27. Job Security by broseidon · · Score: 1

    Personal favorite: Job Security. Because meaningful variable names are pish-posh! *facepalm*

  28. Next on the list: by ledow · · Score: 2

    Taking inspiration from Dungeons of Dredmor (with NH homage, I believe):

    Suddenly the Dungeon Collapses

    Achieved when you manage to crash the program.

    1. Re:Next on the list: by Anonymous Coward · · Score: 0

      Agreed! My two favorite VS achievements were always: (1) getting the "Catastrophic failure" error dialog, and (2) hanging the entire OS. Rare enough to be worth their own badges, I think.

  29. So, when do I get Achievements in real life? by Anonymous Coward · · Score: 0

    Helping an old lady
    Doing my homework
    Calling my mum

    Achievement score!!

    1. Re:So, when do I get Achievements in real life? by simcop2387 · · Score: 1

      You should talk to the BSA, they started all this shit. http://www.bsa.org/

  30. WTF? by gstoddart · · Score: 5, Insightful

    Why would I want my dev environment to have leaderboards and be "gamified"?

    I'm glad it's only a plugin, but to me this is part of the annoying trend that everything we do needs to be tied into social media ... I mean, "they can also brag about their achievements on Facebook and Twitter". Why on earth does everything we do nowadays need to be tied into Facebook and Twitter?

    I'm waiting for the first wave of toilets with integration to those sites ... then we will truly widespread "Twitter Shitters" and other bits of stupidity.

    Then again, maybe I'm just old and uncool, and all of the cool kids are doing this ... but to me this just sounds like something which is utterly pointless.

    --
    Lost at C:>. Found at C.
    1. Re:WTF? by geekoid · · Score: 1

      Not pointless.
      In my experience, there are great areas of many Dev environments that don't get looked at, or used as often as the should. By creating an achievment approach, you can look at achievements and do something just to gain it.
      For examples: A great many people don't know how to do block cut and pastes in VS, or most editors the support it.

      ALT + LMouse, btw.

      I have been talking about this sort of thing for decades, and I am thrilled it's starting to get integration outside of games.
      The social side, if used, brings out competitive nature in the best way.

      As to your original question: Millions of people use those tools to communicate. Probably most then any other communication tool. So if you want to show someone the can communicate something, you use the most common way to do so.

      --
      The Kruger Dunning explains most post on /. http://en.wikipedia.org/wiki/Dunning%E2%80%93Kruger_effect
    2. Re:WTF? by Anonymous Coward · · Score: 0

      Then again, maybe I'm just old and uncool, and all of the cool kids are doing this ... but to me this just sounds like something which is utterly pointless.

      Oh you party pooper, you... You are old and uncool.

      Mind you, saying that, so am I. I'm now old enough and wise enough to know that about 90% of what we do in our entire lives is "utterly pointless", so may as well join the Twitbook crowd and engage in more utterly pointless behaviour.

    3. Re:WTF? by sandytaru · · Score: 1

      You're working from home. One of your coworkers complains that you haven't turned in as much code as he has and tells your boss on you. Your boss, concerned about possible slacking, checks your twitter feed, and sees that in the last hour you just got the "Wow, you're really concentrating!" badge in VS for having constant interaction with the problem for the last three hours straight - e.g. it's been open since 9AM and you've been typing code ever since pretty steadily. Boss, having done his due diligence, ignores your coworker.

      --
      Occasionally living proof of the Ballmer peak.
    4. Re:WTF? by Anonymous Coward · · Score: 0

      It has nothing to do with age, just insecurity and lemming mentality.

      All the actually cool kids have never even wondered whether they're missing out on anything by not using Feltchbook or Shitter.

    5. Re:WTF? by ElusiveJoe · · Score: 1

      then we will truly widespread "Twitter Shitters" and other bits of stupidity.

      I thought that was the only purpose of Twitter - to tell everyone when you eat or go to toilet.

    6. Re:WTF? by Anonymous Coward · · Score: 0

      Then again, maybe I'm just old and uncool, and all of the cool kids are doing this ... but to me this just sounds like something which is utterly pointless.

      i'm not old, but i do think that tying everything to social media is bullshit. i don't have a facebook or a twitter and i probably never will have the will to make one (and screw anyone who tells me to do otherwise)

  31. Re:seriously — they're totally missing the p by Anonymous Coward · · Score: 0

    And all of them are incontrovertible evidence that MS is jumping over a very large shark.

  32. What real men use.. by kallisti5 · · Score: 1, Redundant

    Real men use gcc, vim, coffee, and a gun.

    1. Re:What real men use.. by geekoid · · Score: 3, Insightful

      Smart men use the tool that makes the job the easiest.

      --
      The Kruger Dunning explains most post on /. http://en.wikipedia.org/wiki/Dunning%E2%80%93Kruger_effect
    2. Re:What real men use.. by Anonymous Coward · · Score: 0

      I presume the gun is for people telling you to use emacs.

    3. Re:What real men use.. by networkBoy · · Score: 1

      so gcc, vim, coffee, and a gun then. Glad we all agree ;)

      --
      whois gawk date unzip strip find touch finger mount join nice man top fsck grep eject more yes exit umount sleep dump
    4. Re:What real men use.. by Anonymous Coward · · Score: 0

      I presume gun is on the list to shoot yourself after spending several more hours debugging an obscure AV due to memory corruption in some function that had long since returned?

    5. Re:What real men use.. by Anonymous Coward · · Score: 0

      Smart men use the tool that makes the job the easiest.

      Real men use gcc, vim, coffee, and a gun.

      I'd say he's got it covered.

  33. Re:Throw an exception by Frohboy · · Score: 1

    Incidentally, this is how "break" is implemented in Scala. There is no break keyword in the language, but it is implemented at the library level by throwing/catching an exception.

    Here's the source code:
    https://lampsvn.epfl.ch/trac/scala/browser/scala/tags/R_2_9_1_final/src//library/scala/util/control/Breaks.scala#L1

  34. I've been trying to recover from decades of hating by Nelson · · Score: 4, Insightful

    Seriously, I have been trying to get over the MS hate that I've had since Windows 3. They're just another big company, trying to do what they can and at least they try to compete in new markets even though they routinely get shelled by the competition when they stray off the desktop.

    But WTF?!?. Badges in Visual Studio? For real? They have no idea what they are doing. Are they chasing 15 year old developers to be? This is a company with 10s of billions in cash that can subsidize products like Xbox for years and years. This is fucking Bob in the IDE.

  35. Hey, everyone, look! by 0xdeadbeef · · Score: 1

    This joke ridiculing a trend was turned into real thing ridiculing a trend, so it is evidence of a trend!

  36. Maybe the real reason.... by Dcnjoe60 · · Score: 4, Funny

    Maybe the real reason for the badges and leaderboards is so inept managers who know more about marketing than programming have some way to evaluate what the programmers are doing.

    1. Re:Maybe the real reason.... by Rudisaurus · · Score: 1

      Maybe the real reason for the badges and leaderboards is so inept managers who know more about marketing than programming have some way to evaluate what the programmers are doing.

      Somehow I don't think you were really trying to be funny ... there's more than a grain of truth to this!

      --
      licet differant, aequabitur
  37. Re:I've been trying to recover from decades of hat by Anonymous Coward · · Score: 0

    If Rover pops up when you fail to authenticate to SVN three times and just prompts you to change your password I'll be all for it. Security through absurdity.

  38. Re:seriously — they're totally missing the p by Tim4444 · · Score: 1

    I guess I'm playing with cheat codes. All I have to do is check out and compile one of our solutions and I've automatically got all the "Power Coder" achievements. Until today, I'd never considered any of those attributes to be things anyone would want to consider as goals - not that they are inherently bad. That's nothing special either. I think there are hoardes of programmers out there working on software for which this is true.

    Where's the points for things like consistant formatting and naming conventions? How about a low ratio of intermodule dependencies comparied to complexity (ie. orthogonality)? How about points for checking error conditions? How about points for adding a unit test or updating the comments around the code you're working on? Is "Equal Opportunist (10 points) Write a class with public, private, protected and internal members. It's all about scope." really the best they could come up with for a Top 6 list? It's sad to see how far they've fallen since the days of Steve McConnell and Code Complete.

  39. Goto is great when bringing up a compiler by Anonymous Coward · · Score: 0

    Goto is great when bringing up a compiler for a new architecture. The first legal program I've compiled when creating a new backend is something like this:

    void foo(void)
    {
            bar:
                    goto bar;
    }

    The equivalent of while(1); is quite a bit harder to bring up since you need a functioning conditional test for the while() to function (at least when you are compiling without optimizations, which is probably a pretty good idea when bringing up a compiler the first time...)

  40. Re:I've been trying to recover from decades of hat by Olix · · Score: 3, Interesting

    I'm 22 and I think this sounds pretty cool. I'm already addicted to achievements in videogames, why not be addicted to achievements in programming, too?

    It's like the drug dealers who gave out free samples of crack with the heroin they sold.

  41. Re:seriously — they're totally missing the p by Hythlodaeus · · Score: 1

    The goal seems to be to get developers aware of and experienced using particular features of the most premium editions of VS.

    --
    For great justice.
  42. Need this for my students by lorinc · · Score: 1

    It could really ease the evaluation step :)

  43. lol by Anonymous Coward · · Score: 0

    Achievement unlocked(-10G) You have more errors than lines of code.

  44. Good by geekoid · · Score: 2

    I can't wait for achievement to be everywhere. I think they me the best way to get a populous to achieve an over all, non critical goal.

    --
    The Kruger Dunning explains most post on /. http://en.wikipedia.org/wiki/Dunning%E2%80%93Kruger_effect
  45. How about the other way around? by alexo · · Score: 2

    When will Visual Studio achieve the "supports the C++11 standard" badge?

    1. Re:How about the other way around? by shutdown+-p+now · · Score: 1

      The more votes this gets, the faster it'll be.

      That said, while VC is not exactly on the frontlines here, I don't think there's any compiler claiming full conformance as of today. For myself, I'm quite content with having lambdas, decltype, auto and rvalue references, and the only thing that's really still sorely missing is variadic templates. Library-wise, VC11 is already mostly conforming except for initializer lists (which are kinda useless without compiler support, in any case).

  46. Re:seriously — they're totally missing the p by Anonymous Coward · · Score: 1

    I'd argue that working on a Saturday or Friday night is the exact opposite of positive behavior.
    If anything, it should earn a label of shame for management, as it's clear evidence of poor scheduling and inadequate allocation of resources.
    But alas, this is protestant america, where wringing the last bead of sweat from your lifeless husk is seen as fantastic.

  47. Gamification instead of taxes by MobyDisk · · Score: 2

    What if we had government gamification instead of taxes? Instead of taxing cigarettes, let's have an achievement for not smoking. Or achievements for eating healthy foods. Achievements would earn you points toward social security. Companies could offer achievements toward pensions and retirement. Maybe instead of a military, we could have achievements for killing enemy soldiers. Oooh, I see the makings of a dystopian novel coming on!

    1. Re:Gamification instead of taxes by sandytaru · · Score: 2

      Weight Watchers actually has that, sort of. Every five pounds you lose gives you another star. After you reach your ten percent goal, they give you a keychain to hold charms, which include achievements such as "Ran a 5K" and little weights that represent the pounds you've shed. The most coveted one, of course, is the Lifetime Member, which means you've lost enough weight to reach your goal and you don't have to pay them money to play the game any more.

      --
      Occasionally living proof of the Ballmer peak.
  48. Cow by Anonymous Coward · · Score: 0

    I'm clicking a cow.

  49. with a little analysis... by weakref · · Score: 1

    they can add to the award list something like: *Copy-Pastry Chef* and *Spaghetti Monster*

  50. Re:I've been trying to recover from decades of hat by geekoid · · Score: 4, Interesting

    I'm many decades past 15 and this looks awesome.

    If you stopped and looked around for moment instead of assume you know what's going on you would realize how powerful achievements are. There are many, many good outcomes to this. The biggest will be more knowledgeable and experience developers.

    You can't have been around that long if you think this is MS Bob.
    That said, MSBob had a great start, but someone future wife was put in charge and basically managed it to shit.

    --
    The Kruger Dunning explains most post on /. http://en.wikipedia.org/wiki/Dunning%E2%80%93Kruger_effect
  51. Achievement Unlocked: Et tu? (10 points) by Anonymous Coward · · Score: 0

    Seem to agree with the thread parent, but then flip it around and call their continued employment into question!

    1. Re:Achievement Unlocked: Et tu? (10 points) by Anonymous Coward · · Score: 0

      In java, we call that "breaking out with labels"!

  52. Both decent and free? by tepples · · Score: 1

    But is a "decent optimising compiler" available as free software? Or is it like C++, where at one time one had to replace g++ and libstdc++ with proprietary, expensive Green Hills products to get any reasonable performance and footprint?

    1. Re:Both decent and free? by snemarch · · Score: 1

      Even gcc has been able to inline for many++ years. It's one of the more trivial optimizations.

      --
      Coffee-driven development.
    2. Re:Both decent and free? by Grishnakh · · Score: 1

      By most accounts, gcc/g++ these days seems to be regarded as a very good optimizing compiler, though perhaps not quite as good as Intel's icc. But icc costs money, and generally only gets you a marginal improvement in performance from what I've heard; for most people working with Free software, they're happy to have something that makes 5% slower code but is fully open and free.

    3. Re:Both decent and free? by tepples · · Score: 1

      Once I compiled a Hello World program using for a handheld platform with an ARM7 CPU and 288 KiB of RAM. Even after enabling Thumb instructions, size optimization, and gc-sections, the final binary ended up 180,032 bytes. (The version using was much smaller.) I looked into what might have been causing this, and a whole bunch of locale-related crap was staring me in the face despite that I wasn't printing any date or money objects. StoneCypher told me my problem was having used g++ and GNU libstdc++ instead of a sufficiently smart compiler, and he recommended switching to Green Hills Optimizing Compiler.

    4. Re:Both decent and free? by Ramin_HAL9001 · · Score: 1

      I looked into what might have been causing this, and a whole bunch of locale-related crap was staring me in the face despite that I wasn't printing any date or money objects.

      Did you ever try to use the "strip" utility?

  53. Re:"Gamification" doesn't make dull things a game. by Lumpy · · Score: 2

    Load up the linux kernel source code. you will get the "riddled with filth" achievement.

    --
    Do not look at laser with remaining good eye.
  54. If the profiler says 50% faster w/o unreadability by tepples · · Score: 1

    How many registers do state variables , forcing more useful variables to be spilled to the stack? Run a profiler on the state variables version of a function and the version with goto used as described in chapter 7. If the goto version is at least 50 percent faster with no cost in readability, then why not use the goto version?

  55. good only for learing/discovering IDE features by PJ6 · · Score: 2

    Meaningful coding achievements need to be task-oriented.

    But this is a good idea for making sure you're familiar with all the features the IDE offers. Done right, with interactive walkthroughs and whatnot, achievements could serve as an excellent supplement to documentation.

  56. Re:seriously — they're totally missing the p by mattdm · · Score: 1

    Oh, absolutely. I just meant that it shows engagement, so it could be construed as positive in that way. But overall it fits the negative theme.

    There's a great blog entry on 40-hour work weeks for programmers from, amazingly enough all considered, someone at Microsoft: http://blogs.msdn.com/b/jmeier/archive/2010/10/21/40-hour-work-week-at-microsoft.aspx

    So it's not like they dont' get this.

  57. Re:Knuth by obsess5 · · Score: 1

    From a classic issue of ACM's Computing Surveys devoted entirely to authors responding to Dijkstra's article.

  58. Re:"Gamification" doesn't make dull things a game. by pjt33 · · Score: 2

    I think 5 curses in a file indicates bad design. If you need more than one library for handling your TUI you're clearing Doing It Wrong.

  59. Re:seriously — they're totally missing the p by ByOhTek · · Score: 1

    In particular, the best reason it should be enforced by people, is that, many such rules have exceptions, and the people will understand them, the IDE won't.

    --
    Self proclaimed typo king, and inventor of the bear destroying coffee table (patent not pending).
  60. Declare the variable where it is initialized by tepples · · Score: 2

    You could put the variable declaration outside the block assigned to null and then test if the value is null inside the finally

    Which would violate the commonly quoted best practice to make each variable's scope no longer than needed. That is, don't initialize the variable to null when you declare it and overwrite the null value later; instead, declare the variable where it is initialized for real.

    maybe it's time to think about decomposing the code into more manageable chunks

    Until the overhead of packing an inner chunk's return values into a return value object, passing it back to the caller, and unpacking them in the caller becomes measurable in the profile.

    1. Re:Declare the variable where it is initialized by DrXym · · Score: 2

      Best practice in Java is to immediately close streams when they are no longer used and the best way to do that is from a finally block. And the only way the finally block can see the variable is if it resides in the scope of the parent block or above. So it doesn't violate anything. The first response to this stackoverflow question demonstrates the typical way to do this. You will note that fis is set to null as I said and tested for null in the finally.

    2. Re:Declare the variable where it is initialized by Synerg1y · · Score: 1

      Pretty sure that mechanism doesn't exist in at least some lower level languages. Try catch finally is more of an OOP concept. I believe the Point of the article is that there is NO VALID REASON to use GOTO in any VS native language, thus the achieve if you do.

  61. Re:I've been trying to recover from decades of hat by amliebsch · · Score: 1

    1. It's optional.
    2. Yes, they do want to hook young programmers.
    3. It's essentially a tech demo for the VS plugin system, not a new core feature.

    --
    If you don't know where you are going, you will wind up somewhere else.
  62. Achievemnt Unlocked! Use a C99 Compliant Compiler by VortexCortex · · Score: 3, Insightful

    If only they'd put THAT in the damn compiler I MIGHT consider using it.

  63. Enums bad? by Anonymous Coward · · Score: 0

    "Write a enum with 30 fields. Who needs numbers when you've got words! "

    Why is this bad? I'd rather have an enum for return codes that make sense rather than returning 8238712;

  64. Re:I've been trying to recover from decades of hat by phantomfive · · Score: 1

    Are they chasing 15 year old developers to be?

    Yes.

    --
    "First they came for the slanderers and i said nothing."
  65. Re:I've been trying to recover from decades of hat by NewWorldDan · · Score: 1

    OMG, someone is trying to take a tedious job and make it just the tiniest bit more fun. And they might even help us learn something in the process. Microsoft certainly isn't forcing you to install this little add-on. It's coming out of Channel 9, which is targeted more towards amature and hobby programmers. One of their main sections is Coding4Fun. Don't be a hater.

  66. Security problem? by RobinH · · Score: 1

    In order to do this, they're either evaluating the code on the client to determine if you won a badge or not, which makes it extremely "hackable" (i.e. anyone can hack the client to make it send the signal that they've won a badge), or, even worse, it's sending all of your code to Microsoft for evaluation. I'm not sure your employer would approve of your IDE transmitting all their proprietary code to Microsoft.

    --
    "I have never let my schooling interfere with my education." - Mark Twain
  67. No P/Invoke by tepples · · Score: 1

    If you want your code to be as fast as c, I recommend writing it in c. Every higher level language I use allows you to link it in.

    I can think of one exception: C# on Xbox Live Indie Games and on Windows Phone 7 has no P/Invoke.

    1. Re:No P/Invoke by Tsingi · · Score: 1

      If you want your code to be as fast as c, I recommend writing it in c. Every higher level language I use allows you to link it in.

      I can think of one exception: C# on Xbox Live Indie Games and on Windows Phone 7 has no P/Invoke.

      It may be an exception for you, I don't use C#.

  68. Have fun... by Anonymous Coward · · Score: 0

    ...retards!

  69. The only good bug by dstyle5 · · Score: 1

    is a dead bug.

  70. Hmmm... No Thanks. by InsertCleverUsername · · Score: 1

    No thanks, I'm already playing lots of fun games in Visual Studio, like "Guess What this 3000 Line Function Does," "Find the Configuration Issue," and "Who Broke the Build?"

    --
    Ask me about my sig!
  71. Re:I've been trying to recover from decades of hat by stackOVFL · · Score: 1

    Just wait until MS springs the next add-on: Visual Studio MMORPG (some folks will call it co-development tools) and charges us a $14.00/mo fee for "coding".

  72. Re:I confuse GOTO and SETJMP by b4dc0d3r · · Score: 1

    This sounds like a confusion of goto versus setjmp/longjmp. IIRC the K&R book essentially says "use at your own risk" due to reasons in gp's explanation. The normal goto does not have this caveat.

    GOTO is a useful tool, as long as it is only used when that is the most sensible and elegant way of solving a problem. Or in rare cases when a quick fix is needed with minimal side effects, and again when it definitely won't cause stack or unwinding problems.

  73. Anything but money by SuhlScroll · · Score: 1

    I guess if you don't want to pay for programming help this is an alternative, especially when you can't import half of India on H1B visas like Bill Gates would like to do.

  74. Re:I've been trying to recover from decades of hat by gtirloni · · Score: 1

    For newer generations, if it is not in game format, they don't care.

    --
    none
  75. Award GTH badge when the compiler emits JMP? by tlambert · · Score: 1

    Award GTH badge when the compiler emits JMP?

    After all, if it's bad for a novice programmer to use a jump to a label like that, how much worse is it for a compiler writer to use one, when they are supposedly professionals who know better?

    -- Terry

  76. GOTO = 1911 shotgun with pyro slugs by RobertLTux · · Score: 1

    you may have an armoury covering 4500 meters of space with racks 10 meters high but sometimes in some cases the only thing that will do X Cleanly is That Shotgun and Those Rounds.

    the trick is to not use it when its unneeded (or on your FOOT)

    --
    Any person using FTFY or editing my postings agrees to a US$50.00 charge
  77. Re:Achievemnt Unlocked! Use a C99 Compliant Compil by shutdown+-p+now · · Score: 1

    It's called Visual C++ for a reason - it really is primarily a C++ compiler with accidental C support, that, AFAIK, is there mainly due to its Microsoft C legacy.

  78. Ask Slashdot: Code question by mcalchera · · Score: 1

    Are "fuck" and "motherfucker" separate curses? Come on guys I need to know, my supervisor said I need to have 50 points by next Monday!

  79. Re:"Gamification" doesn't make dull things a game. by pinkushun · · Score: 1

    Well said AC! It reminds me of this grid of "How programming fanboys see each other"; Visual Studio deserves it's own column, each picture that of a tinka-toy.

  80. Re:I've been trying to recover from decades of hat by Simulant · · Score: 2

    "I'm already addicted to achievements in videogames"

    You are being played.

  81. Re:"Gamification" doesn't make dull things a game. by Anonymous Coward · · Score: 0

    BS. Go back to playing kick-ball without keeping score and leave the rest of us alone.

  82. Will it by sjames · · Score: 1

    If you correctly play "Mary had a little lamb" on the bicycle horns with your nose, will it dispense a fish?

  83. Prior Art! by Richard+Kennard · · Score: 1

    Can I claim prior art?

    3 years ago I posted this blog as a joke: http://blog.kennardconsulting.com/2008/12/new-features-in-eclipse-35.html

    Now it appears Microsoft has actually gone and done it!

  84. Re:"Gamification" doesn't make dull things a game. by X0563511 · · Score: 1

    Achievements != Score. Go back under your bridge.

    --
    For large sets, this will be our guide even unto death, for the LORD will work for each type of data it is applied to...
  85. Strip is side effect of objcopy by tepples · · Score: 1

    Did you ever try to use the "strip" utility?

    No, but I used objcopy, which does the same thing. It converts ELF to a raw binary and strips out the debugging symbols in the process.