Live data from Hacker News

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

news.ycombinator.com

341–350 of 601 posts

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

#341

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…

One reason is that there's still a divide in understanding of the requirements to actually solve a problem between management and the engineering team. Unrealistic deadlines are given, and as a result, shit is produced.

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

#342

Earlier quoted context omitted.

"Don't touch this" around the main loop can mean being able to make promises about responsiveness, reliability, etc. Frequently there are critical code sections where it is much easier to tell people "don't touch it" rather than training people how to work on it safely.

When that is the case, would it not also be a really good place to explain why not, or provide a link to the place where such an explanation is provided?

To be fair, if you are implementing a feature or fix in Word and think you need to edit the main loop - 99% chance you are wrong and the fix would be better placed elsewhere. And 99% chance that an edit will cause regressions or changes in behaviour elsewhere.

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

#343

Once upon a time, there was a search product and one of the data sources that it could search was a Solr/Lucene database. This should be no problem, since search is what Solr does. It should be as simple as passing the user's query through to Solr and then reading the response. The problem was, it was important to know exactly which parts of any matched records were relevant to the search. The Guy Before Me™ decided…

... it all "worked great". Wow, what a mess.

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

#344

Earlier quoted context omitted.

Always test "outside-in", i.e. integration tests first, then if you can afford it, unit tests. Integration tests test those things you're going to get paid for... features & use-cases. Having a huge library of unit tests freezes your design and hampers your ability to modify in the future.

Love the idea of this. In my experience it's far easier to introduce testing by focusing on unit testing complicated, stateless business logic. The setup is less complex, the feedback cycle is quick, and the value is apparent ("oh gosh, now I understand all these edge cases and can change this complicated code with more confidence"). I think it also leads to better code at the class/module/function level. In my exper…

In general, I test those things that relate to the application, not those about the implementation.

i.e. Test business logic edge-cases, don't test a linked-list implementation... that's just locking your design in.

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

#345
post #242

Earlier quoted context omitted.

Probably fall from roof few times or was not really handy with hammer or something. The company is quite fascinating, they started around 1945 and during the years they've became small conglomerate. There are three or even four generations workign together and once they like you as a person they will find something for you to do.

Is the original programmer still at the company in any capacity?

No, he left before I was hired as a consultant. I had never get chance to talk to him in any form. I am the single person who ever touched the source code for past 10 years. I don't know why he left or where he went.

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

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

Most software, including on this thread, is not truly new, or at least can be built from known, reliable tools and patterns.

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

#347

I've worked on a CMS that was partially done in .NET, Iron Python and used an XSLT templating system to generate HTML for the front end. The architecture looked like something from the Early Java days. The system used Iron Python / C# in the following way. 1. A web request would hit the CMS 2. There was a massive switch statement to work out how the query would be rewritten 3. If it the url was prefixed with processo…

I actually laughed while reading this. I've encountered something eerily similar, but it was a Ruby app. Almost exactly your steps 1-3, however, what was returned from the db were ruby method names, which were then invoking other pieces of the code through some deep, twisted ruby magic. Uncovering what the hell was actually happening was like peering into the mind of a psychopath. Once myself and 3 other engineers sp…

In a weird way I kinda like these totally mental systems. It really ups your skill level for debugging if nothing else.

I've worked with lots of proprietary CMS systems and I kinda got into a groove with working with them. I knew exactly how to manipulate the system within the parameters of said system.

I kinda found it challenging. When a system is well built. I find it boring.

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

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

Fingers crossed that there are no merge conflicts & conflicting tests.

Everyone's on the same 2 month like schedules, so I guess that won't be much of a problem.

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

#349
post #43

From 10+ years ago when I worked at PayPay, webscr (the frontend at the time, where you'd log in) was a total of 2GB of C++ that would get compiled into a 1GB CGI executable, deployed over some ~700+ web servers. Debug versions would never get compiled, as I'm told the resulting file was too large for the filesystem to handle. Apparently a great deal of the code was actually inline XML. They knew this was a bad pile…

I think you meant to say PayPal?

PayPay is a Japanese payment company

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

#350

As a budding programmer (hobbyist), what can I do not to fall into the mistakes others talk about in the comments? Is there any particular set of mental habits that could lessen the chance of spaghetti occurring, or is it just a matter of when rather than if?

All these comments are good. Also ALWAYS watch out for 'Quick Win': When you do something quick and dirty, mark it up for 'refactoring' (i.e. Tech Debt). When your list of quick and dirty builds up, go and clean it. Do not accumulate tech debt, try to keep it low otherwise you will pay full price later (examples up here).

Another great tip that saved me from tons of refactoring: "The wrong abstraction is worse code duplication". Meaning sometimes duplication of code is better than trying to create the wrong architecture (as long as you mark it in your quick and dirty list).

Post reply on HN