Please join me at my new location bryankyle.com

Tuesday, April 6, 2010

What is Source Code?

Bryan
Hey, I've got a question for you. Can you define source code?
Kyle
Seriously? Source code is source code. What's wrong with you?
Bryan
No, seriously! I'm having a philosophical debate with myself about what source code is and so far I'm losing. I need an outside opinion.
Kyle
Let's see. Hmmmm. Well, I'd say that source code is some human readable form that tells a computer what to do.
Bryan
What do you mean by 'human readable?' Do you mean that it's made of letters and numbers and other things that humans write with?
Kyle
Yeah, human readable, like with words and numbers and stuff.
Bryan
Does it have to make sense to people in order for it to be human readable?'
Kyle
Well, I guess so. To a certain degree anyway. I mean you wouldn't expect just anybody to be able to read it and make sense of it.
Bryan
Ok, so source code is something that's human readable, in the sense that some people may be able to make sense of it, that tells a computer what to do.
Kyle
Yeah, how does that sound?
Bryan
Full of holes!
Kyle
Such as?
Bryan
Well, your definition seems to imply that the human readable form is run directly by a computer. So basically everything that most people think of as 'source code' falls outside of your definition.
Kyle
Like what?
Bryan
How about source code that's run through an interpreter, or a compiler, or a VM!?
Kyle
You know what I mean!
Bryan
Suppose I don't! That's the point of the debate!
Kyle
Alright. Source code is something that's human readable, in the sense that some people may be able to make sense of it, that is processed in some way to produce some output that then tells a computer what to do.
Bryan
That's better. But let's say hypothetically there is a computer that can understand and follow the instructions in the human readable form?
Kyle
I think you're splitting hairs here.
Bryan
Humor me.
Kyle
Fine. Source code is something that's human readable, in the sense that some people may be able to make sense of it, that may be processed in some way to produce some output that then tells a computer what to do, or is interpreted directly by the computer. Satisfied?
Bryan
Not even close. What's this computer you speak of?
Kyle
You're kidding me, right?
Bryan
Nope.
Kyle
A computer, ya know? A thing that runs the source code or the stuff output by the process that processes it.
Bryan
Interesting take on things. Ya know, I seem to recall the word 'computer' has many meanings. Before there were computing machines there were people whose job was to run computations. They were called computers. So far both the machine and the human definition of 'computer' fit your definition of 'source code'.
Kyle
Oh god, what's wrong with you?
Bryan
Pedantry. But I wouldn't say it's something that's wrong with me. Can you define computer for me?
Kyle
...
Kyle
A computer is an electronic device that performs computations.
Bryan
Humans use electrical impulses...
Kyle
ARGH! Fine, an electronic device that you plug in that performs computations.
Bryan
Well, that definition seems rather crude, but I'll accept it just to keep the ball rolling. So what about configuration files? They're human readable and tell a computer what to do. Take emacs for example, its configuration is a bunch of data structures that get interpreted by emacs, well the lisp interpreter part of emacs anyway and are run.
Kyle
What's with you and that stupid editor?
Bryan
What's with you and your stupid editor? What's it called again? 'six?'
Kyle
It's called 'vim' and if you're truely going to be pedantic, VIM in roman numerals is 6000.
Bryan
Whatever, both the fact and question remain.
Kyle
What fact?
Bryan
Your editor sucks.
Kyle
It does not suck, it's awesome. You just don't grok it.
Bryan
Look, why are you arguing with me about text editors? We're supposed to be talking about source code.
Kyle
Very well. I'm not sure that I agree with your assertion that configuration counts as source code. It doesn't tell the computer what to do, it tells a program what to do.
Bryan
That's true, it does tell the program what to do not the computer. But the configuration is still human readable, and processed, and tells the computer what to do. Maybe there's no intermediate form that's produced but I don't see that as being the sole determinant between source code and configuration. If that were the case then source code for an interpreted language would be considered configuration if the interpreter simply walked over the AST.
Kyle
Yeah but, it's configuration. I think you picked a bad example since most people think of lisp as a language, not configuration. What about simple configuration files that are just key-value pairs.
Bryan
I would argue that it could still be considered source code depending, of course, on what's reading and interpreting the configuration. I would say Turing-completeness shouldn't enter the picture at all. Simple configuration or extremely rich configuration doesn't matter. Some people consider HTML and CSS to be source code, but neither are Turing-complete. Conversely what about TeX and PostScript? Both are Turing-complete but nobody considers documents in either to be source code.
Kyle
Look, I'd love to debate with you about what is and isn't source code but I have some work to do that involves writing source code, not just thinking about it.