What is considered source code?

I have seem many posts about technology that lets you change the behavior of a program with changing the code. They claim that changes to production environments can be made as easily as changing a config file. Many times these config files hold import details like database queries.

My question is, what is considered source code?

Obviously, anything written in a programming language and compiled is source code. But what about non-compiled code?

Are SQL statements considered source code? What if they are in a config file?

Should the database structure be considered "source code"? What about the stored procedures it contains?

How about a config file that makes minor changes the way the program works? For example, using a different factory class based on a flag.

What if the changes are major? For example, one that injects code in the fashion used in Aspect Oriented Programming.

This is important because, in the real world, all changes to source code need to be documented and tested.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Source Code + Whatever = Configuration

I think the term "configuration management" was meant to include everything. All of it needs to be tracked and tested.

Instead of thinking "source code needs to be tested" and "is X source code?", maybe "does X need to be tested" would work better.

Depends on the point of view

For a compiler, source code is the string of characters which express a program in some language. The output of the compiler may be "object code"--corresponding to the instruction set of a machine (real or virtual), or it may be the source code for another compiler. Of course, it can be argued that a .class file is merely "source" for a JVM--one can even argue that an .exe is "source code" for the x86 instruction set.

Probably a more useful definition, and one which matters in the domain of configuration management, is that source code is whatever is generated (in whole or in part) by the intellectual activities of humans. Stuff that can be automagically regenerated (by compiling, for example), is not source. In this case, program text which is the output of a metaprogramming tool or process, is NOT source. Wizard-generated skeletons, which are filled in by humans, are source--re-running the wizard may clobber the human's changes. A binary file, which comes from a third party (or otherwise is not buildable from other sources) may be considered "source" in this view.

Whatever you call it...

If an artifact is created by a person then:

It should be in a repository, supporting at minimum versioning, branching, and tagging.

It should be reviewed.

It should be tested.

It should be documented.

(requirements for review, testing, and documentation may vary prer product)

If it is created by a machine then:

It should not be in a repository.

It should not reside in the same file tree as any human-generated artifact

It should be cleanly regeneratable with a single build command and no other human intervention.

It should should be destroyed and regenerated on every complete build.

Why be tied to a definition?

This is important because, in the real world, all changes to source code need to be documented and tested.

Surely in the real world you document and test what you need to document and test in order to achieve the goals you are trying to achieve, eg. keep a smoothly running department. If documenting X makes life easier for everyone then document X. If it doesn't, don't. Surely the definition of "source code" is irrelevant. Indeed, a type of unit that needs testing and documenting in project A might not need testing and documenting in project B so definitions get you nowhere.

Here's a slightly more theore

Here's a slightly more theoretical perspective on this issue.

Source Code

My question is, what is considered source code?

"Source code for X" is the set of strings which are accepted by a given programming language specification X, more generally, by a translator X. A translator translates from a source language to a target language. In a compiler or interpreter, the source language is a subset of the syntax, and the target language is (usually, eventually) machine code. It is called source code because a source string is a code for a string in the target language.

Asking if something is source code without specifying a particular X is meaningless, as I can always invent some X which accepts it.

But this is not the question you want to ask. What you want to ask is, "What is a programming language?" Does it need to be Turing-complete? Does any program which takes input qualify as a programming language implementation? (Banality warning:) Does it need to have an assignment statement? etc.

I have seem many posts about technology that lets you change the behavior of a program with[out] changing the code.

Yes, it's remarkable new technology called I/O.

Are SQL statements considered source code?

Of course. They are SQL source code.

What if they are in a config file?

The property of being source code for translator X does not depend on where you are stored. Similarly, the property of being an integer does not depend on whether you are notated in base 10, base 2 or base 117.

How about a config file that makes minor changes the way the program works? For example, using a different factory class based on a flag.

A config file ipso facto contains source code for a configuration language, which may be some custom little language defined implicitly by the application which reads it.

What if the changes are major? For example, one that injects code in the fashion used in Aspect Oriented Programming.

AOP code is source code for an AOP language, which may happen to have a syntax which is a superset of some other language.

This is important because, in the real world, all changes to source code need to be documented and tested.

First, I think you probably mean "the commercial world", unless you think I am living in a fantasy.

Second, I think you have it backwards. But if you think something is source code (partially) by virtue of needing to be documented and tested, then your definition of source code is at variance with my own.

Source Code

First, I think you probably mean "the commercial world", unless you think I am living in a fantasy.

No offense was intended. The term is generally understood to mean "Anywhere outside a university." among the people I normally converse with.

I don't think "commercial world" is a fair description, as there are a lot of non-commercial applications that need as rigorous testing as commercial applications.

Second, I think you have it backwards. But if you think something is source code (partially) by virtue of needing to be documented and tested, then your definition of source code is at variance with my own.

My definition is admittedly flawed, hence the original post.

I'm sure you didn't mean to be offensive

I'm sure you didn't mean to be offensive...

But you really should re-examine your prejudices from time to time. I think many people who work in universities and other academic institutions might take offense to being excluded from "the real world" (although of course others might glory in the idea).

In any event, it is worth reflecting on the fact that some of the world's most widely-used and reliable software was developed in academic environments. There are few commercial verification exercises which compare to having to defend a thesis explaining why a particular algorithm works.

My experience (which is basically in the non-academic world) certainly does not support the theory that commercial/non-academic software is rigorously documented and tested. To be sure, some of it is. But a lot of it isn't.

And, just to drop my personal prejudices on the table, when I read the original posting "in the real world, all changes to source code need to be documented and tested", my first thought was something like, "yeah, right, that's the sort of real world run by PHBs who use arbitrary categories like 'source code' in order to make random rules which let them feel like they're in control of something they don't have a clue about."

Finally, if you want a system to be reliable, you need change control on everything. Replacing a piece of hardware or upgrading your OS version requires just as comprehensive a set of tests as correcting a grammatical error in a source code comment. And just the other day I saw a website collapse because someone changed the name of a file.

Geekisms

Thank you both for acknowledging my petty whining.

I didn't take offense, and I know what the author meant, but I sometimes get a bit miffed at geekisms like these. (Another one I hate is, "Information wants to be free.") We all use them (admittedly, myself sometimes included), and we think that when we use them we are being consciously hyperbolic, but... are we really? Say something enough and you start to believe it.

Just say no.

What is a programming language

This was debated on Gamedev.net recently. Warning: The quality of posts are significantly more varied than here.