HACKER Q&A
📣 rreyes1979

Is all code crap?


Or have I been unlucky for the last 20 years as software engineer?


  👤 ravenstine Accepted Answer ✓
All code? Nah.

Other people's code? Of course. /s

Most code? Yeah, I kind of think so, actually.

The demands of business will always be at odds with engineering, and everyone is at different levels in their coding journeys, and everyone's got different opinions on what code should be. It's a tug of war where no one actually wins but everyone gets a consolation prize that hopefully makes it worth it.

Code sometimes surprises me, in a good way, and it also disappoints me a lot of the time. I can't really say that My Way TM is better. The disappointment mostly comes from a lack of will from the rest of an organization to not take steps to make things better, even when the writing is on the wall that they will have to sooner or later.

In short, yeah, it's kinda bad, but it's also not so bad. Something we all need to do, I think, is accept that what we were taught that coding would be like is fantastical. I guess I was influenced early on in such a way that I believed that one day the code would actually get better. With a handful of exceptions, it usually doesn't. Unless one is lucky, our job is to make it work and to figure it out when it's not working.


👤 Rury
Maybe. I find myself strangely finding code less and less crappy the more as I've grown as a developer (currently 11 years). Or perhaps, a lot happens to be crap, and it just doesn't bother me anymore like it use to? Somehow I rarely find myself frustrated with coding anymore, whether that's involving other people's code, or my own.

I think part of it is just realizing there is no perfect code, as there's a tradeoff with everything. Acknowledging that someone else was wanting to optimize for something (e.g. efficiency, performance, robustness, scalability, time to implement, ease of maintenance, readability, handling a particular problem) and that it came with a cost at one or more of the other categories, and you realize that the strengths of anything can also be its weakness (and vice versa). It's why languages that are easy to understand, are often criticized to be verbose. Why code minifiers can improve performance, at the cost of readability. Additionally, sometimes the problem isn't fully defined when code is getting written, so it's hard to simply blame code for bugs that do crop up. It's simply unfinished code in such scenarios, not necessarily crap code.

But that said, there is definitely objectively bad code out there. I'd say if you see code trying to solve a given problem, but doing it a much more complicated way than is necessary (by like orders of magnitude, not just a couple of degrees), then it's clearly crap, as it isn't good at any of the categories mentioned above, let alone at its intended purpose.

I'd say I come across undoubtedly bad code less often than not.


👤 AnimalMuppet
I think all code has at least one axis on which it is crap.

For example, I think it's very hard to have code that is as fast as possible, and also is very readable. It's hard to have code that has a good UI and is also not verbose. It's hard to have code that is both complete and easy to change. So for every code you run into, you can say "this is crap because X", and there will be at least one X for which you are right.

But some code is much worse than other code. There is code that is generally good quality, even if it is rare.


👤 anonymousiam
Blame the "patch after sale" culture embraced by Microsoft. Most software houses are perfectly fine with shipping bad code, and then patching it once enough customers complain.

I come from a culture of space-flight software where it needs to be right the first time or the mission fails. Good software is possible, it just costs more.


👤 adam_arthur
Education doesn't really stress readable code. Thus, must in industry don't care about it either. I've met plenty of uber smart people that write crap code (it works, but poorly maintainable, hard to read).

The engineering/quality side of SWE matters way more in 90% of roles than the comp sci theory... so the whole training system is pretty backwards.

But industry will move to higher and higher level abstractions over time, just like bit manipulation questions don't get asked in interviews anymore. And I suspect serverless will neuter the design interview to a pretty great degree over the next few years.

At least personally, I've found interview questions that are light on theory (but still contain some), and heavy on coding to provide a signal that correlates much better with real world performance.


👤 khedoros1
The code that I just finished writing is perfect and beautiful. It'll be crap next week when I forget that I wrote it.

👤 TimJRobinson
It gets worse the more edge cases and "what ifs" it can handle. Code that looks beautiful generally only works in the happy cases.

👤 blacksmithgu
Any actively maintained codebase always devolves into crap. Scopes change, technology shifts, bugs patched; code quality monotonically declines as you trend away from the assumptions the program was written with.

No amount of rigor and discipline can stop this trend. If you truly care about high code quality, design your programs to be small and modular, and redesign them when assumptions change instead of repeatedly patching them.

Rewriting is often unsuccessful as well, though. So practically speaking: best get used to the smell.


👤 Gualdrapo
According to Sturgeon's law[0], not _all_ code can be crap, 'just' the 90% of it.

[0] https://en.wikipedia.org/wiki/Sturgeon%27s_law



👤 linkdd
Programming is the art of adding bugs to an empty text file.

👤 drewbug01
Only other people’s code is crap.

👤 cbanek
Honestly, yes.

Code is a liability, not an asset. Over time it decreases in value, it is forgotten, misunderstood, and everything will change around it. Many times I've been happy to replace a custom system with an off the shelf one, just to reduce the amount of code I have to worry about.

Even if you keep working on it, requirements change, the code becomes a tangled mess and requires refactoring, tests need to be more complicated, you have to support more operating systems, etc.

At best it does what it needs to do well enough to pay for itself, and then some. Until it needs more work! You don't realize it's crap until it goes wrong and you look under the hood usually either.


👤 jeffdoolittle
The code itself matters little. It's a fools errand to attempt to write "good code" while glossing over, or outright ignoring, information hiding and dependency management.

Structure, testability, documentation and automation of the system give you a fighting chance.


👤 toomuchtodo
It’s beauty is directly proportional to the revenue it generates.

👤 Genbox
Yes, it mostly is.

Understanding systems, algorithms, design patterns etc. takes time. Nobody ever starts out writing a solution that incorporates things they don't know. That's why we have education, training, certificates etc. to rectify that and have people start out with some sort of foundation instead of from scratch.

It is rare I come across something I would classify as _good engineering_. It is mostly just crap.

Only artisans put any value into being succinct, using appropriate algorithms and data structures. Everyone else struggle with getting it to work. I think that paradigm covers just about any field of engineering out there.


👤 dustingetz
commercial code is developed under time to market pressure, cost minimization pressure, and organizational pressures, which typically include a dramatic lack of accountability and perverse incentives. And, the most essential elements of a business (without which you don’t have one) is sales and finance, not code quality. so yes

👤 mbrodersen
“Crap” is in the eye of the beholder. It is an attitude problem more than a code problem. The worst developers I have ever worked with thought that everything was crap. Either because they were extremely arrogant, and code that wasn’t done their way was automatically “crap”, or because they had real trouble understanding code written by other developers, no matter how skilled and experienced those developers were. The smartest developers I have ever worked with can jump into any code base, written in any style, and be productive fast. They might make fun of some parts of the code, but they know there are often good historical reasons why the code was done that way, and they will be the first to admit that they themselves probably have done stuff like that in the past. So in conclusion, if you think all code is crap, your attitude might be the problem more than the code.

👤 nowherebeen
People only care about outcomes. They don’t care about code quality until they can’t change anything without breaking it.

👤 captainbland
It seems like there are a fair few coding "ideologies" around which sort of interact with different paradigms and languages, but sometimes multiple exist within those spaces... and every other ideology's code is "crap" to the others. So don't worry, your code is definitely crap to somebody!

👤 ffhhj
Read John Carmack's reply to someone saying Doom's code is beautiful:

https://mobile.twitter.com/id_aa_carmack/status/290886163454...


👤 slater
It's spaghetti all the way down.

👤 4oo4
My code is great when I'm writing it, but becomes crap when I run it and find all the bugs. Code I wrote any day other than today was basically written by a different person, and thus also crap.

👤 roeles
Most engineering is crap, when you look at it close enough. It's like embroidery. In order for the front to be pretty, you take all sorts of ugly shortcuts at the other side.

👤 mbrodersen
Whether code is “crap” is completely irrelevant. What matters is whether it (1) solves the problem it was intended to solve (2) how long it takes to add features/fix bugs. The 2nd part depends more on the developers than the code. Great developers can jump in and be effective in most code. Bad developers can’t even be effective in code written 100% by themselves! In other words, developers matter a lot more than code.

👤 flamesofphx
Absolutely, the great huge heaping volume of horse dung in human history.. bit by bit, the highest density load of garbage one could collect..

YEAH HUMANS!!


👤 User23
There’s an important distinction between program correctness and program pleasantness. A program can be incorrect but still quite pleasant. Video games have many exemplars. Roughly speaking correctness means satisfying some specification and pleasantness means pleasing the program’s users (or owners, which usually means commercial success).

Given that context, what do you mean by crap?


👤 krapp
If it does the job, it isn't crap.

👤 rektide
Code isn't crap. But developers haven't gotten a whiff of better. We still build in a trashform useless protoform, haven't explored into what might actually help.

The platforms & systems we build upon have not significantly improved in noticeable ways. And most critically, there are zero innovations we work with that have included users. All software improvements have targetted developers, development experience, and at no point have we tried to bring a wider world onboard (XOPC being perhaps the only notable exception the last decades). Software is fallen and trash. Code is fine, and good, and noble, but none of these developers have any chance of building a single solitary lone good thing: for all that we build upon is shaky burning platforms of no merit or worth.

Software is shit. We are shit, just trash people. We have been whipped into building solutions, fixed un-soft coercive services, into building complete & totalizing things. This is bass-ackwards, wrong: anti-soft. What's actually important is building extropic systems, is sharing what's happening, is making basic soft systems. We've fallen away from the soft in software. Everything is wrong, we fail to serve the "soft"ware cause, we are misaligned to help the world, and we could do much better. Alas.

We could pivot on a dime. We could decide to start unlocking potential, not gating it, at any time. I view work's like Karlicoss's exploration of all their systems[1] as a starting place, as what software ought do by default, ought assist this species with. But they fight to help advance an equitable basis: against countless resistive piece of shit systems. This should be expectable.

[1] https://news.ycombinator.com/item?id=31187346


👤 jpcapdevila
Haha, most code evolve into crap. But crap can solve real user & business needs.

👤 rufflez
Umm… no. I really don’t like the subtext of this question

👤 georgeoliver
The old saying is that familiarity breeds contempt, but from what I've seen, in software it's the opposite.

👤 outside1234
I don't know about crap, but it every line of code is a liability, not an asset.

👤 quantum_state
An interesting question seems to be: is it inevitable?

👤 wglb
Just 94% of it. See Sturgen’s Rule

👤 sys_64738
It's art.

👤 tptacek
Yes.