Live data from Hacker News

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

news.ycombinator.com

381–390 of 601 posts

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

#381
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 not the only one being built in the west, EDF is having tremendous difficulty delivering the other ones. Flamanville ( https://en.wikipedia.org/wiki/Flamanville_Nuclear_Power_Plan...) is also very late, and given that I'm not quite sure why the UK ordered one too (https://en.wikipedia.org/wiki/Hinkley_Point_C_nuclear_power_...).

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

#382

Earlier quoted context omitted.

I think this validates my view that testing is important, but keeping the codebase clean, readable and modular is more important!

Why not both?

Yes, both. But maybe one is more important?

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

#383

Earlier quoted context omitted.

function isTrue(v) { var result; result = v; if (!isFalse(result == true)) { return result; } else { return isFalse(result); } } function isFalse(v) { var result; result = v; if (!isTrue(result == true)) { return isFalse(result); // Tail recursion so this is fine. } else { return result; } } if (isTrue(myBool) == true) { // TODO: Could this be refactored to isTrue(isTrue(myBool))? return true; } else if (isTrue(isFal…

i hope to god that this is just code you made up to be facetious.

Haha, yes I made it up. The infinite recursion should have been a dead giveaway :P

There's also a bug on line 7 that I didn't notice - it should be isTrue rather than isFalse. I can't edit the comment anymore to fix it.

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

#384
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…

Tests in C/C++ run shockingly fast. I ported an application from Ruby to C++ and the tests ran in well under a second when it was taking 10+ seconds in Ruby. Granted because of C++'s type system there were fewer tests, but it was fast enough that I kept thinking something was wrong.

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

#385
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…

[deleted]

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

#386

Earlier quoted context omitted.

Linux kernel is massive and has been around for decades now and it’s probably millions of lines. It certainly has a lot of cognitive overhead since you need to always keep in mind the context in which the code you are writing will be running (to reason about concurrency etc.), but it’s relatively easy to understand and well written.

Yeah, I think some FOSS projects qualify; I'd say OpendBSD.

OpenBSD has a very sane culture in which deleting code, or reformatting code without the compiler object change, are good things.

Most organizations don't see the value in that.

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

#387
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…

The notion of tests that take 20 hours blows my mind.

The notions of tests written in C that take 20 hours I can't even fathom.

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

#388
Server code written in C++ that called into a lower level C library. There was a 4000 line case statement that handled message replay. I am not sure why it wasn't broken out into functions, but it was "sensitive" code and refactoring it was considered a no go.

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

#389
(I am a regular of HN. I don't want this attributed to my acct.)

Previous job. Was sysad. This code runs most of the academic US internet.

Everything was Perl5. There were over 150 different major applications written with it, ranging from 40 lines to 500k lines. The older the recent commit, the worse. Touching any of this would cause errors, either in itself OR in associated applications! You'd be working on thing A, get it working well, and 4 weeks later thing B would fail horrendously.

The worst was a tie between a variable that was a 6 line long SQL query, which was packed to the brim with function calls that ended up expanding a query to something like 50 lines long.

The tie was a gem in code that wasn't touched for 7 years. This wasn't at the top, or even in a config file. It was hardcoded in the middle of the perl5 program...

     $db_server = (servername);
     $db_user = root;
     $db_password = (password);
Other dishonorable mentions are as follows:

1. No primary keys for the main database....

2. Goober had the idea of storing pictures in said MySQL database. 70 GB of pics...

3. Redhat 4 still in production, along with RH 5.

4. Its everyone for themselves. The goal is you hobble it along enough for the next oncall. Let them get hit with it.

5. Running iron from 10 years ago. Contracts pull in $$$, but you're dealing with paleo-datacenter crap

6. Just retired LTO3 tapes. Now they have "shiny" LTO5....

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

#390

(I am a regular of HN. I don't want this attributed to my acct.) Previous job. Was sysad. This code runs most of the academic US internet. Everything was Perl5. There were over 150 different major applications written with it, ranging from 40 lines to 500k lines. The older the recent commit, the worse. Touching any of this would cause errors, either in itself OR in associated applications! You'd be working on thing A…

You know what's terrible? This could almost be any one of about three of the Perl contracts I've had in the last decade (apart from the US part, obvs.)
Post reply on HN