Live data from Hacker News

The worst program I ever worked on

jacquesmattheij.com

121–130 of 136 posts

Re: The worst program I ever worked on

#121
post #41

I met the guy who wrote this bit that I had to maintain: for(a=0;a What really pissed me off was that he was such a nice guy. He still works a lot. Makes a lot of money. And his customers love him. (No, I don't think they review his code.)

Unless there is a lot of creative abuse of operator overloading or macros lurking in there that code really doesn't look too awful compared to some monstrosities I've had to work with.

Hm, did you check that each loop worked with its own loop variable? If not, how do you _know_ it does what you think it does?

If you code like this, you will have to be paranoid with each line you read. That is what makes such code bad, even if it does what it appears to do at first sight.

Re: The worst program I ever worked on

#122
post #86

You really don't know bad programming until you have spent some time in a 50000 line cobol program. I'd post some crap I work on every day but I don't want to make anyone cry. Nevermind. Here's some random code I'm working on. MOVE SPACES TO LISTBAT-NAME. STRING WORK-FILES "LIST.BAT" DELIMITED BY " " INTO LISTBAT-NAME. OPEN OUTPUT LISTBAT. MOVE SPACES TO SCR-S. STRING "DIR /B " DATA-PREFIX " > " WORK-FILES "TMPLIST"…

Note to self: do not learn COBOL.

That's funny, because I look at that and think it's too bad I don't know anything about COBOL. It's not like I'm planning to learn it or anything, but it's quite different from anything I've ever worked with.

So, questions: I know I'll never program in COBOL. But I'm interested in programming languages in general. How much of a "quick intro" would be worth digesting just for the purpose of contrasting to C, VBA, Lisp, etc.? Is there a good one to look at?

Re: The worst program I ever worked on

#123
Oh you wanna try doing code golf, after a little while it warps your thinking and this sort of thing starts looking reasonable :)

using C=System.Console;class S{static int p,v,x,y,t=10;static void D(char c='@'){C.SetCursorPosition(p%t,p/t);C.Write(c);}static void Main(){var s="";for(;v0).Key-37];D(' ');p=s[v]==' '?v:p;}}}

Re: The worst program I ever worked on

#124
post #39

I worked on a piece of code that literally drove the guy who wrote it round the bend. He had a mental breakdown, ran away, and eventually ended up in a different state ~3000 miles away. It wasn't so bad. Now debugging code written by Chemistry Students ... that's some scary stuff right there. Which is not to go all elitist and put Comp Sci degrees up on a pedestal, one of the better coders I've had the pleasure of wo…

You should try working with code written by hardware engineers. Those guys are extremely smart when it comes to digital and analog electronics, but never ever let them write a device driver ...

I had the interesting experience of maintaining a device driver written by a hardware engineer, for a servo motor. There was no reason for it to be in assembly language, but it was. No comments, either. Very bright guy, but he'd just never absorbed much common sense about coding up maintainable software.

I think the thing here is that, for the most part, hardware guys don't want to write software, so they don't bother to learn how to do it right. This usually comes back to bite them in the ass, when they end up needing to write some code anyway.

Re: The worst program I ever worked on

#125
post #123

Oh you wanna try doing code golf, after a little while it warps your thinking and this sort of thing starts looking reasonable :) using C=System.Console;class S{static int p,v,x,y,t=10;static void D(char c='@'){C.SetCursorPosition(p%t,p/t);C.Write(c);}static void Main(){var s="";for(;v 0).Key-37];D(' ');p=s[v]==' '?v:p;}}}

That's from here btw https://github.com/nrkn/SimpleRLGolf

Re: The worst program I ever worked on

#126

Earlier quoted context omitted.

#define HEREWEGO { #define ENOUGHNOW }

Well we are diverging from the theme, but the proper form of that is #define O_HAI { #define KTHXBYE }

You can even go a little further and use trigraphs, which is one of those ancient features that most people have forgotten because it doesn't make much sense anymore. ?? are equivalent to { and } in C, which could be handy for further obfuscation.

http://en.wikipedia.org/wiki/Digraphs_and_trigraphs

Re: The worst program I ever worked on

#127
post #41

I met the guy who wrote this bit that I had to maintain: for(a=0;a What really pissed me off was that he was such a nice guy. He still works a lot. Makes a lot of money. And his customers love him. (No, I don't think they review his code.)

Did you ever ask this person why he wrote this code in this manner? Did he trot out the "job security" crap or was there a legit reason?

I met someone once who called every variable X. Yes really. The compiler was somehow just supposed to figure out that X on this line and X on that line were different things... What is baffling is that he did have code that worked, kinda.

Re: The worst program I ever worked on

#128
post #70

A project I worked at during an internship had an unmanaged C++ portion for rendering complex typography, which was written when every letter in a variable cost $10 (or so it seems). The result was that "pointer to a metadata character" became the variable "pmc", and that was just the beginning of it. I never quite did understand what the variable lpmnoics meant, and debugging the C++ was quite the drag and the task…

That sort of thing is a lot easier to understand if you have the secret decoder key: http://www.joelonsoftware.com/articles/Wrong.html But it's probably a defensible idea, in context. The idea is to supplement the type system of a low-level language with a manually-checked type system that helps you find semantic errors.

You're right, eventually I did get the hang of the chunk of code and wasn't afraid of it. Lots of others in the team were however. Also, because of eXtreme Programming and pairing, I knew the C# and what it was doing in 2 weeks and was writing code, having never seen C# before. I had some C++ experience, but by the end of my 6 month internship wasn't comfortable with the "views code". Yes, it was high performance code that did black magic, but making it readable is halfway to being able to understand it. It worked and it was fast enough and did good stuff (ever try doing a vertical unicode editing view?).

Re: The worst program I ever worked on

#129
post #122
post #86

Earlier quoted context omitted.

Note to self: do not learn COBOL.

That's funny, because I look at that and think it's too bad I don't know anything about COBOL. It's not like I'm planning to learn it or anything, but it's quite different from anything I've ever worked with. So, questions: I know I'll never program in COBOL. But I'm interested in programming languages in general. How much of a "quick intro" would be worth digesting just for the purpose of contrasting to C, VBA, Lisp…

I'm interning with a company that is a COBOL shop. It took me months to make the transition from "normal languages". I don't think it's worth learning honestly unless you get a job in it. Here are some things it has taught me.

It's taught me to create pretty code that is indented correctly. I pretty much live in a debugger. Most people out of a CS program think they know how to debug stuff. They don't have a clue. It's taught me to be very meticulous and review every single thing I do down to periods(which BTW terminate loops and if statements making life hell) If you can't understand what you just wrote it needs rewritten.

As far as language comparisons. All variables are declared at the top of the program. All variables are fully global. If you move a variable to a smaller variable it doesn't throw an error it just gets truncated. Loops start at 1 instead of 0. There is very limited error handling.

I don't know of any resources online. I searched when I started working but I didn't find anything real helpful. I did have a 25 year old 30 million line code base to learn from though

Re: The worst program I ever worked on

#130

Earlier quoted context omitted.

I was under the impression that serif fonts were best left to headlines that are supposed to catch your attention, and that body text should always be a serif font - and that Arial is one of the better serif fonts if you use set the size to at least 14px and line-height to 150%.

You are missing the word "sans" from that comment. The general opinion used to be that serif was better for bodytext, and sans for title, and Arial is sans serif, but not one of the better ones.

Yeah, I meant sans serif for body text :)
Post reply on HN