Teaching programming in schools?

Estonia recently decided that it should teach programming to children from the very beginning of their education (that is when they are 6 years old). People are asking why?

In a nutshell it will make the future generation more efficient at using computers, and since most of us will work in the service industry and using computers smartly is a big plus.

Where I am currently working, we perform a lot of experiments and one of my tasks involves verifying that some measurements we are doing functions properly. The measurements we do fails a lot so it is important to keep an eye on them, so we can fix the problem really quickly when it happens.I was suggested by co-workers to simply check a folder (on a remote computer) every half and hour to see if there are any problems. Instead I created a Python script that checked the folder for me every 30 seconds and if it detects a problem it alerts me straight away. This way I can focus more on my work and when something goes wrong I am notified by the script and this way I can fix the problemĀ  in a few minutes instead of half an hour. It only took me one hour to write the script and it saved hours of time otherwise wasted on failing measurements, so overall it was a huge gain.

Many people nowadays end up working on computers all day long often doing repetitive tasks. If you can teach them programming there are many things they automate. But programming is a skill that takes time to learn well and people are not very keen on learning it, so it makes more sense to teach it in school. I hope that Estonia's experiment will be a success and a inspiration to other countries. Especially European ones which desperately need more competitiveness.

To illustrate my point further. I decided to include the code I wrote below. It may look complicated, but it is merely 1 page, and if you learned programming from 6 years old, you should be able to understand the code below just fine. Even, I guess the future Estonian generation of teenagers will do a better job than I do.

from Tkinter import *
import tkMessageBox
import os
import time

def setup():
    window = Tk()
    window.wm_withdraw()

def alertUser(textMsg):
    alTitle = "IMMEDIATE ATTENTION REQUIRED"
    tkMessageBox.showerror(title=alTitle, message=textMsg)

def monitorDirectory(directory, conditionList):
    overallTime = 60 * 60 * 24 # one day
    while overallTime > 0:
        files = os.listdir(directory)
        for (conditionFunc, alertMsg) in conditionList:
            if conditionFunc(directory, files):
                alertUser(alertMsg)
                break
        overallTime = overallTime - 30
        time.sleep(30)


def smallFiles(directory, listOfFiles):
    numOfFiles = len(listOfFiles)
    if numOfFiles < 20:
        return False
    anomalies = 0
    for fileName in listOfFiles:
        fullPath = os.path.join(directory, fileName)
        stats = os.stat(fullPath)
        if (stats.st_size < 1024):
            anomalies = anomalies + 1
    if (anomalies > 20):
        return True
    return False

def noRecentChanges(directory, listOfFiles):
    numOfFiles = len(listOfFiles)
    if numOfFiles < 20:
        return False
    allAreOld = True
    for fileName in listOfFiles:
        fullPath = os.path.join(directory, fileName)
        stats = os.stat(fullPath)
        if time.time() - stats.st_mtime < 30:
            allAreOld = False
    return allAreOld

def main():
    setup()
    directory = r'pathtofolder'
    conditionList = [(smallFiles, "Excessively small files detected"),
                     (noRecentChanges, "No recent changes")]
    monitorDirectory(directory, conditionList)

if __name__=="__main__":
    main()