[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[computer-go] Meta languages



I have heard of some developers using meta programming. In this case, the
meta program and the generated program may not use the same language.
Timely, as I've been experimenting with using php as a meta language for C++ in the most recent module in my go program. I kept all the parameters I wanted in a php array, and had half a dozen php functions to generate things like constructor initializer list, operator<< (for debug info), operator==, etc. Anything not inside php tags was just plain C++.

I was pleased with the results: I could add new parameters with a couple of lines in one place, instead of having to add lines in half a dozen places. I could also juggle their order, weights, etc. easily.

I found this more effective than using macros, or clever template techniques (e.g. see Modern C++ Design), for meta programming.

An example of another benefit: a genetic algorithm could operate on the PHP array, then recompile, rather than modify in-memory data structures. If this results in faster code, and the speed gain is more than the compile time, then you can process each generation more quickly. Test runs in go tend to be much slower than the compile (e.g. analyze 10,000 pro games, or play against self or another program 100 times, etc.)

Whatever the answer is, there is no better place than this mailing list to
exchange ideas about this subject : what is the best language to program go
Far too much advocacy and emotion involved in that answer, so discussion degenerates into a flame war. For instance everything you wrote about perl was just plain wrong ;-).

Darren
_______________________________________________
computer-go mailing list
computer-go@xxxxxxxxxxxxxxxxx
http://www.computer-go.org/mailman/listinfo/computer-go/