DEV Community

Cover image for Nobody Wants to Read Your Sh*t
Chris Addy
Chris Addy

Posted on • Originally published at readingqueue.dev

Nobody Wants to Read Your Sh*t

Nobody Wants to Read Your Sh*t

Especially the Next Person to Have to Fix Your Code

A big fan of Steven Pressfield’s The War of Art: Winning the Inner Creative Battle — a fast book I read in a single sitting — I picked up Nobody Wants to Read Your Sh*t: Why That Is And What You Can Do About It last night. Again I finished it in a sitting. Well, ok, two. But still within 24 hours.

Both books could only, very loosely, be described as self-help. In fact towards the end of Nobody he embraces, ambivalently, the genre, but only insomuch as a genre of writing that is guided by the same principles as fiction. Non-fiction and memoir are determined by fiction’s need for a story, and for that story to need a reason to be told.

Good code is like that. Code is written by people for people. If all we cared about was writing instructions for machines we’d have no need for any of the high-level languages we use today. Don’t believe me? Quick, tell me what this does:1

reduce((lambda r,x: r-set(range(x**2,n,x)) if (x in r) else r), range(2,int(n**0.5)), set(range(2,n)))
Enter fullscreen mode Exit fullscreen mode

Yea. How about if we wrote it like this:2

def SieveOfEratosthenes(n):
    prime = [True for i in range(n + 1)]
    p = 2
    while (p * p <= n):
        if (prime[p] == True):
            for i in range(p ** 2, n + 1, p):
                prime[i] = False
        p += 1
    prime[0]= False
    prime[1]= False
    for p in range(n + 1):
        if prime[p]:
            print(p),

if __name__=='__main__':
    n = 30
    print("Following are the prime numbers smaller")
    print("than or equal to", n)
    SieveOfEratosthenes(n)
Enter fullscreen mode Exit fullscreen mode

So why don’t we ever think of writing good stories when we write code?

For one, good programmers generally program for a living. And programming for a living means more than writing code. It means getting things done. It’s factory work. Maybe we shouldn’t think ourselves creatives.

But, I think Pressfield would disagree. While he doesn’t write much about programming, per se, he does briefly mention that code is a creative process. And he devotes the first full quarter of the book to talking about his time writing ad copy and writing screenplays, two professions where business needs and artistic desire clash.

I don’t know that there needs to be a choice between writing code that just works quickly to solve real world problems, and choosing to write that code in a way that feels like a story.

I also don’t know what that looks like, but I think I’m going to start writing it that way and see what sticks.


  1. https://wiki.python.org/moin/Powerful%20Python%20One-Liners. This one-liner needs its own slider. I think that helps prove my point, no?↩︎
  2. https://www.geeksforgeeks.org/python-program-for-sieve-of-eratosthenes/, edited out some comments as it messed with pages markdown, and updated to python 3 prints↩︎

Top comments (2)

Collapse
 
nombrekeff profile image
Keff

I have been using this philosohpy for a while now, as I have come across many codebases that where shit, and that got me thinking that I wouldn't want anyone to feel that way while reading my code. So whenever I can I try to remind myself to do so (If I'm not just getting things done)

It's not easy though, as I need to meet deadlines, or deploy some hotfix quickly. I think good code is a combination of, developers who want to write good code + the ability to do so. If a dev is overworked he will not be able to write as good code as one that has 2x more time for the single task (obsviously)

Collapse
 
jimstockwell profile image
Jim Stockwell

Please keep us posted as you work through discovering what that might look like. Thanks!