Do Androids Dream of Electric Sheep?
There was a snarky comment recently wondering what language I dream in.
Not so snarky, actually.
If you were to ask my lady what language I dream in, she would be likely to answer, “I don’t know, but he types on my back in his sleep.”
Yes, I program in my sleep. I code while in the shower. I solve problems, regardless of what I’m doing.
I started programming experience with “procedural programming”. That is to say, a series of procedures that call each other and return results.
As part of that training, I quickly realized that any problem in programming could be broken into smaller and smaller “functions” or “procedures” until you were at the single machine instruction level.
For me, programming is broken into developing a series of black boxes that are connected to produce results.
If you look at a problem, “I want to layout a line of text on a screen with word wrapping”, it can be broken into smaller questions.
“I want to know the number of characters that will fit on the remainder of this line.” When black boxing, you put a function or procedure in place and assume it works. It doesn’t matter if it does or not. You can even fake it. Instead of actually doing a calculation, it can just return a constant.
Now that I’ve made this “magic” black box, I use it to solve the harder problem. Once that is solved, I can address the black box and make it work correctly.
I combine this with what I call “railroad structuring”.
Suppose that the final step in a black box is to draw a text on the screen. You are given a data structure that contains strings of text with markup. The data structure imparts formatting on the text as well.
You could write code that looks at the data structure and “does the right thing”. You would then end up with dozens of pieces of code, all that are supposed to do “the right thing”. Needless to say, this is seldom the case, at least a few of those places will do the wrong thing. And if you fix it in one place, you have to fix it in all other places.
So I create the end game, “draw the string ‘text’ at ‘position’ using ‘formatting'”. The rest of the code works to create “text”, “position” and “formatting”.
if the original text had markup in it, then that little section would modify text and create formatting to match the requirements of the markup. After that is done, we have ‘text’, ‘position’ and ‘formatting’. At each step, the result is always ‘text’, ‘position’ and ‘formatting’.
So, when somebody asks, “What language do you dream in?” The answer is, “my programming language.”
Because all computer languages look the same to me, but for syntax, it doesn’t matter. I always know what I want the language to do. I might have to look up the syntax for a particular thing, but that’s never an issue.
As an example:
for i in range(0,9):
print(i)
and
for (i=0; i<10; i++) {
fprintf("%d", i);
}
Do the same thing, I think. Because ‘range()’ is python and I’m never sure about it, I’ll look it up to find out if it gives me 0 through 8 or 0 through 9.
Still, the logic is the same and correct for me.