I am (or was) a programmer, and I've taught computer programming at college.
In my experience, the people who had the most difficulty learning to program were those people whose idea of how a computer worked differed from reality. People who had absolutely no idea seemed to catch on easier. As an IT person, this may not apply to you, but give it a little thought.
A computer program is, at one level, a series of instructions written in a particular language. The language is quite specific, and is designed for an abstract machine (I'm not talking about various assembly languages). The instructions manipulate the state of the abstract machine.
This abstract machine may in fact be the data set of the program. As an example, let's say we have a machine that compares two numbers, and tells us which is the greater.
We need to label the numbers, because for the most part we won't be referring to them by their values. Kind of like putting each number in its own box and then referring to 'the number in box A' and 'the number in box B'.
Our program then looks something like:
If 'the number in box A' is greater than 'the number in box B'
Open box A and read the number out
Otherwise
Open box B and read the number out
I hope I'm not insulting your intelligence with such a trivial example, but your statement about 'a complete mental blank' makes me think that the problem you have relates to a fundamental issue of understanding what an abstract computing machine is.
It may help to play around with the kind of technique I demonstrated above. Here's another one. Let's say you want to determine how many days sylvia brown needs to work in order to buy a ferrari.
We need to write down what we know, the pertinent information.
Sylvia does readings. Each reading takes time. She can do a number of readings in a day. A ferrari has a price.
Let's figure out a formula, or algorithm.
We need to work out how many readings it will take to make up the cost of the Ferrari, and then work out how many days she has to work to do that many readings.
Here's our first formula:
Cost_of_ferrari / price_of_a_reading = number_of_required_readings
We're not programming yet, just working out our formulas.
Our next formula tells us how many readings she can do in a day:
Hours_in_a_work_day / duration_of_a_reading = number_of_readings_per_day
OK, we have our formulas. We could simplify things slightly by using constants. For example, a constant could be that her readings go for half an hour, and that this will never change, or that they cost $750 and that will never change, or that a Ferrari costs $200,000, and that will never change.
Alternatively, we can use variables (numbers in boxes), and the program will ask for the current value of those things.
Now, let's look at our language. It's a simple language for a simple computer. Our computer can only do a few things. It can display text on the screen. It can ask the user to type some information in, and it can do some simple calculations. It has a little memory, consisting of boxes that it can store numbers in. It can label the boxes.
Now we're ready to code!
What's our strategy?
We need the program to ask the user for some information; how much does a ferrari cost, how much does Sylvia charge, etc.
The program then has to do the calculations as per our formulae.
It then has to display the result.
The keywords of our language are:
GET, which flashes a little cursor and waits for the user to type something in.
DISPLAY, which displays some text on the screen
Any lines in our program that start with
// are comments, the computer ignores the rest of the line, it's just for humans to read
Ok, here's our program:
Code:
DISPLAY "Hello, let's work out how long it will take Sylvia to earn enough money to buy a Ferrari."
DISPLAY "Tell me, how much is a Ferrari these days?"
// this next line gets a number from the user and stores it in a little box labelled 'ferrari_cost'
GET ferrari_cost
DISPLAY "Thanks, now tell me... How much does Sylvia charge for a reading?"
GET reading_cost
DISPLAY "OK, and how long (in hours) does a reading go for?"
GET reading_duration
DISPLAY "How many hours a day do you reckon she can work?"
GET hours_worked_per_day
DISPLAY "OK Thanks. Let me think for a minute"
// now let's use one of our formulas!
readings_per_day = hours_worked_per_day / reading_duration
// we stored the answer in a box labelled 'readings_per_day'
//
// ok now let's use the other formula
//
required_readings = ferrari_cost / reading_cost
number_of_days = required_readings / readings_per_day
//
// we can give this info to the user now
//
DISPLAY "Sylvia needs to do 'required_readings' in order to earn enough money to buy a Ferrari. At 'readings_per_day' readings per day, it will take her 'number_of_days' days to accomplish that."
// In the above instruction, the variable names in single quotes have their values displayed. It's like the DISPLAY instruction opens the boxes with those labels and reads the numbers out.
DISPLAY "Not bad, huh?"
Let's add some conditionals in there. These allow our program to choose which action to take based on certain criteria. To do this we need to add a couple of keywords to our language:
IF, which tests a condition to see if it's true or not, and indicates what to do if the condition is true
ELSE, which indicates what to do if the condition was false
ENDIF, which indicates that the program can go back to executign instructions in order.
Here's our updated program:
Code:
DISPLAY "Hello, let's work out how long it will take Sylvia to earn enough money to buy a Ferrari."
DISPLAY "Tell me, how much is a Ferrari these days?"
// this next line gets a number from the user and stores it in a little box labelled 'ferrari_cost'
GET ferrari_cost
IF ferrari_cost < 30000
DISPLAY "I said Ferrari, not Mazda"
ENDIF
DISPLAY "Thanks, now tell me... How much does Sylvia charge for a reading?"
GET reading_cost
IF reading_cost > 700
DISPLAY "Man, I'm in the wrong line of work"
ELSE
DISPLAY "I heard it was more than that"
ENDIF
DISPLAY "OK, and how long (in hours) does a reading go for?"
GET reading_duration
DISPLAY "How many hours a day do you reckon she can work?"
GET hours_worked_per_day
IF hours_worked_per_day > 8
DISPLAY "I somehow doubt that"
ENDIF
DISPLAY "OK Thanks. Let me think for a minute"
// now let's use one of our formulas!
readings_per_day = hours_worked_per_day / reading_duration
// we stored the answer in a box labelled 'readings_per_day'
//
// ok now let's use the other formula
//
required_readings = ferrari_cost / reading_cost
number_of_days = required_readings / readings_per_day
//
// we can give this info to the user now
//
DISPLAY "Sylvia needs to do 'required_readings' in order to earn enough money to buy a Ferrari. At 'readings_per_day' readings per day, it will take her 'number_of_days' days to accomplish that."
DISPLAY "Not bad, huh?"
And there you have it. You'll be writing Linux device drivers in no time.
PS There may be some errors! I apologise in advance...