Live data from Hacker News

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

news.ycombinator.com

151–160 of 601 posts

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

#151

A customer-facing dashboard. Yes, a dashboard. How bad can a dashboard be bad you ask? Well, for one, the dashboard had tabs, and each tab was a separate webapp hosted on a separate server. And each team was responsible for developing and maintaining the webapp that their team was incharge of (i.e the User team in charge of Users webapp, Feature1 team incharge of Feature1 webapp). Now add on the fact that different t…

I've run into exactly this issue at a past job, multiple webapps run by different teams that were "tabs", with a central auth system. I turned up, saw this and couldn't believe my eyes. Basically because teams couldn't agree on working together, they made this horrid attempt of a service based architecture and the result was chaos. I know monoliths are not popular, but they have their place in early stage companies where moving fast v's having a trendy design is critical. Company went out of business a few years later...

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

#152
post #10

Years ago as an intern at Microsoft, I had code go into the Excel, PowerPoint, Word, Outlook, and shared Office code. Excel is an incomprehensible maze of #defines and macros, PowerPoint is a Golden Temple of overly-object-oriented insanity, and Word is just so old and brittle you'd expect it to turn to dust by committing. There are "don't touch this!"-like messages left near the main loop _since roughly 1990_. I had…

Maybe in the year 2050 some future intern/employee will be adding to the Office code and wonder about the "Don't touch this" code relics of the past that someone from long ago left for future generations.

I bet in 2050 people will puzzle over the microservice-cloud-javascript-Go-caching legacy systems that were developed in 2018 and be scared...

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

#153

Earlier quoted context omitted.

In reality there often isn't time. Getting it done > Getting it done properly as far a management is concerned.

This is a complete fallacy IMO. The time is 10 fold down the line when people are attempting to reverse engineer in order to maintain it.

Try telling that to a pointy-haired boss.

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

#154
post #102

My own CMS. Here's the function signature of the heart of it, which depending on circumstance may call itself recursively. function a_nodes_list_trees( $site_url, $base_url, $mode, $site_id, $max_subtree_depth, $nlevels, $node_id = 0, $tree_id = 0, $nleft = 0, $nright = 0, $nlevel = 0, $current_subtree_depth = 0, $flags = 0, $order = 'tree', $inline = false, /* needed when loading stuff via ajax*/ $skipped_types = []…

An easy refactor for your function is to use a "Builder" for your params, i.e.: options = NodeBuilder .author({ min: 2 }) .flag({ .. }) .pagitation({ .. }) function a_nodes_list_trees(options) { ... } Because in the end, if your function is fast and working correctly, it's fine even though it's a little bit messy. The problem is more all the code calling this function and having to pass dozens of params in the right…

I think I'll just use arrays, one for the caller, and one globally that has the default values. Fortunately that function isn't called in that many places.

Making and then really using the CMS helped me with knowing what I would want in my next CMS, and just keeping the whole in mind from the start would probably make it a lot better by itself. My thinking is that the longer I put that off, the more languages improved and the more I hopefully learned in the meantime ^^

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

#156

My own CMS. Here's the function signature of the heart of it, which depending on circumstance may call itself recursively. function a_nodes_list_trees( $site_url, $base_url, $mode, $site_id, $max_subtree_depth, $nlevels, $node_id = 0, $tree_id = 0, $nleft = 0, $nright = 0, $nlevel = 0, $current_subtree_depth = 0, $flags = 0, $order = 'tree', $inline = false, /* needed when loading stuff via ajax*/ $skipped_types = []…

You're benefitting from an accurate mental model of this code (since you wrote it and work on it) and as soon as someone else has to work on this thing they are going to curse you. So it might be job security but it's also vulnerable to the hit-by-a-bus problem

When I started out, I wanted to opensource it, it had an installer and everything.. but then I realized it's become kind of a little monster and wisely canceled that plan, I'm not that irresponsible or mean :)

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

#157

Worked on a file-sync system written in Python 2.6/7 by B-players in a hurry. Lots of microservices, before it was cool, that was fine. Shitty code everywhere, commented code, dead code, 5 blank lines here and there. Many lines over 100 chars, lots pushing 150 or 200+. Didn't understand how to use argparse or logging but tried. Crazy mixed-case WTFExtremelyLongSillyNamesEverwhereSendThis at the command-line interface…

My only code style rule is don’t write lines more than 100 char which usually means “one statement per line”. It floors me how people think it’s acceptable to write code that you have to scroll not one but two axises to try and comprehend. Reading code should be like reading a book. And forcing yourself to write code that grows vertically instead of horrizontally usually solves all the problems and more that people dumping countless hours into auto-formatters are trying to grapple with.

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

#158
post #134

Earlier quoted context omitted.

This is a complete fallacy IMO. The time is 10 fold down the line when people are attempting to reverse engineer in order to maintain it.

Presumably, down the road, you'll either be a defunct company or doing well enough to afford 10 times the manpower to fix things. Facebook was a spaghetti code mess in the beginning. I'm sure it caused them some growing pains, but moving too slowly early on would have likely been more costly.

> Presumably, down the road, you'll either be a defunct company or doing well enough to afford 10 times the manpower to fix things.

Only in startup land which is still a small fraction of our industry.

Most places will never have 10 times the manpower to fix things and are hurting themselves by not doing them properly in the first place.

> Facebook was a spaghetti code mess in the beginning. I'm sure it caused them some growing pains, but moving too slowly early on would have likely been more costly.

Survivor-ship bias, for every facebook how many potentially viable companies never got off the ground because users couldn't tolerate using their steaming pile?

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

#159

A customer-facing dashboard. Yes, a dashboard. How bad can a dashboard be bad you ask? Well, for one, the dashboard had tabs, and each tab was a separate webapp hosted on a separate server. And each team was responsible for developing and maintaining the webapp that their team was incharge of (i.e the User team in charge of Users webapp, Feature1 team incharge of Feature1 webapp). Now add on the fact that different t…

Talk about shipping the org chart.

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

#160

Here's a metaquestion: Is it possible for any codebase to NOT eventually (given enough time) become a crufty pile of garbage? I suspect (but have no real evidence... yet) that SOME of this spaghetti garbage is due to the traits of procedural, OOP, mutable languages. But this would then imply that things like functional-language codebases have much longer lifespans... and I don't have evidence for that... but I'm hopi…

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.
Post reply on HN