Live data from Hacker News

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

news.ycombinator.com

441–450 of 601 posts

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

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

I love my job

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

#442

At my first gig I teamed up with a guy responsible for a gigantic monolith written in Lua. Originally, the project started as a little script running in Nginx. Over the course of several years, it organically grew to epic proportions, by consuming and replacing every piece of software that it interfaced with - including Nginx. There were two ingredients in the recipe for disaster. The first is that Lua comes "batteri…

This is gold.

Part 2 please???

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

#443
post #62

Earlier quoted context omitted.

A sentiment among members of a former team was that automated tests meant you didn't need to write understandable code - let the tests do the thinking for you. This, and stuff like your story, are why I don't trust people who promote test-driven development as the best way to write clean APIs.

The problem with TDD is that a dedicated developer can always make a test pass- the how is another matter.

when(mockObject.getVar()).thenReturn(1); assertEquals(1, mockObject.getVar());

test passes boss!

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

#444
post #413

I worked on the DMS switch in Nortel (if PRI broke for you, I'm sorry, I tried my best!). 31 millions lines of absolutely horrific code. You'd think somewhere in that mess there would be some redeeming code, but if there was I never found it. To give you some examples, I originally came on as a contractor because they had some refactoring they wanted done. The entire system was home built (including the programming l…

If you've made a long distance call at any point in the last 20 years (including today) you have decent odds that the call went thru a DMS.

It's been decades since I worked on telephones. That scares me a bit :-D

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

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

How can it have millions of tests with 25 million lines of code? How many lines of code is there including the code in the tests?

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

#446

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…

Chemical synthesis of medicine is highly scrutinized and fairly well understood, but there are a lot of other products that large chemical companies make in great quantity that are basically made using Black Magic. Tinker with it until it works, then don't mess with it!

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

#447
post #445
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…

How can it have millions of tests with 25 million lines of code? How many lines of code is there including the code in the tests?

You can have automated test generation. I'd imagine with a database system, you'd have a big list of possible ingredients to a query and then go thorugh a series of nested for loops to concatenate them together and make sure each permutation works separately. That can easily make for thousands of tests with only a few lines of code.

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

#448

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…

Brilliance is not indication of an ability to write clean code. In my experience, code needs to be re-factored 3 times before it starts to look coherent and clean. But 99% of projects can't justify that kind of expense. But good code is very feasible, just takes time.

I'll expand this further by saying yes to all of the above with the addition that to get it perfect in my experience requires about 7 iterations.

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

#449
post #445
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…

How can it have millions of tests with 25 million lines of code? How many lines of code is there including the code in the tests?

Along with what eigenspace said, check out SQLite's Testing page: https://www.sqlite.org/testing.html (the project has 711 times as much test code and scripts, as code). You can go really far... and still miss things on occasion.

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

#450

Earlier quoted context omitted.

Brilliance is not indication of an ability to write clean code. In my experience, code needs to be re-factored 3 times before it starts to look coherent and clean. But 99% of projects can't justify that kind of expense. But good code is very feasible, just takes time.

I'll expand this further by saying yes to all of the above with the addition that to get it perfect in my experience requires about 7 iterations.

Yup. Diminishing returns on that though. I'm happy with 3. Unless it's API or public code used by a wide audience then it needs a lot of eyes and has to be very clean.
Post reply on HN