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…
Ask HN: What's the largest amount of bad code you have ever seen work?
381–390 of 601 posts
Re: Ask HN: What's the largest amount of bad code you have ever seen work?
#382Re: Ask HN: What's the largest amount of bad code you have ever seen work?
#383Earlier 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.
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?
#384Oracle 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…
Re: Ask HN: What's the largest amount of bad code you have ever seen work?
#385Oracle 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…
Re: Ask HN: What's the largest amount of bad code you have ever seen work?
#386Earlier 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.
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?
#387Oracle 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 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?
#388Re: Ask HN: What's the largest amount of bad code you have ever seen work?
#389Previous 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…