lazy article

Pages: 123... 15
A few years ago I read an article online about programming and the value of being lazy. I would like to read it again, if only I could find it. If you know of any article that touches on this topic please post a link to it here. Thank you.
Last edited on
Sorry, I don't have the motivation to look for it. :)

(Sorry, couldn't resist.)
You lazy programmer. (That felt redundant.)

You should, it was a great article about programming and the value of being lazy. Why do what a computer can do for you?
Seriously, though, it sounds interesting.

I program by the motto: "why check something at runtime if the compiler can check it at compile time?"
I liked it. When I find it, I will be sure to post the link here for you and any one else who wishes to read it.
I got one about lazy programmers in an email from a Code project newsletter I think. I'm digging through my old mail trying to find it now. Is that the one you're talking about?
No. Google around "lazy evaluation".
Already looked there, but thanks, Duoas.

I dont recall much about this article. It talked about how adding a new programmer in the middle of a project slows progress down more than speeding it up. It went on about when its ok to be lazy and the value of writing a program to do your work instead of actually doing the work.

I have done several Google searches and did not find the artical I am looking for. When I get some time this week I will rip through the internet with the speed and force of an ADHD kid. Even if I have to manually tear 10000 sites to find it, I will find it!!
On the subject of laziness I just wrote a python script which clears the trashcan in Ubuntu every 300 seconds (5 minutes). I'm actually too lazy to click the trashcan icon every couple now and again just to delete it's contents. Then I added it to my list of startup programs so I don't even have to invoke it myself.

I'm going to find more ways of getting python to do things for me so I don't have to bother... I'll try to think of some other things I do alot that I can get python to do for me...

import os
import time

while True:
    os.system("rm -rf .local/share/Trash/*") # Clear trash
    time.sleep(300.0) # Wait 300 seconds (5 minutes) 

That's it... it's so cool how easy that is. At first I thought it would waste the CPU but it doesn't :)
Last edited on
5 minutes? how often do you delete stuff?

Thats great Chris. Don't you love the feeling you get when you teach a computer to replace you. I do.
I delete alot of stuff, very often. I get some kind of weird satisfaction from it, like I'm saving loads of space on my hard drive (hey, 1kb used to be alot)
Don't you love the feeling you get when you teach a computer to replace you.

Yeah :) Also I'm extremely lazy. When I have time I'm going to write something to do algebra for me... I remember someone saying that they'd written a program to do it but I've forgotten who it was. Anyway all I want it to do is find x in something like
x + 3 x + 7
----- = -----
x - 3 x - 5

because I can't do it! Stupid maths teacher didn't even teach us how to do this stuff. He's a complete waste of space.
Last edited on
Wouldn't it have been easier to just bind delete to actually delete the file?
You mean remove the whole wastebasket thing and just permadelete things with the delete key? No, this way I get five minutes just in case I made an accident :) That is the point of having a wastebasket, afterall...
Last edited on
No, you get at most five minutes. On average, you'll get two and a half minutes.
That's pretty slick!

I can't stand the wastebasket, but there have been (rare) times when I immediately regretted hitting the ENTER key...

Personally, I'd bump the time up to about thirty minutes, or once a day...
No, you get at most five minutes. On average, you'll get two and a half minutes.

What? It should sleep for 300 seconds (if only I could live off of 300 seconds of sleep per day; I'd be SO much more productive!) so how could it possibly re-iterate before 300 seconds is up? Is the Linux scheduler THAT good? "Attention: Linux kernel's scheduler is now so fast it can "compress" time. Yes, you heard right." I guess it must just be magic.
Any sufficiently advanced technology is indistinguishable from magic.
wow, Arthur C Clarke was right!

That doesn't really matter anyway. Usually if I delete something by accident; I'll be able to recover it within a minute... If not... then I best start rewriting the file/fixing the system/whatever I broke.

Personally, I'd bump the time up to about thirty minutes, or once a day...

Hm? I don't know why, but I can't stand seeing the wastebasket not-empty. This way, so long as I don't look at it within 5 minutes; I don't have to OCD-ily empty it myself all the time.
Last edited on
Look carefully at what your code is doing. It's just unconditionally emptying a directory every five minutes. What do you think would happen if you sent a file there 4:59 minutes after the last deletion?
Five minutes later it would delete it...

If it empties a directory then 300 seconds later it will empty it again. So every five minutes it is emptying the directory. If I put a file into the directory 2 minutes before the next deletion, then 120 seconds later, the file is deleted. So it is deleting files every 5 minutes; but just not necessarily five minutes after I delete it... I get it now.

Ok I'm going to add code to check if there's anything in the directory. Ideally, eventually, it will check for anything in the directory, and if there is anything it will delete it one minute later.

How about I make you a flowchart? :)

import os
import time

trash = ".local/share/Trash/" # Location of trashcan

def has_files(directory):
    i, files, fname = 0, [], ""

    for fname in os.listdir(directory): # Iterate over files
        i += 1
        print("Found file/folder %s" % fname)
    return (False, True) [i > 0]

def clear(directory):
    os.system("rm -rf " + directory + "*")

def sleep(seconds):

while True:
    if has_files(trash): # Trash directory isn't empty
        print("Trashcan not empty, empty trashcan...")
        clear(trash)     # Empty it
        print("Trashcan empty.")
    sleep(300) # Sleep for ~5 minutes 

Now it only tries to empty the directory if there are files in it.
Last edited on
Actually it would delete the file immediately. You would need to check every second or so to see if there are files, and if there are, THEN start the 5 minute timer.
The new version has exactly the same flaw as the old one.
Pages: 123... 15