What concepts are important to learn when considering writing a program that can "think" about itself?
By "think", I mean software that can look at itself and improve over time.
How easy is it to write a program that can introspect at a basic level?
What concepts are important to learn when considering writing a program that can "think" about itself?
By "think", I mean software that can look at itself and improve over time.
How easy is it to write a program that can introspect at a basic level?
Fairly easily. If you consider a configuration as part of a program, then you can simply change it, and thus it has changed itself.
Really, your questions is completely vague and arguably useless. I suggest you consider a real goal; something you actually want to do, and then do that. To implement some AI you don't want to modify the program itself (i.e. change lines of code). You only want to add new behaviours, and so on. It's a conceptual thing.
There are languages that expose the program to itself as a data structure, such as Lisp, and allow you to write code that manipulates this data structure, to dynamically modify the program. This is why Lisp is sometimes used for AI programming.
You can do similar things, maybe not as straightforward though, using C#'s emit and reflection capabilities.
Thinking is a very abstract term and something that we still haven't understood properly. That said, the problem you may be trying to crack encompasses recreating human intelligence and there is plenty of research work and materials you can find on the current state of the art.
If, however, you have a specific goal that you're trying to achieve and you can objectively define and measure "improvement", then you could use some of the some AI techniques to make progress. For example, it could be code that runs faster, or is shorter in size, etc. You can find related work in the field over here.
Many languages offer Reflection capabilities that should allow you to modify the program's structure from within.
You're basically talking about the hypothetical point in future when we reach Technological Singularity. A software that can improve itself will mark a turning point in history, because that feature will create a feedback loop, and artificial intelligence will start to outsmart everyone of us very fast, rendering us plain human beings dumb and useless.
So do you really want to be the guy who does that break through and are you going to take all the burden of responsibility for that?
;-)
If "if" and "else" were commands rather than keywords, then something a program could do to improve itself would be to log which branches of a conditional got executed most frequently, and then make sure that the most frequent conditions got evaluated first. For this you might need a command language, such as Tcl.
The ability of the software to improve itself will be dependent on two things:
In practice, profiling libraries and genetic algorithms would probably be good starting places for programs where people are doing these kinds of tasks.
A language like lisp that is designed to read and write the structures which make up its own executable code makes this sort of thing much easier, and much more robust, though you can emulate this behavior in other languages with liberal use of arrays of function pointers and conditionals.
The most important thing to consider is what problem you're trying to solve. The second is how you represent knowledge. The third is how you choose to find improvements. Let's take these steps one at a time:
What you're trying to solve
Running these simulations usually requires a purpose. This purpose something to judge against: an evaluation function that says how close you are to your goal. Without a goal, a simulation can manipulate itself... but it would just put out random material.
How you represent knowledge
If you're trying to reach a goal, then the code needs two parts: the goal-oriented material, which doesn't change, and the learning material, which does change. Some use a language like LISP, where data and code are of the same format. I created a simple virtual machine with the functions that I needed, putting knowledge in an assembly language. There are myriads of correct answers, but you need to choose.
How you find improvements The most common way to examine and upgrade code is through a genetic algorithm strategy. But other hill-climbing algorithms and optimization algorithms work well too. I've used genetic algorithms, simulated annealing, and neural networks in metaprogramming experiments.