8 year old has been fascinated by usb drives and viruses for a while, so today I said we'd write some virus scanning code and put it on a USB drive. So I wrote a little javascript function that prints "VIRUS DETECTED" or "no viruses found" randomly when you click a button.
We put the USB drive in his mom's computer, opened the html file and clicked the button and... uh oh... virus detected.

Now we needed a virus blocker.
So obviously I wrote a virus blocker program.

Copied the exact same function to a new file and changed the text to "VIRUS BLOCKED" or "Virus blocking failed, please try again." Also set the probability of the first option to be 20% so it'd require more clicking.
So now we've got a usb drive with a virus scanner and, just in case we detect one, a virus blocker.

Kid thought I was a GENIUS.
The kid wanted to see the code and learn how to do it.

The jig was up...
So I explained how the function worked and how it wasn't actually scanning anything but just picking a random number then printing text based on the number.
The kid looked at me like I had just said the dog died. Absolutely devastated. All those viruses we found and blocked WERE A LIE.
I explained that I don't actually have any idea how to scan a computer for viruses. The kind of programming that I do is mostly about making numbers pretty.
But I also explained that programmers often make toy examples to make sure the code works. And then I pointed out where in the code you could add some *actual* virus scanning code to make it work 'for real'.
And that was totally satisfactory. Now the kid wants to figure out that addition and plug the code in.

I did not commit to that part....
You can follow @WyoWeeds.
Tip: mention @twtextapp on a Twitter thread with the keyword “unroll” to get a link to it.

Latest Threads Unrolled: