<story><title>Ask HN: What&apos;s the largest amount of bad code you have ever seen work?</title><text>I think I&amp;#x27;ve broken my own record with this one ~2500 lines of incoherent JavaScript&amp;#x2F;C#. Works though.</text></story><parent_chain><item><author>forthy</author><text>I doubt the competition (e.g. IBM or Microsoft) has any better code quality. Even PostgreSQL is 1.3M lines of code, so let&amp;#x27;s get something deliberately written for simplicity. SQLite is just 130k SLoC, so another order of magnitude simpler.&lt;p&gt;And yet, even SQLite has an awful amount of test cases.&lt;p&gt;&lt;a href=&quot;https:&amp;#x2F;&amp;#x2F;www.sqlite.org&amp;#x2F;testing.html&quot; rel=&quot;nofollow&quot;&gt;https:&amp;#x2F;&amp;#x2F;www.sqlite.org&amp;#x2F;testing.html&lt;/a&gt;</text></item><item><author>AtlasBarfed</author><text>You&amp;#x27;ve violated the terms of service of Oracle Database by insinuating the codebase quality is in any way not superior to any and all competitors. No benchmarks or comparisons may be performed on the Oracle Database Product under threat of grave bodily harm at the discretion of our very depraved CEO.</text></item><item><author>oraguy</author><text>Oracle Database 12.2.&lt;p&gt;It is close to 25 million lines of C code.&lt;p&gt;What an unimaginable horror! You can&amp;#x27;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.&lt;p&gt;Very complex pieces of logic, memory management, context switching, etc. are all held together with thousands of flags. The whole code is ridden with mysterious macros that one cannot decipher without picking a notebook and expanding relevant pats of the macros by hand. It can take a day to two days to really understand what a macro does.&lt;p&gt;Sometimes one needs to understand the values and the effects of 20 different flag to predict how the code would behave in different situations. Sometimes 100s too! I am not exaggerating.&lt;p&gt;The only reason why this product is still surviving and still works is due to literally millions of tests!&lt;p&gt;Here is how the life of an Oracle Database developer is:&lt;p&gt;- Start working on a new bug.&lt;p&gt;- Spend two weeks trying to understand the 20 different flags that interact in mysterious ways to cause this bag.&lt;p&gt;- Add one more flag to handle the new special scenario. Add a few more lines of code that checks this flag and works around the problematic situation and avoids the bug.&lt;p&gt;- Submit the changes to a test farm consisting of about 100 to 200 servers that would compile the code, build a new Oracle DB, and run the millions of tests in a distributed fashion.&lt;p&gt;- Go home. Come the next day and work on something else. The tests can take 20 hours to 30 hours to complete.&lt;p&gt;- Go home. Come the next day and check your farm test results. On a good day, there would be about 100 failing tests. On a bad day, there would be about 1000 failing tests. Pick some of these tests randomly and try to understand what went wrong with your assumptions. Maybe there are some 10 more flags to consider to truly understand the nature of the bug.&lt;p&gt;- Add a few more flags in an attempt to fix the issue. Submit the changes again for testing. Wait another 20 to 30 hours.&lt;p&gt;- Rinse and repeat for another two weeks until you get the mysterious incantation of the combination of flags right.&lt;p&gt;- Finally one fine day you would succeed with 0 tests failing.&lt;p&gt;- Add a hundred more tests for your new change to ensure that the next developer who has the misfortune of touching this new piece of code never ends up breaking your fix.&lt;p&gt;- Submit the work for one final round of testing. Then submit it for review. The review itself may take another 2 weeks to 2 months. So now move on to the next bug to work on.&lt;p&gt;- After 2 weeks to 2 months, when everything is complete, the code would be finally merged into the main branch.&lt;p&gt;The above is a non-exaggerated description of the life of a programmer in Oracle fixing a bug. Now imagine what horror it is going to be to develop a new feature. It takes 6 months to a year (sometimes two years!) to develop a single small feature (say something like adding a new mode of authentication like support for AD authentication).&lt;p&gt;The fact that this product even works is nothing short of a miracle!&lt;p&gt;I don&amp;#x27;t work for Oracle anymore. Will never work for Oracle again!</text></item></parent_chain><comment><author>pgaddict</author><text>I&amp;#x27;m sure some of the difference (25M vs. 1.3M) can be attributed to code for Oracle features missing in PostgreSQL. But a significant part of it is due to careful development process mercilessly eliminating duplicate and unnecessary code as part of the regular PostgreSQL development cycle.&lt;p&gt;It&amp;#x27;s a bit heartbreaking at first (you spend hours&amp;#x2F;days&amp;#x2F;weeks working on something, and then a fellow hacker comes and cuts of the unnecessary pieces), but in the long run I&amp;#x27;m grateful we do that.</text></comment>
<story><title>Ask HN: What&apos;s the largest amount of bad code you have ever seen work?</title><text>I think I&amp;#x27;ve broken my own record with this one ~2500 lines of incoherent JavaScript&amp;#x2F;C#. Works though.</text></story><parent_chain><item><author>forthy</author><text>I doubt the competition (e.g. IBM or Microsoft) has any better code quality. Even PostgreSQL is 1.3M lines of code, so let&amp;#x27;s get something deliberately written for simplicity. SQLite is just 130k SLoC, so another order of magnitude simpler.&lt;p&gt;And yet, even SQLite has an awful amount of test cases.&lt;p&gt;&lt;a href=&quot;https:&amp;#x2F;&amp;#x2F;www.sqlite.org&amp;#x2F;testing.html&quot; rel=&quot;nofollow&quot;&gt;https:&amp;#x2F;&amp;#x2F;www.sqlite.org&amp;#x2F;testing.html&lt;/a&gt;</text></item><item><author>AtlasBarfed</author><text>You&amp;#x27;ve violated the terms of service of Oracle Database by insinuating the codebase quality is in any way not superior to any and all competitors. No benchmarks or comparisons may be performed on the Oracle Database Product under threat of grave bodily harm at the discretion of our very depraved CEO.</text></item><item><author>oraguy</author><text>Oracle Database 12.2.&lt;p&gt;It is close to 25 million lines of C code.&lt;p&gt;What an unimaginable horror! You can&amp;#x27;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.&lt;p&gt;Very complex pieces of logic, memory management, context switching, etc. are all held together with thousands of flags. The whole code is ridden with mysterious macros that one cannot decipher without picking a notebook and expanding relevant pats of the macros by hand. It can take a day to two days to really understand what a macro does.&lt;p&gt;Sometimes one needs to understand the values and the effects of 20 different flag to predict how the code would behave in different situations. Sometimes 100s too! I am not exaggerating.&lt;p&gt;The only reason why this product is still surviving and still works is due to literally millions of tests!&lt;p&gt;Here is how the life of an Oracle Database developer is:&lt;p&gt;- Start working on a new bug.&lt;p&gt;- Spend two weeks trying to understand the 20 different flags that interact in mysterious ways to cause this bag.&lt;p&gt;- Add one more flag to handle the new special scenario. Add a few more lines of code that checks this flag and works around the problematic situation and avoids the bug.&lt;p&gt;- Submit the changes to a test farm consisting of about 100 to 200 servers that would compile the code, build a new Oracle DB, and run the millions of tests in a distributed fashion.&lt;p&gt;- Go home. Come the next day and work on something else. The tests can take 20 hours to 30 hours to complete.&lt;p&gt;- Go home. Come the next day and check your farm test results. On a good day, there would be about 100 failing tests. On a bad day, there would be about 1000 failing tests. Pick some of these tests randomly and try to understand what went wrong with your assumptions. Maybe there are some 10 more flags to consider to truly understand the nature of the bug.&lt;p&gt;- Add a few more flags in an attempt to fix the issue. Submit the changes again for testing. Wait another 20 to 30 hours.&lt;p&gt;- Rinse and repeat for another two weeks until you get the mysterious incantation of the combination of flags right.&lt;p&gt;- Finally one fine day you would succeed with 0 tests failing.&lt;p&gt;- Add a hundred more tests for your new change to ensure that the next developer who has the misfortune of touching this new piece of code never ends up breaking your fix.&lt;p&gt;- Submit the work for one final round of testing. Then submit it for review. The review itself may take another 2 weeks to 2 months. So now move on to the next bug to work on.&lt;p&gt;- After 2 weeks to 2 months, when everything is complete, the code would be finally merged into the main branch.&lt;p&gt;The above is a non-exaggerated description of the life of a programmer in Oracle fixing a bug. Now imagine what horror it is going to be to develop a new feature. It takes 6 months to a year (sometimes two years!) to develop a single small feature (say something like adding a new mode of authentication like support for AD authentication).&lt;p&gt;The fact that this product even works is nothing short of a miracle!&lt;p&gt;I don&amp;#x27;t work for Oracle anymore. Will never work for Oracle again!</text></item></parent_chain><comment><author>jeltz</author><text>PostgreSQL has a lot of code but most parts of the code base have pretty high quality code. The main exceptions are some contrib modules, but those are mostly isolated from the main code base.</text></comment>