Live data from Hacker News

Ask HN: What's the largest amount of bad code you have ever seen work?

news.ycombinator.com

271–280 of 601 posts

Re: Ask HN: What's the largest amount of bad code you have ever seen work?

#271
post #10

Years ago as an intern at Microsoft, I had code go into the Excel, PowerPoint, Word, Outlook, and shared Office code. Excel is an incomprehensible maze of #defines and macros, PowerPoint is a Golden Temple of overly-object-oriented insanity, and Word is just so old and brittle you'd expect it to turn to dust by committing. There are "don't touch this!"-like messages left near the main loop _since roughly 1990_. I had…

Reminds me of this beautiful rant

http://blog.zorinaq.com/i-contribute-to-the-windows-kernel-w...

Re: Ask HN: What's the largest amount of bad code you have ever seen work?

#272
post #18

Oracle Database 12.2. It is close to 25 million lines of C code. What an unimaginable horror! You can't change a single line of code in the product without breaking 1000s of existing tests. Generations of programmers have worked on that code under difficult deadlines and filled the code with all kinds of crap. Very complex pieces of logic, memory management, context switching, etc. are all held together with thousand…

That is absolutely insane. I can't even begin to imagine the complexity of that codebase. I thought my Rails test suite was slow because it takes 4 minutes. If I wrote it in C or C++ it would probably be 10 seconds. I can't imagine a C/C++ application where the test suite takes 20-30 hours on a test farm with 100-200 servers. And if you can break 100-1000 tests with a single change, it doesn't like things are very mo…

Hell for the proactive go-getters, but paradise for people who enjoy any excuse for a bit of justifiable down time!

Q: Are you busy? A: Yes, in the middle of running tests...

Re: Ask HN: What's the largest amount of bad code you have ever seen work?

#273

I used to own a C++ application that was a morass of abstractions and indirections so it was impossible to reason about. It took a number of hours to compile. On one infamous occasion we were making a, relatively small, patch release. The debug version worked fine but the release version crashed systematically. Even when we backed out all the changes we had the same behaviour. We were screwed. Until one of the team h…

> Apparently, we had deleted more code than all the other teams combined had added in the previous measurement period. This caused their metric calculation to barf. Their solution? We should add all the code back in!

ah yes, when bad metrics become targets

Re: Ask HN: What's the largest amount of bad code you have ever seen work?

#274
post #168

I am maintaining one application in construction industry space. That application was created 25 years ago by construction worker that never wrote single line of code before, but because he caused a lot of problems on construction site they give him Programming 101 book and let him build it. 15 years later the app was close to half milion lines long of huge bowl of spaghetti code. Only comments in whole codebase were…

I have to salute this construction worker for building a solution that is apparently so valuable for the business that they can’t simply replace or rewrite it. This probably means that it solves a real problem for them, and adding 30.000 lines of code per year without any formal training or much tooling is no small feat either. I understand the criticisms and laughs here from the “real” software developers, but damn…

This.

A spaghetti monster which solves a real business problem can be improved, chunked into pieces, gradually rewritten, whatever improves maintenance. If need be, there will be funds and time for doing so.

By contract, an impeccably architectured, layered, no-design-patterns-omitted, product which solves no business problem .. oh, the horror.

Re: Ask HN: What's the largest amount of bad code you have ever seen work?

#275
post #234

We have absolutely no idea how to write code. I always wonder if it's like this for other branches of engineering too? I wonder if engineers who designed my elevator or airplane had "ok it's very surprising that it's working, let's not touch this" moments. Or chemical engineers synthesize medicines in way nobody but a rockstar guru understands but everyone changes all the time. I wonder if my cellphone is made by mac…

It's like that in other fields of engineering too, when they are making something they haven't built before . That's the essential part: for example, a lot of construction is really just rebuilding the same thing that's already been built 100,000 times in the past 100 years. When they attempt to build something new, it often ends up like software – tremendous overruns in both cost and schedule. C.f. the only new nucl…

> It's like that in other fields of engineering too, when they are making something they haven't built before.

Exactly this. I like to use an analogy of building bridges :)

  - OK, we have this valley and we want to drive cars over it. What do we 
    do?
  
  - Hmm, we could just make the road along the bottom of the valley
  
  - Wouldn't that cause the cars to fall because of the steep angle?
  
  - Good point. Maybe if we built the road with a lot of twist and turns
  
  - Then it's a slow and long drive.
  
  - Maybe we could build some sort of catapult setup to throw the cars
    across the valley
  
  - That would make safety a concern though. Is there a way we could use
    helicopter rotors to suspend a road in mid air over the valley?
  
  - Or what if we attach the road to each side of the valley and make a 
    road that's strong enough to not crack in the middle under its own weight?
  
  - Yeah, that sounds like a good idea. How do we make sure it can hold its
    own weight, though?
  
  - .....etc

Re: Ask HN: What's the largest amount of bad code you have ever seen work?

#276
I never actually saw the code that makes this work (thank Christ) but at the previous place I worked, we did everything in SQL. Believing SQL Agent to be 'too limited', my boss had taken it upon himself to reimplement it... in SQL...

Just let that sink in for a moment.

There were 20+ tables all modelled after how SQL Agent does its own scheduling, 30+ stored procedures for interacting with it, and it was all intended for use with a GUI that was (naturally) never written. A relationship diagram of the tables sat on my personal Wall of Shame board for most of the time I was there. And yes, I had to use it from time to time. It was installed in every database for 200+ clients, in production, UAT, development, you name it.

The most delicious irony is, the only way such a thing could run automatically... was to use a SQL Agent job to poll it once a minute.

Re: Ask HN: What's the largest amount of bad code you have ever seen work?

#278

I never actually saw the code that makes this work (thank Christ) but at the previous place I worked, we did everything in SQL. Believing SQL Agent to be 'too limited', my boss had taken it upon himself to reimplement it... in SQL... Just let that sink in for a moment. There were 20+ tables all modelled after how SQL Agent does its own scheduling, 30+ stored procedures for interacting with it, and it was all intended…

And yes, I'm aware you can programmatically create SQL Agent jobs in SQL, so he couldn't even use that excuse. The only thing it had over SQL Agent was that it could be 'event driven'. All that ultimately meant was that the job would only run if a condition was met.

Yeah...

Re: Ask HN: What's the largest amount of bad code you have ever seen work?

#279
I have seen a complete project. The project was maintained by one person. Former developer left and transferred his work to the next.

It was a C project, but the second developer was coming from a Java background. So his half is all written with Java notation and naming conventions.

The thing was maths-heavy and had no comments. Instead they were consulting to a documentation book which also had file names and approximated line numbers.

The error tracing was done with function call stacks, so every function pushed some data into a global stack before a critical operation and, popped the same data if everything went without any problems.

Some libraries they were using were ad-hoc patched to taste, and grafted into the code tree. So, debugging was 5x harder and longer.

The functions were not divided into headers in a logical way, they were ad-hoc. So finding something was dependent on an source indexer or a grep sprint.

Last but not the least, the developer was so arrogant that the bugs were resolved by threatening to force him to clone his code and sent it out to another developer to debug and clean. Otherwise he pretended that the bugs were not present, because it was running on his test bed.

... and yes. It was in production.

Re: Ask HN: What's the largest amount of bad code you have ever seen work?

#280
post #210

Earlier quoted context omitted.

Rich Hickey called it guard rail driven programming. You'll never drive where you want to go if you just get on the highway and bump off the guard rails.

Except that's a really bad analogy. It's more like you set up guard rails, and every time your vehicle hits a guard rail you change the algorithm it uses for navigation until it can do a whole run without hitting a guard rail. I've experienced myself how the code quality of proper TDD code can be amazing. However it needs someone to still actually care about what they're doing. So it doesn't help with idiots.

> Except that's a really bad analogy. It's more like

The response to every analogy ever made on the internet. Can we stop using them yet?

Post reply on HN