Live data from Hacker News

You should write "without bugs"

korshakov.com

51–60 of 91 posts

Re: You should write "without bugs"

#51

Earlier quoted context omitted.

Ah, but perfect is the enemy of good.

Perfect is the enemy of ever shipping an actual product.

Hmm... Hasn't been my experience. I've been shipping a lot of really high-Quality stuff for decades.

It just takes a lot of work. No shortcuts.

But that WFM. YMMV.

Re: You should write "without bugs"

#52
post #35

In grad school I took a formal methods class where we proved properties about programs that completely changed how I think about bugs. The main things I took from the class were 1. Correctness of a program is distinct from its performance. 2. Program correctness can be proven. 3. Optimizing for performance often makes it harder to prove correctness. I do not actually use formal methods in my work as a developer, but…

Correctness of a program is usually distinct from performance. One obvious exception is code processing secret data. There, performance variance creates observable side-effects (timing side channels) which can be used to determine the secrets' values. Another is any sort of hard real-time system, where performance is critical to correctness. For example, a brake-by-wire system that took 10 seconds to respond to the p…

Even for hard real-time systems, focusing on correctness first is often the right way to go. At least in my experience, it's typically been much easier to make a correct system fast than a fast wrong system correct. With some particularly delightful (read: catastrophic) results when some folks really wanted to push their fast wrong code (fixed years ago, fortunately, and they had a good corporate culture change not long after so no point in naming and shaming).

Re: You should write "without bugs"

#53

This is pretty spot-on. A culture of testing everything will ossify code by not understanding what a "unit" is and amplifying developer churn by testing implementation details instead of the actual units. A culture of just getting features out the door will suffer under the weight of every change dragging on all future changes. If you want to really get code that can be adapted whenever requirements change, you need…

> Understand the code you write. Understand the code you choose not to write. Understand the code that was there before you got there.

Yup. I have seen so many people write stuff that could just be a YAML script, tying together massive dependency trees that they have no clue about.

Then, they lose it, when things go pear-shaped.

However, if the goal is to sell the company before the chickens come home to roost, it's a feature, not a bug.

Re: You should write "without bugs"

#54
In a college chemistry lab we would have to write lab reports of our work. The instructor made it very clear that he has never given 100% on a lab reports because there's always something to improve.

A one of my CS cohorts happened to be in the same class so we teamed up for the first lab project. It was pretty straightforward, we collected whatever information, and started working on our report. We didn't bother spending much time on it because we already knew we'd lose points for something or another.

When we got it back, there was a big, red "100" on top. We checked around and it did look like we were the only ones that got a perfect score, so we went to the instructor and, mostly jokingly, said, "What's up with this?" to which he stayed on beat and replied, "Do you want me to take another look?"

It's not hard to do good work, but you do have to make a habit of it. Re-read what you write, preferably out loud, to make sure it actually makes sense.

You'll still make errors and mistakes and you won't catch them all, but no one's going to care about a typo or two unless you draw attention to it with more glaring problems. And I think this is where metrics, especially things like code coverage, can actually be detrimental, because they bring attention to the wrong things.

Specifically, in places I've seen code coverage enforced, tests (written by consultants making x5-10 more than I do) tend to look like, `assert read_csv("foo,bar") == [["foo", "bar"]]` that execute enough of the function to satisfy the coverage requirements, but everyone is surprised when things break using a real CSV document.

The corollary of the author's trick is that if you keep making excuses to produce poor work, you may subconsciously decline instead.

Re: You should write "without bugs"

#55

His strategy for Russian language was sort of how I approached math in college when it started getting difficult and more abstract - I found that when I wrote in pencil, I would frequently make mistakes because of all the erasing and scratching out and going too quickly. So I started showing up to exams with only a pen - forcing me to sit and think very carefully about whatever I was about to write, and if I couldn't…

You story about the one pen reminds me of something. My old chemistry teacher gave grades to how orderly people's notes looked. "How it's put on your page, it's in your head," he used to say. At the time, we school kids found it "childish". But empirically, there is some truth to that: it seems I can learn better from clean notes than from sloppy notes, so often I re-wrote things. I was wondering whether that is due to the visual nature of memory, or whether the aesthetically more pleasing appearance of the cleanly re-written notes perhaps increased motivation.

Re: You should write "without bugs"

#56
post #55

His strategy for Russian language was sort of how I approached math in college when it started getting difficult and more abstract - I found that when I wrote in pencil, I would frequently make mistakes because of all the erasing and scratching out and going too quickly. So I started showing up to exams with only a pen - forcing me to sit and think very carefully about whatever I was about to write, and if I couldn't…

You story about the one pen reminds me of something. My old chemistry teacher gave grades to how orderly people's notes looked. "How it's put on your page, it's in your head," he used to say. At the time, we school kids found it "childish". But empirically, there is some truth to that: it seems I can learn better from clean notes than from sloppy notes, so often I re-wrote things. I was wondering whether that is due…

Good point, I think the reason it helped me was I could trust what I had written down a lot more as following a clean line of thought I had become reasonably certain of - which had the effect of speeding me up because i wasn’t looking back in some chicken scratch sprawl and trying to find whatever weird assumption I had made somewhere. It still would happen in pen sometimes, but, a lot less, and if it did, the error was much more blatant and easier to find.

Re: You should write "without bugs"

#57

Earlier quoted context omitted.

Ah, but perfect is the enemy of good.

Perfect is the enemy of ever shipping an actual product.

That's a justification for making a product with fewer features, not for making a product that's packed with bugs.

Re: You should write "without bugs"

#58
post #35

In grad school I took a formal methods class where we proved properties about programs that completely changed how I think about bugs. The main things I took from the class were 1. Correctness of a program is distinct from its performance. 2. Program correctness can be proven. 3. Optimizing for performance often makes it harder to prove correctness. I do not actually use formal methods in my work as a developer, but…

It is a great time to work with proofs and formal verification; so many nice tools with different goals like idris, agra, lean, coq, tla+, etc, but also unit and system tests, however generally clients don't pay for that; they pay for sloppy and buggy.

Re: You should write "without bugs"

#59

The best way to write without bugs is to measure bugs, and react to them. Airbrake, Rollbar, Datadog, New Relic mean nothing if you ignore bugs because you don't take the time to replicate them. You also can't fix what you don't know, so you need some telemetry or reporting of not your happy path. You can't have a goal of bug free code if you don't measure bugs (that's not SMART goal because it's not measurable). Uni…

The point is to not write bugs in the first place. At the point you’ve noticed a bug and measured it in your bug tracker you’ve missed your goal. You did not write “without bugs.”
Post reply on HN