Though if you spend enough time your probably going to be reimplementing some type of http://en.wikipedia.org/wiki/Genetic_programming
Why Forth?
I doubt it is possible to solve "serious" problems with this approach but there is a whole class of work that is solved by mediocre programmers with copy pasting. We strive to automate other jobs, why not these? :)
We should come up with some sort of Turing like test for this. Like some small simple Wordpress job.
It's not really, so far at least, suitable for replacing work done by mediocre programmers, because the setup cost is so high: The hard work is defining the fitness function and symbol set and other factors, and to pay off this requires problems where it is easier to recognise a good result than writing the algorithm to achieve it.
E.g. a sort function does not fall in that space: Once you've specified how you want your data sorted, you've usually done most of the work.
But once you've specified the fitness function sufficiently well, and figured out the inputs etc., there are a lot of other search algorithms that often will perform better.
I'm very fascinated by GP too (though I've never had time to truly delve into it), but without combining it with mechanisms to take a large chunk of the specification work out of the equation, it remains confined to fairly specific types of problems.
If you want to get paid to play around with this thought, my contact info is in my HN profile.
: fizzbuzzable dup 3 mod 0= swap 5 mod 0= or ;
There's a repeated pattern here, so we can textually excise it and make it into a named word without changing any of the structure of the surrounding program: : /? mod 0= ;
: fizzbuzzable dup 3 /? swap 5 /? or ;
Or we could break it down a different way by excising different fragments: : /3? 3 mod 0= ;
: /5? 5 mod 0= ;
: fizzbuzzable dup /3? swap /5? or ;
(Obviously not the best real-world example, but hopefully it illustrates the idea.)Java bytecode, on the other hand, uses local variable references and activation records. This means that inlining or breaking out a procedure has pretty much the same problems as inlining or breaking out a procedure manually in C- variable names may clash, new arguments have to be threaded around, parts of expressions may need to be stored in temporary variables, etc. the JVM additionally enforces many constraints on "well-formed" bytecode at class load time[1] which could make it hard to generate valid programs by chance. Overall, Trying to "harvest" java bytecode from the wild could be useful, but I think that would be much harder than it sounds at first.
[1] http://docs.oracle.com/javase/specs/jvms/se7/html/jvms-4.htm... (and below)
8000 papers so far:
http://www.amazon.co.uk/Genetic-Programming-Introduction-Art...
Yeah, I can see why using Brainfuck is a good idea. You're basically restricting yourself to generating only the programs that compile rather than wasting time on gibberish.
Modified it a bit to run in parallel. I guess I'll leave it on for couple hours and see if it gets anywhere.
current output:
1363637914 2013-03-18 22:18:34.118051 +0200 EET Stats: 0/53659699 (0%) good/tries, 223559.91320127275 ops/secYou can tweak the range of the number of generated characters, the length of Markov chains, the minimum main body clauses, etc. With my original config it should give you a valid program every hour~few hours or so.
After running it overnight (it was attempting 40+ programs per second), the very best program looked something like this:
Next step I wanna try is to use tokens of the language instead of series of random characters.Edit: Here's the code. https://gist.github.com/shurcooL/df2c8339ada1997606b3 It should run out of the box if your Go is installed in /usr/local/go. I just changed it to generate a temp dir in the working dir (prefixed with "Gen-"), so you can delete it afterwards (previously it relied on a "Gen" folder to already exist). Right now it's configured to have quite difficult verification conditions, so it generates valid programs quite infrequently (despite trying 5000+ programs per second on my machine).