back to article Good thing this dev quit. I'd have fired him. Out of a cannon. Into the sun

Roll up, roll up. It's your Wednesday dose of ridiculous code spotted in the wild. If you've seen some horrors, send over your tales, please, and we'll share them with our readers. We've had a great response so far, which perhaps is a damning indictment for the software engineering industry. It can't be all bad, though – …

  1. theOtherJT Silver badge

    Let me guess, that last one was an academic?

    There's something about academics and amusingly ancient versions of Fortran. Well, they would be amusing, but when they show up in your office with a Fortran IDE on floppy disk and want it installed on the managed desktops it stops being amusing really quickly.

    1. theModge

      Re: Let me guess, that last one was an academic?

      I know of pretty of chemistry academics still using fortran. The real question is are they using anything so modern as fortran 77? Or is it still the really old version that's formatted to fit on punch cards?

      1. Paul Crawford Silver badge
        Pint

        Re: anything so modern as fortran 77?

        Converting FORTRAN IV from https://celestrak.com/NORAD/documentation/spacetrk.pdf in to C was not much fun, but sadly it was necessary to have any sane way forward. Start with f2c conversion, spend time sorting out the weird functions it used to make Fortran-like calls (i.e. by reference) instead of C-like (usually by-value) and finally work out how to restructure to code so it looked sane and still worked.

        Oh, and a subroutine with multiple ENTRY points also had to be converted, but thankfully it was just a dodgy way of having shared auto-allocated (implicit declaration & typing) variables. Anyone writing Fortran without "implicit none" deserves a serious slapping!

        Needed oh so much =>

    2. elDog

      Re: Let me guess, that last one was an academic?

      I'm guessing the chap (or chapstress) was playing with memory caching. We used to put items that were frequently used together (input and output cells) in proximity since fetching from a block of contiguous memory was more efficient.

      Actually, that brings up another wonderful trick from the early 8088 days: execute code on the stack since it was guaranteed to be ready/available and easily reachable via ,SP. Ah, the good old days of coding animation for the PC Jr. (Thanks Time-Life, Broderbund, etc.)

    3. BoldMan

      Re: Let me guess, that last one was an academic?

      Oh this brings back terrible memories trying to support FORTRAN written by "clever" scientists, using nested arithmetic gotos and other such horrors.

      Scientists/academics should not be allowed to write code that anyone else needs to touch! :)

    4. Anonymous Coward
      Anonymous Coward

      Re: Let me guess, that last one was an academic?

      There is something about academics that mean they can't code....

      Seriously, I think only one professor in my university knew how to write good code, and that was because he'd worked commercially in addition to being a professor....

      I often re-wrote the helper classes & methods we were given to use, purely because they were so badly written it frustrated me to even try and use them....

      I would tell the lectureres I re-wrote them, why I did it and then ensure they had my updated code for future years...

      1. keithpeter Silver badge
        Coat

        Re: Let me guess, that last one was an academic?

        "There is something about academics that mean they can't code...."

        I suspect the OA was talking about academics in other subjects rather than computing lecturers. Physicists and Biologists and Chemists live very close to their problem domains and probably see the computer as a huge calculator that can print things nicely (well, I did). They may not need/want to abstract away the underlying logic of whatever problem they are trying to solve...

        PS: @Tom 13 I used to number my punched cards in pencil on the back just in case I dropped the stack. That was considered to be a useful innovation at the time...

        1. Vincent Ballard

          Re: Let me guess, that last one was an academic?

          Some computer science academics have experience in the real world and know how to write good software. Others are complete disasters. They know how to write for the common case, which is all they need to get the results they want for their papers, but don't know anything about writing software which handles corner cases and is robust enough for the real world.

        2. Phil O'Sophical Silver badge

          Re: Let me guess, that last one was an academic?

          I used to number my punched cards in pencil on the back just in case I dropped the stack. That was considered to be a useful innovation at the time...

          That's why Fortran only uses columns 1-72, you punch sequence numbers in the last 8 columns (going up in 10s so you can insert missing cards later, just like you used to do for BASIC line numbers). Then when you drop the stack you can load them in any order and have the system reorder them for you.

          1. keithpeter Silver badge
            Coat

            Re: Let me guess, that last one was an academic?

            "That's why Fortran only uses columns 1-72, you punch sequence numbers in the last 8 columns (going up in 10s so you can insert missing cards later, just like you used to do for BASIC line numbers)."

            Excellent, I wish I could go back in a time machine and tell the 22 year old me about that. That old mainframe was the first card-punch input machine I had used. 'Coffee batch' before that.

            Mind you, those card punches took a bit of typing. We did Algol as an undergrad, I had to learn FORTRAN on the 'job'.

          2. Dyspeptic Curmudgeon

            Re: Let me guess, that last one was an academic?

            I am pretty sure that Fortran started out to use only 1-72. The ability to add line-numbers in columns 73-80 came a little later.... If memory serves ( but sometimes it can only volley at all well) the changeover was about 1970 or so. Since I can remember writing line numbers on the cards and only later being able to use the end columns..... Dropped a box containing a ~4000 line program down a stairwell once. Luckily it was AFTER numbered columns were available...

            Long ago in a galaxy far far away....

        3. The Rest of the Sheep

          Re: Let me guess, that last one was an academic?

          My favorite way is simpler - a diagonal stripe across the top of the card deck. Maybe not as exact as numbering, but will get you very close.

      2. druck Silver badge
        Unhappy

        Re: Let me guess, that last one was an academic?

        AC wrote:

        I often re-wrote the helper classes & methods we were given to use, purely because they were so badly written it frustrated me to even try and use them....

        I would tell the lectureres I re-wrote them, why I did it and then ensure they had my updated code for future years...

        I can imagine how well the egotistical bastards took that - did you managed to graduate?

        I was lucky enough to get one one of the first Computer Science courses in the country using C++. The language was only a couple of years old, and the only compiler was CFront. There was no teaching books on it at the time, so the lecturer writing one based on the course. At the end of the year he gave us the draft printout of the book, and promised a pint for each mistake anyone spotted. I had a list of 10 by the next day, did I get as much as a single pint? The hell I did, and strangely enough things started getting a lot more difficult after that.

    5. Tom 13

      Re: on floppy disk and want it installed on the managed desktops

      Be thankful it was at least on a floppy disk. Could be worse; it could be magnetic tape or even punch cards.

    6. /dev/null

      Re: Let me guess, that last one was an academic?

      I once worked on a complex Fortran-77 "code" (hard scientists always use the word "code" as a singular noun, not a mass noun) where all the important data was held in one giant 1-dimensional array. Some of it was integers, some floating-point, some elements were "pointers" into other parts of the array...

      And then there was the module that was written by a mathematician who never added comments to his code because they would slow down the execution...

      1. dajames

        Re: Let me guess, that last one was an academic?

        I once worked on a complex Fortran-77 "code" (hard scientists always use the word "code" as a singular noun, not a mass noun) ...

        I've noticed that trait, and ascribed it to non-native English speakers ... bit while 'hard scientists' may not be capable of speaking plain English, many of them certainly are native English speakers.

        At least "a code" is better than "a soft".

    7. fajensen

      Re: Let me guess, that last one was an academic?

      Academics always have to prove how clever they are at whatever task attempted - and thus we get abominations such as: "NUMERICAL RECIPES IN C: THE ART OF SCIENTIFIC COMPUTING (ISBN 0-521-43108-5)" - where parentheses are banned from really hairy expressions because only a moron will be ignorant on the evaluation order of C operators.

      .... and the lesser academics are copy-pasting the "FORTRAN in any language with C-quirks on top" code that they ripped from books all over the matrix.

      1. Alan Johnson

        Re: Let me guess, that last one was an academic?

        I actually quite like numrical recipes at least the numerical parts but the code style is awful, not least in the use of single letter variable names starting with a and working through the alphabet as if the length of variable name was related to efficiency or memory usage.

        The attitude of mind was illustrated when I tried to compile the code that goes with the book on a unix system. The numerical recipes code had a function called 'select'. This caused a lot of header file/linking issues with the completely unrelated POSIX call of the same name. Anyway after working around the issue I sent a nice e-mail describing the problems and suggesting that in time they modified all of the function names by adding a prefix to make the names unique or at least much less likely to conflict. The reply was that they considered the problem a bug in the OS I was using and they had no intention of changing!

        Maybe not an example of awful coding but an example of an awful attitude.

        1. Simon Harris

          Re: Let me guess, that last one was an academic?

          "not least in the use of single letter variable names starting with a and working through the alphabet as if the length of variable name was related to efficiency or memory usage."

          If they'd started out using interpreted BASICs (well those that actually allowed long variable names) then it probably was related, and of course, if they'd used versions that didn't allow such things, then single letter names would be what they were used to.

        2. GrumpenKraut
          Boffin

          Re: Let me guess, that last one was an academic?

          > ...numerical recipes...

          A word of warning: the books are OK for a first intro, especially if you check the referenced papers (though these urgently needed updates last time I look).

          Actually using the code is VERY ill advised. There are enough problems with correctness and performance to screw your project. A friend of mine got bitten by this: mentioning "numerical recipes" next to him is now outright dangerous.

          Finally, the license terms are bonkers.

        3. Sam Liddicott

          Re: Let me guess, that last one was an academic?

          and an example commercial naivety

          Did they want the major conversations about their book to be about how people couldn't get the code to link properly? Or to be stories of success and usefulness?

      2. GrumpenKraut

        Re: Let me guess, that last one was an academic?

        > Academics always have to prove how clever they are at whatever task attempted...

        Wrong. Yours, an academic.

  2. Anonymous Coward/2.0
    Facepalm

    re: left to my own devises

    I used to program in Coral66 which institutionalized something akin to the wonderful #defines in the article. In Coral66 keywords are in primes, e.g. 'IF', 'THEN', 'ELSE', 'BEGIN', 'END' and so on.

    This fine except that it meant that you could spaces in variable names but the spaces were ignored by the compiler. These all refer to the same thing -

    my variable, myvariable, m y v a r i a b l e, my variable

    As you can imagine it became a nightmare trying to find a variable in a big program where developers had used spaces in their own unique way. We tried to ban the use of spaces inside variable names but there were always the maverics that insisted on using them and legacy code and the careless Friday afternoon code post pub lunch.

  3. JimmyPage Silver badge
    Flame

    Ah, VB ... "variants"

    I once worked on a sizeable project in Weath Managment.

    Written in VB (I hail from a C/C++ background) they had tried to be "all grown up" and name variables correctly. So you had iCount, dblPrice, strName etc.

    Problem was, they were all variants.

    Which meant, if there was a fuck-up in the chain, and a string got accepted for a numeric value, the error could be propagated a long way from the source.

    1. Kubla Cant

      Re: Ah, VB ... "variants"

      iCount, dblPrice, strName etc.

      Aaargh! The abominable Hungarian notation!

      It's just about excusable in a language with few data types, where it provides some sort of validation, if anybody bothers to read it. The trouble is, nobody does.

      Then the type gets changed, but the Hungarian remains the same, because development environments where Hungarian notation is used rarely support refactoring. At which point it's actively misleading.

      Then developers who don't know how it's supposed to work start devising their own Hungarian prefixes, often to indicate the usage of the variable, eg domNumber because it holds the day of the month.

      (Apologies to any actual Hungarians reading this.)

      1. Someone Else Silver badge
        Pint

        @Kubla Cant -- Re: Ah, VB ... "variants"

        Aaargh! The abominable Hungarian notation!

        Any enemy of Hungarian Notation is a friend of mine. For you, my friend --->

        1. J.G.Harston Silver badge

          Re: @Kubla Cant -- Ah, VB ... "variants"

          Hungarian notation is ok, but for /meaning/, not for typing.

          timerInit, timerSlice, fnameExpand, ctxOld, ctxCurrent, ctxNext, etc.

    2. Bc1609

      Re: Ah, VB ... "variants"

      While the variant type is indeed abominable, it is sometimes preferable to the cock-ups you can get when using the proper number types. Because VB/VBA creates types for you if they're not specified properly you can end up with exceptions just by multiplying five-digit numbers together.

      (Of course, a competent coder wouldn't have that issue, but the entire problem is that we're not dealing with competent coders...).

    3. Kubla Cant
      Flame

      Re: Ah, VB ... "variants"

      Another VB horror I had to sort out.

      A developer writes a critical routine that takes a datetime parameter. This routine eventually gets called from hundreds of locations all over the system. Often it's actually passed a datetime value, but sometimes it gets a variant and sometimes it just gets a string. VB says "that's cool, just pass any old thing and I'll make it work".

      Years pass, and it starts to become clear that there are some bad dates in the system. It turns out that VB's way of turning strings into dates is to ignore the system locale and try to guess what the format might be. Pass in "25/12/2015" and it correctly assumes DMY and returns 25 December, but when it sees "10/12/2015" it returns 12 October! Finding the bad calls is more or less impossible, given the lack of VB code analysis tools.

      The cause of this problem is a thing called cdate() that lives deep inside the run-time infrastructure. It turns out that the only way to fix it is to add code that patches the run-time after it's loaded into memory, not something you really want to do on a mission-critical server.

      Thank you, Microsoft.

      1. I'm Brian and so's my wife

        Re: Ah, VB ... "variants"

        No - never, never use CDate() since it'll happily wave through Yank dates.

        Also, IsNumeric() will allow through 123,,445,,6,5,4

        I ended up writing helper functions that employed regex to ensure that the values matched.

  4. Anonymous Coward
    Anonymous Coward

    How does bad code like this ever reach released state? Isn't all code peer-reviewed and approved?

    Individuals can make mistakes and poor judged decisions. But since the 60's we've known that quailty requires a code review process. You don't just bung it from development direct to functional test.

    1. A Non e-mouse Silver badge

      Because coders don't always work in teams? Maybe the code started out as a niche project which grew beyond its original use case? Maybe the boss didn't want to "waste time" tidying up or re-writing something that already works.

      As to "Testing", well, that's just overhead, so just go straight from development to live...

    2. Jason Bloomberg Silver badge

      Ah, in such a perfect world. Unfortunately it's often not. When code is being screamed for it's whatever works no matter how bodged, fudged and kludged it has to be. Often the programmer committing the atrocity knows that's exactly what they are doing, knows what nightmares they are creating along the way, but they don't get to call the shots.

    3. Just Enough

      Coding by geniuses

      Because the code monkey writing the shitty code usually has a boss who knows nothing about writing code. So all the boss knows is that the code appears to work, was written really quickly, and only the code monkey understands it. Therefore the code monkey must be a freaking genius.

      Experience shows that if you are in a new job, and are introduced to a colleague by the boss as a "genius we couldn't do without", it often means that they are a dangerous lone developer who produces shitty code that no-one else has ever been asked to review.

      1. matchbx

        Re: Coding by geniuses

        I work with one of these geniuses..... He's a very knowledgeable developer, but he never tests anything and is often surprised when a bug occurs in his code. He lives and dies by the motto, how fast can I have this done. His code is usually overly complicated, cause it's a micro second faster to do it this way, but you waste hours trying to figure out what he wanted to accomplish.

        I use him as an information source and a sounding board only. I NEVER follow his advice on how to implement any code routine.

        A few years ago at Christmas, I almost bought him a t-shirt from thinkgeek:

        "I don't often test my code, but when I do, I do it in Production."

        anonymous..... cause he might be reading this.

        1. GrumpenKraut

          Re: Coding by geniuses

          > anonymous..... cause he might be reading this.

          Oh dear, you missed that button before going into production.

          1. matchbx

            Re: Coding by geniuses

            yea... I see that now that it's too late to update.....

            I must have been busy reviewing my code......

      2. Brewster's Angle Grinder Silver badge

        Re: Coding by geniuses

        "...and are introduced to a colleague by the boss as a "genius we couldn't do without", it often means that they are a dangerous lone developer who produces shitty code that no-one else has ever been asked to review."

        *holds up hand*

        Yup, that'd be me.

        Although I'm not as bad as the one matchbox encountered: some of my code has test cases.

      3. LucreLout

        Re: Coding by geniuses

        @Just Enough

        Because the code monkey writing the shitty code usually has a boss who knows nothing about writing code. So all the boss knows is that the code appears to work, was written really quickly, and only the code monkey understands it. Therefore the code monkey must be a freaking genius.

        This ^^^

        I've suffered that situation so often over the past 20 years that I now simply quit when encountering said monkeys. There's nothing you can do for them because both the monkey and the manager are equally convinced of the monkey magic, and neither can grasp why its wrong, expensive, frustrating, and dangerous (from a risk PoV).

        I've seen nothing over the past 20 years that has in anyway persuaded me that our industry is better for not being regulated, similar to the GMC etc. It's the only way to keep the monkeys in the zoo rather than wandering through your business causing havoc.

      4. Nick Ryan Silver badge

        Re: Coding by geniuses

        I first encountered this when working on an industrial placement as part of my Uni course.I was given the task to take over code from the resident genius. His code was concise, fast and didn't work.

        It was so concise there were often no, or few validation checks with error messages. If something didn't work it was often ignored, and this "something" could have been any one of a dozen things in a single compound logic statement. Every bit of code worked like this, therefore when something didn't work it was next to impossible to work out why.

        Needless to say I simplified things and logged every damn error message so we knew exactly wasn't working, where and when which gave us a start as to why.

    4. d3vy

      "How does bad code like this ever reach released state? Isn't all code peer-reviewed and approved?"

      Ha.

      Good one.

    5. Anonymous Coward
      Anonymous Coward

      Usually, "peer reviewing" code is the best way to create a lot of enemies. Very few people on average like people reviewing (and criticizing) their work - unless working in environments were that's enforced for some reasons. I had many issues while pointing out bad code (and thoroughly explaining why it is bad, with a lot of references to books, best practices, standards, etc. etc.), or looking like the one who likes to put others into bad light, up to the point I was recalled by HR telling me explicitly "you need to learn how to relate to people properly" AKA don't "annoy" anybody and who cares if a lot of crappy code goes into production, HR doesn't care as long as it's not an HR issue.

      All I wish is to avoid that, because when the fans start to throw s**t around, it's not usually the "original developer" who is called to fix things quickly, and calm an angry and unwillingly to pay customer, but me, and I'm quite tired to fix someone else ugly buggy code - often needing a complete rewrite in a too short time.

      Lately I stopped reviewing completely, leaving that code entering production. After a while, I was even asked "please, oversee X to ensure he doesn't create troubles", and my answer was "I have my own tasks to finish. I have no time to babysit anyone. And if I advise him, he doesn't listen, is piqued, and then complains to HR. Choose: we get rid of X, and I write the code when I can, or he writes the code but I won't accept any responsibility of it, nor I'll babysit him". After a couple of times they choose solution 2, and customers were not happy at all, and s**t started to hit someone above me, a couple of developers were moved to other roles...

      Also in many software companies that have promotion states, those reviewing the code before accepting into an "higher" branch are not usually those who have the expertise to properly review it. It may happen in some notable projects like the Linux kernel, but in other situations they are often less skilled devs (or even testers) checking only if the code does pass tests.

    6. Code For Broke

      @Denigor: I honestly can't tell if you are joking or not. Is this what they call the "dry British wit"? Because, honestly, have you even ever used a computer, or looked at source code?

  5. GrumpenKraut
    Mushroom

    thermonuclear FORTRAN

    Approximately 11000 lines, all screaming capitals, no indentation. Of course no subroutines! About a hundred magic numbers, The program had 1 (one) comment in total, midway in, after a goto jumping almost 1000 lines forward. The comment read: "not needed".

    I warned the poor guy supposed to polish this monstrosity that he'd have a "window job": if you try this, you'll jump out of a window in despair. He left after spending eight weeks of trying with exactly zero progress. I was glad he did, as he looked unhappier every week and very much like a zombie near the end.

    Beat this.

    1. Androgynous Cupboard Silver badge

      Re: thermonuclear FORTRAN

      My first job out of university was an insurance broking system originally written in basic that had been automatically converted to C. Lots of fun stuff: I remember methods like b_streq(string1, string2) where 0 meant the strings were equal. Dozens of source files, each with a two or three methods several thousand lines long peppered with code like "goto b_2405" for flow control. Oh, and every variable was global, including loop counters, which meant every change had to be analyzed to see if the value of the variable was used later in the code without being reset.

      I don't recall if comments were included in the conversion, but I doubt they would have helped. Sadly I don't have any code from those days, otherwise I'd be submitting it.

    2. John Sager

      Re: thermonuclear FORTRAN

      The electromagnetic field modelling package NEC2 is a bit like this, though one part of the user manual does try to explain things. It uses magic numbers, particularly a high value (10,000) added to the segment number. Guess what happens when you have more than 9999 segments in a model...

      Of course the code was written in the days when a 9999 segment model would a) take far more memory than the computers in those days could handle and b) take longer than the age of the universe to run.

      Nowadays it's still used a lot by radio amateurs to model antennas so we run into these limits (amongst others in this package). I have hacked it to model up to 30k segments on Linux, but beyond that it runs into yet another, more fundamental limit.

    3. Anonymous Coward
      Anonymous Coward

      Re: thermonuclear FORTRAN

      I inherited some image processing code in my younger days when I was still a scientist. C++, written by a Pole who (when he commented at all) commented in phonetic Russian. Oh, and he really LOVED pointer arithmetic.

      Me, a polish - russian dictionary, russian - english dictionary and a great big bruise on my forehead from banging it on the desk. Pre-inernet (well mid 90s) so no online translation or anything else.

      I still wake up sweating occasionally!

    4. keithpeter Silver badge
      Windows

      Re: thermonuclear FORTRAN

      @Grumpen

      "I warned the poor guy supposed to polish this monstrosity that he'd have a "window job""

      Honest question: would it not have been easier to find out what this thing did by running it with a variety of inputs covering most cases and simply re-code it? I mean is there a point where you just decide to start again with a (comparitively) small system?

      PS: I think we need a thread for code that has been kept in systems for decades but never run.

      1. GrumpenKraut

        Re: thermonuclear FORTRAN

        This did run, it was a physics simulation of the most non-trivial kind. It was quite valuable to the department. Programmer had long left. There were _one_ _hundred_ magic numbers, and changing any single one simply broke things. As far as we saw the program was many different algorithms (entirely undocumented) made into one program. One could _guess_ what some places did, but no more than that.

        Re-writing the fucker would have been then plan, even though boss was delusional enough to think it could be tidied up in some way. But the value of the code was in the horribly convoluted variations of the (partly known) algorithms.

        Not a chance in hell.

        1. keithpeter Silver badge
          Coat

          Re: thermonuclear FORTRAN

          @Grumpen

          "...it was a physics simulation of the most non-trivial kind....the value of the code was in the horribly convoluted variations of the (partly known) algorithms."

          Look for the notebooks. All the serious physicists I have worked with kept a notebook for each project. Everything went in the notebook and was dated. Theoreticals for claiming priority and keeping track of what you refer to as magic numbers (aka 'parameters') and the experimentalists just in case of little ...err... upsets(*) in the lab.

          (*) slide 25 makes especially instructive reading. Writing it down helps you think it through before modifying equipment...

    5. Gotno iShit Wantno iShit

      Re: thermonuclear FORTRAN

      I once had to work on some embedded C a colleague had left behind. It was at the opposite end of the comments spectrum to the thermonuclear FORTRAN example above. A full screen in the editor could only have a maximum 2 lines of actual code on it due to the volume of comments. Every single line of code was followed by several paragraphs. It was all hand formatted for the authors favoured screen size with hard CRLF so you couldn't turn off line wrap. It was impossible to grok the structure of the code.

      The comments didn't even help much, they were predominantly long hand of the code. "If FirstExtrordiarilyOverVerboseVariableName is a value that is greater in magnitude than ConstantDefinedInOneOfAThousandCompilerMacroFiles then the programme will proceed to execute rather than skip over the lines of code following the opening brace below this point down to the closing brace which may be found further down this file". Like that example punctuation was in short supply. You'd turn blue as you mentally ran out of breath trying to read it. The worst case we found was one sentence that ran to 8 lines.

      1. GrumpenKraut
        Devil

        Re: thermonuclear FORTRAN

        Progammer:

        for (int LoopCounter=0; LoopCounter < MaxLoopCounter; LoopCounter = LoopCounter + 1) { SumOfArrayValues = SumOfArrayValues + ArrayOfValues[LoopCounter]; }

        Me: Please, kill yourself.

        They teach this style in (some) schools.

    6. Anonymous Coward
      Anonymous Coward

      Re: thermonuclear FORTRAN

      AC, cos some ex-colleagues might take offense.

      Amongst 6 years of being in super-computing (late 90s), I never found any readable Fortran code, ever. They all are totally cryptic/unreadable, utter shite and only work part of $DEITY's support. All of my engagements to reverse-engineer any fortran code ended up in a complete re-write in C, as it was faster.

      The reason seems to be only academic people use Fortran, since it is only tought in maths or physics class at university. And those guys never got proper code writting training, therefore don't write good code. And let's say it: Fortran is totally obsolete as a language and no computer scientist uses it.

      Most of the time, when reading such terrible fortran code, you can feel for the poor guy that never really got the concept of variable type, flow of code, comments and struggled so much to come up with something working.

      At contrary, computer science guys get thought C, C++ or ADA, plus some basics on writting good and readable code.

      That's why only computer scientists write good code while other academics's code is most always unreadable.

      1. GrumpenKraut

        Re: thermonuclear FORTRAN

        > ....complete re-write in C, as it was faster.

        Good you pasted anon, because FORTRAN programmers will NEVER forgive you for that!

        More seriously, there is a substantial amount of well written and very well tested FORTAN code. Think linear algebra (but it is much more that only that).

        > That's why only computer scientists write good code ...

        Oooops, I have met computer science PhDs who did not know not a single language! ... and people with a degree along the lines "foot massage with special attention to music of the 1800's" who were excellent programmers.

        As a general rule: general rules are wrong.

        1. Someone Else Silver badge
          Coat

          Re: thermonuclear FORTRAN

          More seriously, there is a substantial amount of well written and very well tested FORTAN code. Think linear algebra (but it is much more that only that).

          Aren't linear algebra programs all written in APL?

          (/me ducks and runs for cover...)

      2. Yet Another Anonymous coward Silver badge

        Re: thermonuclear FORTRAN

        > And let's say it: Fortran is totally obsolete as a language and no computer scientist uses it.

        That's because computer "scientists" don't need to solve real problems.

        LISP is very clever, but try modeling a thermonuclear explosion with it.

        "computer science - solving yesterday's problems on tomorrow's hardware"

      3. Phil O'Sophical Silver badge

        Re: thermonuclear FORTRAN

        All of my engagements to reverse-engineer any fortran code ended up in a complete re-write in C, as it was faster.

        For you, maybe, but that just shows your lack of skills as a programmer.

        That's why only computer scientists write good code

        In my experience they write absolutely crap code.

        Sure, it's elegant, well-structed, well-commented, and may even do what it's meant to, but since computer scientists know little or nothing about the hardware, and are generally terrified they might break it, the code tends to be mind-boggling slow and inefficient. It has little error handling, since they don't know what might go wrong, and is often prone to race conditions because they have no idea what's happening in the real world of the system. Resource management is non-existent, since resources are assumed to be either infinite, or somebody else's problem (Java garbage collection, anyone?).

        A ghood programer can write fast, efficient, well-commented code without making it cryptic or unmaintainable. That can rarely be said of "computer scientists". In the real world, computing isn't a science, it's engineering.

        1. Brewster's Angle Grinder Silver badge

          Re: thermonuclear FORTRAN

          "Resource management is non-existent, since resources are assumed to be either infinite..."

          A good simplifying assumption. Which is true, to good approximation, for those of us who grew up on 8 bit micros.

          "..., or somebody else's problem (Java garbage collection, anyone?)."

          But garbage collection is annoying. Sooner or later you end up needing to performance tune a critical section of code. And suddenly you're in a whole heap of trouble without the tools you need.

    7. Anonymous Coward
      Anonymous Coward

      Re: thermonuclear FORTRAN

      Not me, but a colleague whose code I was responsible for testing. He inherited the job of porting some network driver code from one of our devices to another. This is embedded code, there is no emulator, so the only way to debug it is by using breakpoints and a serial terminal debugger.

      The code is 10,000 lines of assembler written by a guy who had long since left. It contains one comment. That comment is "SPONG!".

      He got it working. Bloody legend that bloke.

  6. This post has been deleted by its author

    1. Androgynous Cupboard Silver badge

      Always use braces isn't rhetoric, it's probably the number one rule in any coding standard worth its salt. And unecessary () aren't always bad option either. I think everyone knows the precedence of * and +, but with || and && I'd always use () for grouping.

      1. Gideon 1
        Facepalm

        Precedence Rules OK

        One of the classics in C is swapping in >> where you had a /, forgetting both the precedence and rounding rules.

    2. MarkB

      "Isn't the rhetoric 'always use {}' the same as suggesting that we do not make use of operator precedence and 'always use ()'?"

      No - why do you think it is? Not that I'm averse to additional parentheses to improve (my perception of) clarity of code.

      Bracing single statements in "if", "while" etc is an aid to readability, and (probably more importantly) gives some protection against bugs introduced by the inevitable addition of further dependent statements.

      1. This post has been deleted by its author

        1. Tom Wood

          Either always use braces, or use Python...

    3. Novex

      I always try to use the braces regardless of operator precedence, as I feel it gives anyone else looking at my code a chance to understand my intent in what I was writing, and me a chance of understanding what I was intending when I come back to the code years later...

      If anyone prefers not to use the braces and rely on precedence, then at least do us the favour of providing a comment next to the unbraced code showing the intent, either in plain language, or in the form of how the code would look if it was braced.

    4. Kubla Cant

      Always use braces

      The confusion introduced by brace-less code with misleading indentation is a staple of the Java Certification tests, and of the IKM Assessments that an increasing number of employers expect you to take. Whenever you see indented statements with no braces, it's safe to assume it's a trap.

      1. Sam Liddicott

        Re: Always use braces

        If you have to indent, then use braces.

        Asides don't need braces, and are confused by braces.

        if (...) return; // Look ma! No braces

        if (...) break;

        if (handle<0) handle=getDefaultHandle();

        if (filename && *filename) handle=open(filename);

        else handle=open(DEFAULT_FILENAME);

        The last one will no doubt make some people feel sick, particularly the if (...) clause, but there is no opportunity for misunderstanding, and it construes neatly. As a pair of lines it means "open the file", the two code paths to open the file are incidental.

        I wouldn't go as far as:

        handle=open((filename && *filename)?filename:DEFAULT_FILENAME);

        (unless I wrapped it in a macro !)

        1. Brewster's Angle Grinder Silver badge

          @Sam

          I actually find the last example clearer than the rest. It allows me to see exactly what's happening, although I'd prefer filename[0] since I presume you're checking for a zero length ASCIIZ-string.

          The rest I agree with. The one credible objection to not bracing is the problems with diffs and patches. And not-indenting solves that. But I accept the brace fascists have won the argument.

        2. Simon Harris

          Re: Always use braces

          If you're going to code like this...

          e.g. if (...) return; // Look ma! No braces

          braces can be really useful when debugging. You'll be doing something like this to return early from some function (e.g. some fault condition such as not all the required information has been set up yet). Debuggers may only track line-by-line - i.e. put a breakpoint on that line are likely to pause before the 'if'. Now, let's say you have a function that's doing...

          if ( somefault ) return FAILURE;

          ..

          if (anotherfault) return FAILURE;

          ..

          if ( yetanotherfault ) return FAILURE;

          ..

          do some stuff..

          return SUCCESS;

          (I'll assume the calling code doesn't care why it fails, just whether it does)

          You may not need the debugger to pause if you return successfully, but want to find out where it's failing:

          if ( somefault )

          {

          return FAILURE;

          }

          ..

          if (anotherfault)

          {

          return FAILURE;

          }

          ..

          if ( yetanotherfault )

          {

          return FAILURE;

          }

          ..

          do some stuff..

          return SUCCESS;

          The code itself should compile exactly the same, but now you can mark each of the 'return FAILURE' lines with a breakpoint and determine what condition is making it fail during debugging without having to single-step through all the successes too.

          Sorry - not sure how to keep the indents in a post here!

    5. Williard

      Better to make the intent explicit.

  7. Joe Bryant

    #define spel spell

    I'm pretty sure that when I dealt with Microsoft's own SNMP library, it had a header file that used #define to make up for the fact that someone at some point had named something ELAMENT instead of ELEMENT.

    1. Allonymous Coward

      Re: #define spel spell

      I see your 'ELAMENT' and raise you an 'HTTP referer'

      1. Anonymous Coward
        Anonymous Coward

        Re: #define spel spell

        I'll raise you:

        consolodated

        buisness

        These were admittedly just fieldnames. However, I work in the financial sector; I'd expect people to be able to spell "business" at least.

    2. Anonymous Coward
      Anonymous Coward

      e-Lament !!!!

      no, no ,no...

      an e-lament is the keening cry of the developer trying to manage this code !

      1. GrumpenKraut
        Coat

        Re: iLament !!!!!!!!!!!!!!!eleventyone!!

        #define iLament ExpressionOfFruityDespair

    3. Fibbles

      Re: #define spel spell

      I'm only a hobbyist programmer so at the risk if sounding like a complete fool; why aren't they just running a 'find and replace' on misspelled variable names?

      1. Joe Bryant

        Re: #define spel spell

        Probably to maintain compatibility with existing external code that expects the old, wrong spelling.

      2. Tom 13

        Re: why aren't they just running a 'find and replace'

        Well, let's take the example provided.

        If you run a find for 'spel' and replace each instance with 'spell' when you are done you will have 'spell' and 'spelll' as your new variable names.

        Yeah I know. The best way to do that find is to look for 'spell ' and replace it with 'spell '. Alternately you can do a second search and replace all instances of 'spelll' with 'spell'. BUT, do you really want to trust the sort of people who can't spell correctly in the first place to do this sort of thing?

        No, I'm not a programmer. But once upon a time I was the English major writing the instruction book for an object oriented language to be used in a proprietary control system. So you'd have commands like 'OpenAppliance' or 'IfOpen'. Hand checking the text was the only thing that really worked and spelling was my second worst subject in school (worst was always math, slight dyslexia). The two months I spent working on that was the worst year of my life.

        1. d3vy
          Trollface

          Re: why aren't they just running a 'find and replace'

          "The two months I spent working on that was the worst year of my life."

          * Worstest

          :)

          1. Anonymous Coward
            Anonymous Coward

            Re: why aren't they just running a 'find and replace'

            God, you could of used a dictionary.

            :-)

            1. Anonymous Coward
              Anonymous Coward

              Re: why aren't they just running a 'find and replace'

              God, you could of used a dictionary.

              Could have used...

      3. Anonymous Coward
        Anonymous Coward

        Re: #define spel spell

        Rule Number 1 of updating someone else's code:

        never change anything you don't absolutely have to.... least you find yourself like Alice headed down a very deep rabbit hole.

        having said that, smaller programs usually aren't a problem with find/replace.... but the larger ones, it will bite you.

        1. Anonymous Coward
          Anonymous Coward

          Re: #define spel spell

          My approach is exactly the opposite. Enter with a bulldozer and tear down and level any rubbish. If you don't, it will come back to bite your ass later - especially if that code is now your responsibility.

    4. fajensen
      Trollface

      Re: #define spel spell

      The only thing true in SNMP is the 'P* - yes, it's a Protocol, but, it's not Simple and it can't be used to Manage Networks!

      KILL it with nuclear fire.

    5. G.Y.

      Re: #define spel spell

      When Grace Hopper's people checked out COBOL compilers, they found of them insisted on using the keyword THRU. The "variant spelling" THROUGH was not accepted.

    6. druck Silver badge
      Facepalm

      Re: #define spel spell

      Quite often this is down to a foreigner thinking they know English better than you do - and I'll be first to admit that English taught to foreign students is vastly better than what us natives had in 1970s schools, but in case this it wasn't.

      We were porting Swiss Interbank Gateways code from one platform to another, the coding rules at their end specified English for all comments (understandable given the mix of German, French and Italian speakers in Switzerland), but I kept getting annoyed by a comment repeated thousands of times at every error handler

      // DESASTER
      I changed all occurrences to DISASTER and even put in the change control logs that this was the correct English spelling, but blow me if they didn't change it all straight back again.

  8. John Smith 19 Gold badge
    Unhappy

    "reputation of being somewhat of a talented programmer."

    Word that should put any competent developer on high alert.

    Along with

    "He's very fast at writing stuff" (IOW 1 character names, no comments, no indentation)

    "They're very productive" (as long as they don't have to try and re read the stuff they wrote last month)

    "He's a Mensa member" (Oh f**k. So 15 level deep If/else logic rather than a case statement. Utter sh**storm coming right at you).

    "He's very creative" See "He's a Mensa member"

    As for the comment

    "But since the 60's we've known that quality requires a code review process. "

    Indeed. They were all small sites with less than 10 developers in total. Not IBM Federal systems Division (which pioneered a lot of the stuff people should do but somehow always have a reason not to).

    I'd kind of like to have "Premature optimization is the root of most evil" tattooed on the left arm of every new programmer. One way or another most of these tools reckoned they were being more "efficient."

    I've read interviews with the original Macintosh design team who core software devs wrote the original OS in Pascal before recoding in assembler. Basically they said "First we got right, then we got it fast because that way we knew it would do what we wanted it to."

    For those "boy racer" types out there who want to code faster I have a special message for you.

    USE A SMART EDITOR OR LEARN TO F**KING TOUCH TYPE.

    Now I'm going to go out, strangle a few chickens and come back when I've calmed down.

    1. Robin

      Re: "reputation of being somewhat of a talented programmer."

      "Now I'm going to go out, strangle a few chickens and come back when I've calmed down."

      I've just choked one, so you can cross it off your list.

    2. Alien8n

      Re: "reputation of being somewhat of a talented programmer."

      There's MENSA members and there's MENSA members. See my old boss from Hell. Ironically I used to be a member of MENSA, however I prefer not to code where possible, I'm better suited to support roles. Having a logical mindset is very good for debugging code, not so good at writing it.

      However, even I know when to use CASE and not IF.

      1. Alien8n
        Big Brother

        Re: "reputation of being somewhat of a talented programmer."

        I swear someone stalks me just to down vote me...

        1. GrumpenKraut
          Meh

          Re: "reputation of being somewhat of a talented programmer."

          Upvoted for balance. Yes, in some threads many messages are downvoted by what seems to be a single individual. Strange indeed.

        2. BurnT'offering

          Re: I swear someone stalks me just to down vote me...

          I wouldn't go out of my way, but I'd hate you to feel left out

          1. magickmark
            Trollface

            Re: I swear someone stalks me just to down vote me...

            Ditto

            1. John Smith 19 Gold badge

              Re: I swear someone stalks me just to down vote me...

              Likewise

              Seem particularly frequent when I post on privacy and government snooping.

        3. werdsmith Silver badge

          Re: "reputation of being somewhat of a talented programmer."

          I swear someone stalks me just to down vote me...

          It's half term.

          Do we over-12s really care about the votey arrows?

          1. GrumpenKraut

            Re: "reputation of being somewhat of a talented programmer."

            > Do we over-12s really care about the votey arrows?

            Yes.

            Gawd, I know what's coming now...

    3. Steve Graham
      Alert

      Re: "reputation of being somewhat of a talented programmer."

      I was a (pointy-haired) manager when one of my fellow project managers owned a team where the team leader was a genius. He probably was too.

      The whole project was being coded in a language which he had invented, with everything going through a compiler/translator which he had developed and which he maintained, fixing bugs as his team discovered them.

      It was forbidden to touch the intermediate code (C, I think it was). All development had to be done in the new language.

      Things did not turn out well.

      1. GrumpenKraut

        Re: "reputation of being somewhat of a talented programmer."

        Oh dear. Exactly the same in a company I worked for. The language was neatly free of side effects. Sadly the goal of the project could be described as "just side effects, plus a few text messages". Somehow nobody ever wanted to join the team. I looked at it and ran away as fast as possible. Last I heard everything was rewritten, so no more of this computer science brain turd.

        Oh, the syntax was brilliant. As in: please die.

      2. MD Rackham

        Re: "reputation of being somewhat of a talented programmer."

        Over many years and some painful experiences, I've learned that anyone who says "we'll create a special language" needs to be fired as quickly as possible. They've revealed that their priority is not solving the problem at hand. They are absolute poison.

      3. Anonymous Coward
        Anonymous Coward

        Re: "reputation of being somewhat of a talented programmer."

        Once I worked in a company where a team was so smart they thought they needed to code any new project in a newer language/technology than the previous one, because they were of course better and improved. Just they never spend enough time to really learn how to use all that new stuff.

        They were really smart, because as soon as things never went the right way, they found a way to pass the project onto someone other to start a newer one, or left the team/company (sometimes just for a while).

  9. itzman

    All code should be rewritten from scratch...

    ...at least 3 times.

    Because until you have written it twice, you don't actually know the best way to write it.

    Byte time I am on iteration 3, all the bits that belong in subroutines, are, not because they are called twice, but because they are details in a larger picture which I want the main code to represent. And all the run time errors that happened whilst developing that show up as segfaults where a particular unanticipated condition has in fact occurred, are now catered for by extra error handling again put in its own file generally.

    Version one is hacked till it works - some of the time.

    Version two works, nearly all the time, but is messy ugly spaghetti code.

    Version three works all the times so far, and is somewhat neat structured and well commented so that even I will understand it when I need to look at it in a years time.

    Some people think that careful planning will get you there first time. I disagree.

    Careful planning only deals with the contingencies you thought of, not the ones you didn't and careful planning beyond a certain point takes longer than hacking it till it works, and going through the alpha beta release cycles

    1. Roger Greenwood

      Re: All code should be rewritten from scratch...

      Well said. As Mr Brooks says :- "plan to throw one away, you will anyway"

    2. nijam Silver badge

      Re: All code should be rewritten from scratch...

      > They say starting again from scratch is a terrible idea...

      They say lots of things. Making a 50-tooth cog wheel shouldn't be done by starting with a 49-tooth wheel and adding an extra one somewhere.

      1. BurnT'offering

        Re: Making a 50-tooth cog wheel

        Tell that to British Leyland

      2. GrumpenKraut
        Happy

        Re: All code should be rewritten from scratch...

        > Making a 50-tooth cog wheel shouldn't be done by starting with a 49-tooth wheel and adding an extra one somewhere.

        Why does that make think of Adobe Flash?

      3. Anonymous Coward
        Anonymous Coward

        Re: All code should be rewritten from scratch...

        You should combine it with a 98 tooth wheel and a 100 tooth wheel on a common shaft, thus creating unnecessary complexity.

        1. Anonymous Coward
          Anonymous Coward

          Re: All code should be rewritten from scratch...

          "You should combine it with a 98 tooth wheel and a 100 tooth wheel on a common shaft, thus creating unnecessary complexity."

          All tonewheel Hammond organs can provide the necessary parts, even on a common shaft since they all run in pairs...

      4. Phil O'Sophical Silver badge
        Coat

        Re: All code should be rewritten from scratch...

        Making a 50-tooth cog wheel shouldn't be done by starting with a 49-tooth wheel and adding an extra one somewhere.

        That would be silly, there's nowhere to put it.

        Much easier to start with a 51-tooth wheel and file one off.

    3. magickmark

      Re: All code should be rewritten from scratch...

      I agree with what you say! Not quite the same thing, but it did involve coding.

      There is one case I always recall from when I was an independent database developer. Most of my clients were small local businesses, mostly 10 or less employees i.e, not loads of cash to throw around. One day I was contacted by a new potential client in the insurance industry asking me to a meeting to discuss their needs.

      So halfway through the meeting having had some discussion with the owner and staff of the company the owner excused himself for a minute to get something. He came back a few minutes later with a HUGH stack of A4 paper and dropped it on the table with a very loud THUD (it was a very big stack). And said "That fucking lot cost me £3000" pointing at the stack.

      I looked through it and it was a needs analysis/system specification that detailed every aspect of a proposed database. So detailed in fact I assumed that the only way they could have produced it was by actually by building the thing or, if not, the amount of work they had put in was equivalent.

      The told me at that point he had pulled out of the project because he could not afford to pay £3000 for a "pile of paper". I think he was worried that I would do the same thing to him.

      I had to assured him that was not the way I worked, sure I had to do analysis and design but that I'd build him working prototypes and then working with him and his team would refine and expand the functionality to get a system that would do what they needed it to do.

      To cut a long story short, it ended up with me working off and on with them for getting on for 10 years and producing a product that suited their needs totally, In fact at one time when they were being audited by their underwriters (just a routine audit I hasten to add) the auditor said it was one of the best underwriting systems he had ever seen, I was always very proud of that.

      So my point is that you can plan and design to the n'th degree but at some point you have to roll up your sleeves and dive in and produce something and then refine and develop until it does what it's meant to.

    4. d3vy

      Re: All code should be rewritten from scratch...

      "All code should be rewritten from scratch...

      ...at least 3 times."

      Sounds a lot like the Red Green Refactor cycle of TDD.

      Or the more common Red, Green, Refactor, Red, Red, Red, fuck it disable the tests. Cycle. :)

    5. FatGerman

      Re: All code should be rewritten from scratch...

      I agree but I'd go with 4 times.

      Version 1 is bodged together with gaffer tape until I've figured out what the client actually wants it to do.

      Version 2 is your version 1...

      Some people would call my Version 1 the "requirements spec" but I usually find that people are much more enthusiastic about providing input if you actually give them something to play with and ask them to tell you why it's shit.

    6. Tom 13

      Re: Some people think that careful planning

      You're right, careful planning won't get you there the first time. But without it, you'll have trouble making it there in merely 3 iterations. As to the point about covering only the contingencies you've thought of, that's where having at least one old fart on the project is usually helpful. He's run into many of those contingencies you didn't think of, and since he now bears the scars of having done so they're on his permanent checklist.

      Not a programmer, but I have been the old fart doing the meeting planning with a plethora of young guns chomping at the bit to do something differently because it has to work better than what we're doing. Except that was the first thing we tried and it didn't work.

      I left in disgust some years ago. While I was there we paid someone to write custom software for our registration/sales table/art show activities. ALL of our data was kept on the local server. As in, two weeks before the big meeting, the data on the web servers was copied to CD/DVD then copied onto the show server. It was the only time I've ever seen three drives set up as a mirror and spare and I was the guy who did it because it made sense for our particular needs (3 day meeting over the weekend, no way to get replacements while at meeting). The Young guns pronounced it stupid and replaced it with a cloudy system because that's what EVERYBODY is doing these days. First day of the show, there was no internet for their system. Second day of the show they were trying to run over some phone generated wifi hot spots. Reg line never didn't clear until Sunday. For some reason, they never saw that coming. Oh, and yeah, when I was doing it the head of reg had two sets of very, very thick books. Yep, they insisted on a printout of every registration just in case the computers went down. Smart woman. Then again, two years into her new job she went to the safe to pull out the 10 year old floppy disk with critical data on it only to discover the floppy had demagnetized.

    7. Charlie Clark Silver badge

      Re: All code should be rewritten from scratch...

      No need to rewrite everything from scratch: add tests. Good tests go a good way to making up for a bad briefing, lack of time, etc.

    8. Andrew Moore

      Re: All code should be rewritten from scratch...

      until you get good at coding- then you can get away with writing it 1.5 times.

  10. Stoneshop
    Mushroom

    "and give him a piece of my mind"

    Sorry, no. Or rather, hell no. My mind is mine, and it's not yours to think with*.

    And yes, I had someone expelled from the place where I was contracting for trying to use my mind for doing her thinking.

    * yes, I know what the expression is meant to convey.

  11. MJI Silver badge

    I am allergic to VB6

    I cannot touch the stuff, I have had to help maintain some and I detest it.

    I try to neatly line up = when assigning variables and it removes the white space.

    Used an external editor, it broke my code again.

    The only module I had to write has EVERY VARIABLE NAME the same length in characters.

    There is a special place in hell for IDE writers like that.

    1. Anonymous Coward
      Anonymous Coward

      Re: I am allergic to VB6

      Years ago, when having to deal with MS VB, I never understood wtf was ON ERROR ... RESUME stuff was all about.

      1. Stoneshop
        Windows

        Re: I am allergic to VB6

        I never understood wtf was ON ERROR ... RESUME stuff was all about.

        It was meant as a message for the maintainers: ON ERROR UPDATE RESUME, but MS found they lost too many programmers that way.

  12. Anonymous Coward
    Anonymous Coward

    i noticed the phrase vb.net near the top of that article.

    So is VB one of the allowed languages in this multi blah blah dotnet thing i keep seeing well paid jobs for?

    1. Dan Wilkie

      I'm no expert (seriously, I last wrote with VB5 in College, and am only just starting over with C#) - but .net is a framework. When they say ".net developers" they usually want C# from what I've seen. Hence the starting over with bit...

      From what I understand, it's basically an execution environment, which I think is a bit like the Java VM, and a collection of classes and libraries. If someone wants to correct me I'd appreciate it.

      1. Alien8n

        I'd say that's reasonably close. I run DNN which is a .net portal and over the years I've seen modules for DNN that were written in C# and some written in VB. The only thing each version of DNN had in common (until DNN6 iirc) was the same bug concerning null point errors as the code would check the cache for data, go off and do something and then read the cache again by which time the cache had cleared and resulted in the error. To my mind this was sloppy coding as the cache should have been read to a variable and then the variable called which would get around the cache clearing issue on slower servers. The C# code looked to be better written as I don't recall the same bug in those modules.

  13. Ifordh

    Really a GIT

    Having the .git folder deleted by another developer and then a couple of weeks later being asked where I kept the different versions of the code, I had left the project by then, after a handover.

    1. Paul Crawford Silver badge

      Re: Really a GIT

      Where was the GIT repository, as surely you did not have just one copy?

      And the machine's backups?

  14. Anonymous Coward
    Anonymous Coward

    The first real code eye opener I had was early on in my contracting career. We were working on a well known media celeb vanity project, and I was brought in to do some html/webby stuff back in the days before smarty and widely deployed css to get a new project and domain under the master brand up and done as it was in danger of hitting the rocks. Before that I had a tiny little web design shop cum minutest funded isp where I had learned my craft for a few small sme's websites and stuff before freeserve crushed that market, so I was nervous the first day there, but I knew the guy brought in to troubleshoot the whole project and he knew what I could do technically so assured me I'd be fine.

    Week 1 I had my dev environment set up on a crappy old laptop, reformatted with linux running php etc, and templated the whole site I was working on with a little php template engine I'd done for the sme's, testing on the local apache server, running it through bobby and other validation tools and hand editing it all with vi in screen sessions, slicing up images to stretch 1 pixel wide images with img tags into bar decoration to cut load times down in the modem speed era and lots of other little tweaks, so I could just change a few things in my includes and bingo, everything changed style or font or whatever on a whim and it coped with resized screens etc, then because we didn't have php or perl in the live server, I sucked off a static archive of the whole dev site to flat html using wget in a one liner and checked it into the company cvs with comments as a release in the same script. I was working with some truly talented graphic artists and UI layout people and it was a pleasure to see how much better they were at visual stuff than clunky coder graphics/work that I had been responsible for. They didn't have much clue about image sizes and its effect on load times but one japanese girl quickly grasped it and turned out to be brilliant at mocking up the pages as one image like she had been used to then slicing things up very quickly indeed. I hope she's working somewhere in the industry still for vast sums, she was that good.

    Having got ahead by delivering weeks early to everyones complete shock, I was called over to work on the main site alongside the experienced html guru, who turned out to not know html. He was morrocan or something and wore thick jumpers in the middle of summer and had a habit of avoiding showers. I think he had cats too, since he stank of cat pee to put it bluntly. Everyone told me he was a ninja of html, they never saw him work, then suddenly, bang something was finished. I suspect he used his aroma so nobody wanted to be near him in the office or come close enough to see his screen to see his workflow. But he was the established god and would be checking my work. Ok, bring it on, always up for being measured.

    I'd always wondered why the site was massively slow and still frame set based in the era of tables and layout, and I found out why when I was asked to help debug some of the site during this phase. He used netscape editor (remember that!) to make the pages and his titles etc were all *drawn* in photoshop and served as one giant png with seperate images to replace the ENTIRE screen with that button lit, swapped in as a mouseover. We're talking 100Mb's of graphics on the homepage here in dial up 56k era being slowly jammed into a massive cache. Then I looked at the mess of code he had in the cvs repo and it was such a utter clusterfuck I didnt even think debugging it was possible. But... at a meeting I asked why he wasnt using any mark up to lay the different pieces out so he could just change one tiny image during a mouseover event, and he broke down and admitted he didn't know how to do html or tables, and his version of netscape editor coudlnt make them, so thats all we were getting.

    After that I was saved by the client wanting a bit more development for a database backend on the subsite which I already had all the code to do tucked away from my sme stuff in a nice template with defanging on bad chars etc. He wanted me off the main project too, so quickly allocated it and off I went, suited me, happy days.

    Not sure if they just felt sorry for ninjadev's circumstances or were just as clueless but once my updates were done decided it was time for me to move on rather than battle against the window pane of desolation like a bluebottle with its legs pulled off while wondering exactly how inept you had to be to get finished in the brave new world of a dotcom. And at that point I was the little fish in a big sea and he was the expert. 15 years later in the industry thats still not a unknown feeling...

    1. Anonymous Coward
      Happy

      You wrote: "I sucked off a static archive"

      F'narr! F'narr!

  15. Alan J. Wylie

    "Lesson: Don't pluck values out of the air ...

    ... and give them special powers – or your days, like your magic constants, could be numbered.

    From the bug report for the current glibc getaddrinfo vulnerability:

    https://sourceware.org/ml/libc-alpha/2016-02/msg00416.html

    "The use of MAXPACKET is a value/boolean-style check. The send_dg internal logic uses a value of *anssizp of MAXPACKET to indicate an internal buffer was allocated for the response. It does not contemplate a user might pass in a buffer that big, but let us ignore that for now."

  16. 404

    I hate code...

    ... I hate the people writing it, I hate having to fix it... which I do all_the_fucking_time.

    I liked doing programming at one time - until that fateful day the main programmer moved on. This programmer was responsible for porting Netsol's Unix registrar code to our ISP's Windows 2000 AD network, a biggish deal since everything has to be perfect. This guy made performance bonus's and a fucking big payoff when the software was 'finished', then he quit and moved on across the country. Week later the big launch comes and it_failed_horribly. Enter me, the senior admin who just recently upgraded the ISP's network from NT 4.01 to Win2k AD with Solaris x86 DNS servers, and I'm the guy they're pointing fingers at. I didn't know shit about what the 'programmer' was doing, I'm not sales or head of the programmer/webdesign department, How_the_fuck_am_I_responsible? I caught so much shit... and the motherfucker didn't document shit. Ended up coding that POS essentially by gunpoint, no bonus, from scratch. I giggled when that registrar (and the ISP) folded a few years later...

    I have hated programmers since that point in my life. I'll admit they are useful at times, but overall they did shit code.

  17. Anonymous Coward
    Anonymous Coward

    Clearly cant code

    spell checkers.

    Left to my own DEVICES...

    FFS....

    Do I smell American?

  18. Anonymous Coward
    Anonymous Coward

    IBM 1130

    IIRC, I found a Fortran programming book at home, that belonged to my Mom. And she had access to the College mainframe, through an IBM 1130 at the time. A few punched cards fell from it, that were neatly stored on a stapled envelope on the back of the book. I'm not sure if it ran by itself, of plugged to another computer.

    I bet that the code would run smoothly even today, provided any IBM 1130 was still operational and attached to a mainframe. The cards were yellowed, but were perfectly fine, the holes perfectly aligned to the card.

    My DOS floppy disks were not even close to that state of preservation.

    1. Mike 16

      Re: IBM 1130

      -- provided any IBM 1130 was still operational and attached to a mainframe. --

      There was a perfectly cromulent Fortran compiler for the 1130 (descended, IIRC, from the 1401 version), so it's entirely possible that code ran on the 1130 itself. There are several still working 1130s around these days, BTW

      1. Phil O'Sophical Silver badge

        Re: IBM 1130

        There are several still working 1130s around these days, BTW

        http://www.tnmoc.org/news/current-projects/ibm-1130-system-restoration-during-2011

  19. OzBob

    I have just been tasked to reverse engineer some shell scripts

    for a customer, which, when I looked at the comments, was old enough to vote. (+20 years)

    And when I scrolled through the code, I saw the interface script was called a terminal program with modem commands, as the interweb wasn't big back in 1996 at this customer. (Ever tried googling "term commands" and trying to get meaningful help?) Fortunately that part of the script was disabled.

    Only last week I was on another customer site trying to determine on a redhat system why the rotated compressed messages logs only had 15 or so lines in them. Turns out one of the sysadmins decided to write a script to cycle, compress and archive the messages files at 1:45 in the morning. I send him a curt email with "man logrotate" and "cat /etc/cron.daily/logrotate" and a reminder to let the OS do it's own maintenance rather than re-inventing the wheel.

    1. Down not across

      Re: I have just been tasked to reverse engineer some shell scripts

      Only last week I was on another customer site trying to determine on a redhat system why the rotated compressed messages logs only had 15 or so lines in them. Turns out one of the sysadmins decided to write a script to cycle, compress and archive the messages files at 1:45 in the morning. I send him a curt email with "man logrotate" and "cat /etc/cron.daily/logrotate" and a reminder to let the OS do it's own maintenance rather than re-inventing the wheel.

      Whilst I do agree with your comment, I'd like to point out that on a site with heterogenous environment with many vendors' UNIX variants, it would be quite understandable there to be a common logrotation script that works on all environments instead of relying vendor specific solution(s). And no, your post did not indicate that site to be one, just wanted to point out potential exception.

  20. Mike 16

    Hugarian, code-reviews, and Real Programmers

    Sort of an omnibus comment.

    1) Time to (re-?)read Joel Spolsky's excellent essay on "making wrong code look wrong"

    http://www.joelonsoftware.com/articles/Wrong.html

    In a nutshell, the original "Hungarian" notation was actually quite useful, specifying the type (in the plain English sense of the word) of a variable, that is, was a particular coordinate pair in world or screen space. It was perverted by people who thought "type" as in the C.S. sense, something about the size and format of a variable, nothing to do with semantics.

    2) Code reviews can be a great thing. Or they can be (usually are) an occasion to air petty grievances, show off the reviewer's vast knowledge of arcane language points, and endlessly bikeshed things like brace style and variable name (local ones, even).

    3) My "favorite" example of "lost in translation" was when I was tracing a "hardware error" on a PC motherboard used in an embedded system. The buggy 8086 code (to initialize a device) was traceable in part to some magic values computed by a C program that had obviously been translated from BASIC to C by someone not too familiar with either. We fixed our BIOS, but I did notice that a fairly high volume consumer desktop by a famous manufacturer had the same issue, so even though I reported the error to the chip vendor, apparently the major BIOS vendor didn't bother to fix it.

    In short, giving a damn is half the battle.

  21. Sam Adams the Dog

    As in all else, Orwell is correct.

    Fortran 90 and successors are actually reasonable languages. Fortran 77 and earlier didn't even have dynamic allocation. One of my more interesting projects was converting a multi-hundred-thousand-line Fortran 77 program to Fortran 90. Because allocation was static, (1) There were many places in the program where a given array could be first filled; and (2) It made use of "work arrays", which were utility arrays that were equivalenced (Fortran programmers know that word!) to different arrays of different types, depending the current input. Even when a single array was used for a single purpose throughout the code, depending upon the work flow, it might be first filled in any of a number of places. So it was a challenge to know when and how to allocate it. Fortunately, I already knew the program pretty well, but I have to say that by the end, I knew it much better. The program is still widely respected and in general academic and commercial use, and his been greatly advanced since I worked on it in the '90s.

    1. GrumpenKraut

      Re: As in all else, Orwell is correct.

      > ...multi-hundred-thousand-line Fortran 77 program...

      Gasp! And then, you (A) bought a nice house, or (B) spent several years in the loony bin, or (C) ???.

  22. Frozit

    20 20 hindsight is always best

    I am amused. The original article referenced programmers who clearly were broken. However, picking on academic fortran, and other code that was written LONG before today's Software Engineering standards were created, and the glorious hardware that we have that allows effectively infinite memory space is quite amusing.

    And most academic programmers are self taught. No one teaches software engineering 101 to Physicists. Even though most of their work is simulations...

    1. GrumpenKraut

      Re: 20 20 hindsight is always best

      Physicists now do learn programming (here in GrumpenLand), at least where I checked the courses offered. The quality of such courses varies quite a bit.

      When a student, I took a C course where the teacher tried for many hours to explain what a pointer is. He failed miserably because he didn't understand it himself. I did tell a fellow student that I failed to understand that darn complicated pointer stuff. He replied "but you know assembler, it's just a bloody adress". That very second I got it.

  23. Alistair
    Windows

    I've been doing this too long.

    Looking at a korn shell script written 11 years ago that chugs through several *thousand* job logs a day looking for a specific combination of oracle errors. I'm horrified at the horrible ...........

    God DAMMIT. I wrote this crap.

  24. tiggity Silver badge

    code review

    They can be useful but...

    What constitutes readable code / best practice is all so subjective.

    e.g. C#, some people love the null coalescing operator, conditional operator etc. whereas others like more verbose alternatives that are potentially more readable to people less familiar with obscure areas of a particular language

    .. and don't even get involved in disputes regarding at what point do linq and lambda expression heavy areas of code transition from clarity to WTF.

  25. chic

    You'll throw one away . . .

    Re the Fred Brookes comment, I once bought my then boss a copy of 'The Mythical Man Month'

    In fact I bought him three copies so that he could understand it quicker . . .

POST COMMENT House rules

Not a member of The Register? Create a new account here.

  • Enter your comment

  • Add an icon

Anonymous cowards cannot choose their icon