Hi at my school in my engineering computations class we were talking about programming a replica of the human mind. The problem was brought up that the computer will only run until the it runs out of code to read. My question is this. Is there a computing language that has the ability to write self sustaining code during execution? That is generate code dynamically based on parameters given at the start of the program? Would this be hard to implement?
If your still confused imagine you are riding the slope of a function of nth parameters and you do not know what the explicit function is but you have incite of what the gradient is 1 unit forward and back of your position.
Since we only know two points of the gradient in total space, writing loops initializing the start and end points will not work. However if we only initialize the beginning point and tell the computer to calculate the gradient of the line at the forward and backward positions in space we can then estimate the gradient of the line at the next point and compare this gradient to the gradient of the previous point and "guess" what the next value of the gradient would be. For this to happen the computer would have to make a choice of the best method to compare the two slopes and instead of explicitly writing if-then checks and outcomes we only write one if statement which is "the method that has the higher presidency is most likely to be the best method to choose". Logically at the start of the program we have given the computer starter methods to solve this problem and therefore the computer executes all of them and decides which is the best choice for this step. It then logs this choice out of the lists as having a higher success rate over the other methods and takes that into account at the next step. If we could then find a way for the computer to know if a choice it made is wrong we could tell it to backtrack and try again.
What do you guys think?
Coding Evolution
Coding Evolution
Last edited by dhnhatthe on Thu Nov 19, 2015 9:43 am, edited 1 time in total.
Re: Coding Evolution
Code is just data and any language can modify data. Self-modifying code means you have to get that data interpreted again (or compiled and run again which is pretty much the same in this context). The easiest languages to do this in are interpreted languages - especially in Lisp this is used a lot.
But you already start with a wrong premise. Programs don't stop because they run out of code. You can loop endlessly - this is pretty much what nearly every application you are using does. For example your web-browser. It doesn't stop at some point of time because it runs out of code. It runs until someone quits it. Or it crashes due a bug. Or someone puts out the power. Aside from that it could run to the end of times.
And that's likely also how your brain works. You don't have one endless thought that you think on and one from birth until you die. Instead your brain probably hangs around in an endless loop and once in a while starts processes which lead to a bit of thinking.
By the way self-modifying code is used already in some artificial intelligence algorithms. Genetic programming especially. And it's also important in a philosophical context. Because computers are Turing complete - and Turing complete means more or less it can run *any* math function out there as long as it has enough memory - and because programs can overwrite themselves it means - a program can rewrite itself to be any other program possible. Like the monkeys typing Shakespeare thing it might take a while.
But you already start with a wrong premise. Programs don't stop because they run out of code. You can loop endlessly - this is pretty much what nearly every application you are using does. For example your web-browser. It doesn't stop at some point of time because it runs out of code. It runs until someone quits it. Or it crashes due a bug. Or someone puts out the power. Aside from that it could run to the end of times.
And that's likely also how your brain works. You don't have one endless thought that you think on and one from birth until you die. Instead your brain probably hangs around in an endless loop and once in a while starts processes which lead to a bit of thinking.
By the way self-modifying code is used already in some artificial intelligence algorithms. Genetic programming especially. And it's also important in a philosophical context. Because computers are Turing complete - and Turing complete means more or less it can run *any* math function out there as long as it has enough memory - and because programs can overwrite themselves it means - a program can rewrite itself to be any other program possible. Like the monkeys typing Shakespeare thing it might take a while.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
-
- Competition winner
- Posts: 688
- Joined: Mon Sep 10, 2012 8:51 am
Re: Coding Evolution
^ What he said. O_O
Or maybe the internal clock resets when the program depends on it. Hurray Unix end?
Since I insist on sticking my foot in my mouth at least once, let me add: I've found that it's faster just writing an algorithm dedicated to a job than trying to do, what is comparably, an inefficient AI, which will inevitably outdated for one reason or another in light of newer discoveries and tech. Not to say it isn't cool, though what is top-of-the-line-tech today will inevitably be outdated tomorrow, so every cool AI you come up with will leave you dissatisfied in the wake of someone else's advances.
There are some other tricky problems to overcome. Obviously, you can't rewrite the main while loop. You also have to decide which code can't be changed, since obviously, even if you could let it rewrite nearly everything, you don't want your program to erase itself out of existence (perhaps due to "testing" an optimization).
One way to do it without requiring a special interpreted language would be to write two programs: One to do all the rewriting in light of feedback and the other to be the final "product".
But I'm just tossing ideas out there.
Or maybe the internal clock resets when the program depends on it. Hurray Unix end?
Since I insist on sticking my foot in my mouth at least once, let me add: I've found that it's faster just writing an algorithm dedicated to a job than trying to do, what is comparably, an inefficient AI, which will inevitably outdated for one reason or another in light of newer discoveries and tech. Not to say it isn't cool, though what is top-of-the-line-tech today will inevitably be outdated tomorrow, so every cool AI you come up with will leave you dissatisfied in the wake of someone else's advances.
There are some other tricky problems to overcome. Obviously, you can't rewrite the main while loop. You also have to decide which code can't be changed, since obviously, even if you could let it rewrite nearly everything, you don't want your program to erase itself out of existence (perhaps due to "testing" an optimization).
One way to do it without requiring a special interpreted language would be to write two programs: One to do all the rewriting in light of feedback and the other to be the final "product".
But I'm just tossing ideas out there.
-
- Posts: 1010
- Joined: Mon Oct 24, 2011 10:03 pm
- Location: 0x45 61 72 74 68 2c 20 69 6e 20 74 68 65 20 73 6f 6c 20 73 79 73 74 65 6d
Re: Coding Evolution
Exactly what CuteAlien said, now as for self modifying code; polymorphism does this to an extent but template metaprograming is a much better example, metaprogramming is the act of writing code that writes code; which to me sounds exactly like what you're looking for.
Incidentally template metaprogramming is turing complete (and it's merely a reasonably small subset of C++), technically though you could write self modifying code using functional programming so long the language is turing complete, the only real issue is not if but how; that's up to you to figure out though (I'm no AI guru, I couldn't help you even if I tried).
"Metaprogramming is the writing of computer programs with the ability to treat programs as their data. It means that a program could be designed to read, generate, analyse or transform other programs, and even modify itself while running."
That's wikipedias description of metaprogramming, regardless metaprogramming isn't the only solution, it's merely one of the more obvious ones.
Incidentally template metaprogramming is turing complete (and it's merely a reasonably small subset of C++), technically though you could write self modifying code using functional programming so long the language is turing complete, the only real issue is not if but how; that's up to you to figure out though (I'm no AI guru, I couldn't help you even if I tried).
"Metaprogramming is the writing of computer programs with the ability to treat programs as their data. It means that a program could be designed to read, generate, analyse or transform other programs, and even modify itself while running."
That's wikipedias description of metaprogramming, regardless metaprogramming isn't the only solution, it's merely one of the more obvious ones.
"this is not the bottleneck you are looking for"
Re: Coding Evolution
I think the easiest way to write a self-generating program would be to have the main program generate code in a new file, run the compiler on it, then kick it off as a new process from the main program. Really interesting idea. I've thought about this before... skynet poop lol.
Re: Coding Evolution
https://www.youtube.com/watch?v=92WHN-pAFCs Perhaps you could take a look at the "halting problem" it esentially tells that there is no machine that can do everything.
"There is nothing truly useless, it always serves as a bad example". Arthur A. Schmitt