Lurker News
I think I've broken my own record with this one ~2500 lines of incoherent JavaScript/C#. Works though.

Comments (578) 119 threads

Earlier comments
jancsika#
If you search youtube for something like "pure data dance music" you'll find some excellent spaghetti diagrams that produce music/video.

Since the environment provides realtime feedback, it's a drag to try to refactor the current diagram into a reusable abstraction. Instead, many users optimize their creative time and just keep adding functionality to the diagram in a single graphical window. By the time they are done there is text overlapping other text and a bunch of lines obscuring most of the diagram.
Even with the ones that have a simple set of controls for a sequencer or whatever, there is usually a "guts" module that hides all the spaghetti.
Also, for any running program you can instantly make it twice as spaghetti by doing "select all" and "duplicate." :)

jtolmar1 reply#
All code is bad and Google puts almost everything in one repository, so I'm going to say that ;-).

For more traditionally defined bad code, I worked with a team that rewrote an existing service from scratch using with 40000 lines of spaghetti. The service that it replaced was 80000 lines, and was replaced despite working perfectly fine because it was a total clusterfuck with dependencies interwoven across every service anyone had ever heard of. This was a payments system for a major online retailer. All of this code has been removed since.
I also used to participate in Java4k, a competition to make games fit in 4 kilobyte jar files. Writing almost everything inside a while loop in a single function is basically table stakes for that.

geezerjay#
> I worked with a team that rewrote an existing service from scratch using with 40000 lines of spaghetti. The service that it replaced was 80000 lines, and was replaced despite working perfectly fine because it was a total clusterfuck with dependencies interwoven across every service anyone had ever heard of.

Your post should be at the top of the thread. Rewriting projects from scratch tend to do more harm than good, and the only reason this problem isn't addressed very often os that the people invested in reinventing the wheel don't admit to having caused more problems than they solved, and the ones who developed the old systems have moved on and thus are unable to say anything in their defense.

ryanmarsh1 reply#
Any large company. I’m being serious. As a development coach I see a lot of code and I must say the DEFAULT is “how does any of this even work?”
TideAd1 reply#
I've been working on fixing some old C++ code at my company so that it compiles with the most recent version of the compiler. To my surprise, the errors that the new compiler gives me are very reasonable. But I always ask myself, "how on earth did this ever compile in the first place?"

The crazy part is going into the commit logs and seeing that a lot of the people who wrote this have been very successful. They've become vice presidents, retired rich, and written influential papers.

flukus#
I've been doing the same, porting (getting to compile and seemingly run) an old c and c++ codebase from 32bit solaris to 64bit linux. For a while I was spending my days alternating between "how did this ever compile" and "how did this ever run" when debugging. It took a lot of modifications to get it to compile on a now 6 year old version of GCC, then I got to debug a lot of issues with type sizes, endianess and posix differences. The team responsible for it is still in favor of keeping it 32bit unfortunately, so we can't even do a desperately needed valgrind run. I wish I could look at the history but I don't have access to the clear case repository I think they're still using.

We've got another codebase of similar vintage that is preventing us from deploying spectre patches...

baron8162 replies#
I’d like to hear people describe why the code they’ve seen is bad.
mikekchar#
In my experience (despite what you might imagine) the biggest factor has been lack of experience for the developers. You can get some pretty weird ideas when you first start out. Those weird ideas can gain traction in a group and then it becomes "the way" to do it. Over time, the system gains cruft and there is no practical way of addressing the problems. It takes really experienced people who specialise in legacy code to systematically improve large systems -- and it takes a donkey's age. It's just not a sustainable enterprise.

We tend to think that harsh deadlines and unthinking managers are to blame, but writing good code over the long term is incredibly difficult. Group dynamics are hard to deal with and as you add (or replace) people on the team, you are bound to eventually go off the rails even if you started off well. Which is not to say that you shouldn't try, but our industry is really immature. Most developers are quite young and even when you have a couple of older people on the team, they may or may not have the skills for long term design evolution. Maybe 50 years from now it will be the norm to write good code, but I think we'll still be writing legacy messes for a while.
I should point out that even the worst code I've seen written this decade is at least an order of magnitude better than the average code I saw when I started my career. As an industry we are improving!

natalyarostova#
The core tech lead on our team switched projects, new engineers were assigned to our projects and given tight deadlines, as well as being responsible for giving each other CRs. Our once well maintained code base began to fall apart, and I realized keeping it clean wasn't worth burning myself out. This is also my first real job working on/with software, so I suppose this is normal?

Load more comments