21.5.1 Why make your own language?This is NOT the latest copy of this book; click here for the latest version.
At the International PHP Conference 2001, Sterling Hughes was given a lecture on PHP Internals where he mentioned that, using the new filters in Apache 2, you could run a PHP script, send the output to TCL, and finally parse the end result with Perl. One member of the audience piped up with the question, "why would you want to?", to which Sterling's answer was "because it's cool". So, in answer to the question, "why make your own language using PHP?", the obvious answer is because it's cool .
There are reasons too. Making your own language is a popular Unix pastime that fulfils one of the key tenets of Unix programming: write programs to write programs wherever possible. This is rule 14 of 18 listed in Eric Raymond's book, "The Art of Unix Programming", and it is certainly a rule worth keeping mind. You see, if you have to regularly write code to perform approximately the same task, you are better off inventing your own mini-language that lets you abstract the problem - it is faster and easier in the long term, and also less prone to error. Although the language we start to create in the following chapters is general purpose, you could write your own specific language for anything - controlling household devices, calculating pi to the n,000,000,000,000th place, or even modelling the behaviour of cats.
|
Want to see this stuff in print? PHP in a Nutshell takes the core topics covered here, adds in thousands of edits from the editorial team and myself, and combines them to make an unbeatable reference for PHP programmers at all levels.
My latest book has hundreds more tips on how to use PHP, Apache, and MySQL, plus Perl, Python, shell scripts, performance tuning, and more!
|