Live data from Hacker News

The code culture problem

fraustollc.com

101–110 of 162 posts

Re: The code culture problem

#101
post #34
post #7

A factor I think the article doesn't point out clearly enough is how the main attraction of dissing code is that it serves as an ego-defense mechanism. Understanding code is, almost without exception, challenging. It's much easier on our self image if we believe the code is to blame, rather than us. An unfortunate side effect is that this perceived badness of the code is then often used as an excuse to not really try…

A good assessment in my opinion. As a junior coder earlier in my career I found exactly the situation described. A co-worker was always griping loudly about how bad the code and architectural decisions of certain people supposedly were - all except his own, of course. At first I was too diffident to form an opinion and considered whether he might be right. When I gained more experience, and finally got a look at what…

> all except his own, of course.

yeah, if you're going to talk bad about anyone's code, start with your own. not even the things you wrote a few months ago, but like even today, writing xml schemas for a rest api, the whole time i'm thinking about all the ways the decisions i'm making are going to come back and bite me in the ass. not because i'm inexperienced but because i've written and worked with schemas and specs for interprocess communication before and know that any changes to the schema will require edits to multiple codebases and the time and effort to make some of those changes can be frightening.

i guess this is what fred brooks calls "the second system effect." it'll probably turn out that there's some other more terrible problem with the current system that i'm not even seeing because i'm overly concerned about the communication protocol on top and not the databases underneath or concurrency off to the side somewhere.

how many systems of some particular type does one have to build before not writing shit on the first pass? because, like, yes, the code freely available to anyone with a quick `apt-get source` is often of much higher quality than some things hidden in multinational corporations' private repos. so everyone can have some idea of what good code looks like now, but i am personally finding creating much more difficult than verifying and fear that it's going to take a lot of time to narrow that gap.

is it really necessary to work on like 8 processors before doing what someone like ivan godard does? maybe just 4 or 5 projects (which translates into about a decade, mind you) is enough before the "i'm fucking shit up" jitters pass for any particular type of system?

Re: The code culture problem

#102
A toilet that doesn't flush correctly isn't a reason to complain if you're a plumber; it's your raison d'etre. And, although many don't want to recognize it, a good number of software developers are modern day plumbers.

For many developers, imperfect code, which is often more likely to be result of circumstances beyond the control of the person who wrote it than downright incompetence, is the gift that keeps on giving. If business and functional requirements were always well-defined and never evolved, clients/business stakeholders completely sane, deadlines realistic, resources plentiful and "scope creep" a rare phenomenon, a lot of software developers would be unemployed, and employed ones would be more frequently undervalued.

Re: The code culture problem

#103

This piece reminds me of Linus Torvalds. He's the kind of guy that lives these truths. Always respectful and constructive, never saying code is shit, etc etc. We need more developers like him.

Torvalds is BDFL. If you wrote it, it's widely acknowledged to be good, and people want to add code to it, you're entitled to tell people their contributions are unwanted.

If no one other than the 6 people you're working with have ever read the code and nobody wants to add code to it, you need to really spend some time reading the code before you make a judgement call. At that point, it's better to make the code not shit than simply call it shit.

In software, if you can articulate why it's bad, you can fix it. If you can't articulate why it's bad, keep it to yourself.

Re: The code culture problem

#104

> the code is usually not particularly shit I'm sorry, but yes, it usually is. I've been in this business for over 25 years, and I'm one of the few people that actually enjoys the challenge of dealing with legacy code. But most of the code I've seen is shit. The answer to the question "could it have been done better" is usually "yes, if it had been done by someone who understood the basic principles of the paradigm t…

So what exactly is the point you are trying to make here other than that you are the smartest guy? The article is not about the existence of shit code, the amout of shit code produced per year or how much shit code the average developer will see in his career. It is about teamwork, and what kind of culture poisons the atmosphere in a company. Not about shit code, which by the way everyone here has produced at some po…

The first step to solving a problem is admitting that there is one. I remember debugging some AJAX code once which was racing with itself. It took a lot of mental effort to work out what the existing code was meant to be doing and what it was actually doing, both of which were wrong. At it's core was a simple jQuery AJAX call with a success callback (no error callback, of course), but interleaved through it was a mess of global variables ("finished_yet", "time_last_checked", etc.), busy-loops, manual timeouts, state-rollback functions, etc. What I would call shit code.

Once I finally understood what it was doing enough to refactor it I managed to delete most of the file and replace it with a "latest_id" counter which incremented on each call, with the success handler skipping if its ID wasn't the latest. Simple.

I approached the developer responsible for the original, to show him what I'd done and explain how Javascript's scope let each call have its own ID. His response was that I'm using obscure language hacks which nobody is going to understand when they have to maintain it, that I should stop trying to force everything into a few lines and that he doesn't need to learn about Javascript's scope because he can already program so learning anything else is a waste of time that could be spent coding.

I got told a similar thing during a code review as well, since I'd used map on an array. Needless to say, I didn't stay there long.

Now that is a cultural problem, which can only be solved by pointing out shit code (although in a more polite way). Some people are so stuck in their ways that they don't care about improvement because they see their stuff as 'good enough'. In those cases, they need to be shown that no, it's not good enough, because XYZ.

I wasn't trying to gain points on anyone; I was just frustrated at the utter lack of care about the codebase we all had to work on. Whenever I spotted anything particularly WTF I'd send out a "Code of the day" email. My favourite is still this one:

    
      blah blah blah
    

Re: The code culture problem

#105

I imagine anyone who's been around for long at all has written what someone would call "shit code." Hindsight is 20/20. Imagine auto makers comparing product today with those from 50 years ago? That's about how far we've progressed in 10-15 years in this industry. Were those guys whose contemporaries were able to send people to the moon on CNC-less machine tools and computers with 4K RAM somehow doing "shit engineeri…

Good point, but writing software in PHP or Java is voluntary retardation. You're holding back the advancement of our trade.

> Java

I call bull. Java has plenty of issues, but plenty of plus points too, particularly for large-scale development on teams that experience employee turnover.

- Reasonably fast, considering the ease of development.

- Genuinely fantastic tooling.

- Generally discourages 'fancy' programming techniques. Obviously doesn't stop shit code getting produced, but at least tends to be relatively easy for maintenance programmers who weren't heavily involved in original development to understand.

I have to use Java for some of my work, and with the correct tooling it's really not that bad. Sometimes it's fantastic - when you're maintaining someone else's code, the ability to trivially (and exhaustively) find out what code calls this code, safely refactor and so on is invaluable. Of languages in its general class, C# is significantly superior, but tied to MS if you want a full-speed VM.

I'm not saying that you're likely to produce the most beautiful code of your life in Java, but compared to many other languages (+ toolchains) I find working on other people's code is rather easy.

Re: The code culture problem

#106
60% shit removal! A review removes 60-80% shit, to remove more than 80% use compounded shit removal. Compound requirements, design and code reviews to get 99%+ shit removal. finding 60% shit is not hard, every time you spot a little shit spend 3mins thinking about how to create better next ti

Re: The code culture problem

#107
post #72
post #61

Earlier quoted context omitted.

"Most code out there is shit code." semantic point. if you're saying 'most code' is shit, aren't you saying average code is shit? Kind of like saying a 6 min mile is shit because it's not a 4 min mile.

No, a 6 min mile is not average. And yes the average of most things is shit. Shit isn't bad (unless it is), it is the output of useful work usually. It just needs to be covered up and stayed away from.

> Shit isn't bad

I would suggest that this indicates that your figurative use of "shit" is not the common figurative use of the term in the phrase "shit code", which is impairing communication.

Re: The code culture problem

#108
post #48
post #38

Earlier quoted context omitted.

If the majority of code is shit, then it's not really a very useful observation to make repeatedly. So I think this goes back to the author's point that this is really a cultural or attitude issue. It's like the friend who complains about everything all the time: constantly complaining about traffic, about the weather, about how the city is losing its charm, about his job, about his classes, about his parents, about…

There is at least one useful implication to the observation, and that's that most (or all) software is shit. Yet people still use and buy it. The implication is a nice three-edged sword. You're guarded against crippling perfectionism, you're striving to get out of the shit as much as you can, and for developers you will always prefer having the source if you want to fix some shit. This article made me remember this f…

That is not my experience. There is a ton of good to extremely good code out there. I'm rather dismayed by the amount of "well, what can you do" hands-thrown-up attitude here.

I've always found clean code to be faster to develop. I find that developers that produce lower quality code tend to spend their days debugging, fighting their code, reading and trying to figure out what they wrote 5 months ago, and so on. They are just not very productive. There are the outliers - people that have instant recall of all their code and elaborate mental models of really poorly structured code - but by and large I find that people that generate low quality code are quite slow performers.

I've worked in very good code bases, and very bad ones. In the good ones you can easily figure out what is going on, quickly make changes, confident that you aren't breaking 5 things because things are decoupled. You can produce new code quickly because you aren't fiddling with code nested 6 if statements deep, which is just about impossible to model correctly in your head. You aren't in endless compile/run/debug (or REPL/run/debug) cycles because your first try is usually just about right, because you can understand the surrounding code. I recently requested a simple feature, and was told it would take a week. I was dubious. Then I looked at the code, and decided that they were being conservative, if anything... for something I thought would reasonably take a few hours.

This is just an impassioned plea, not to Jach, but to the profession, to cast a critical eye on code. You can produce high quality code quickly. Not "nuclear reactor" quality, but pretty close. Bad code always costs you. Always. Don't write that way, don't allow it in your code base, or in your teammates.

Re: The code culture problem

#109
post #59

I still love it when you find some "shit" code, just to realize you wrote it yourself ages ago.

This is a sign of progress, actually. If you cannot find faults in the code you wrote ages ago and think it is awesome, time to find and fix some deep problems.

Not necessarily... it's only progress if you wouldn't do the same thing again.

It's one thing to be able to recognize shitty code in hindsight or in another developer's work. It's quite another to be able to catch yourself before you write shitty code and do better.

Re: The code culture problem

#110
I'd say most code is shit. However, I'm sure people don't deliver shit code by pure choice. Unclear function purposes, time constrains, bad days, etc. Or just the plain old, "quick hack it together" to get back to the code you where really working on. We should just not feel insulted about the fact we write shit code, this doesn't mean you are a shit programmer.
Post reply on HN