Hudzilla.org - the homepage of Paul Hudson
Contents > Alternative PHP uses > Making your own language Wish List | Report Bug | About Me ]

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.





<< 21.5 Making your own language   21.5.2 The elements of a compiler >>
Table of Contents
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!



Top-right shadow
 
Bottom-left shadow Bottom shadow

Comments from other readers
rockentara@hotmail.com - 16 Oct 2008

sucked!!!!!!!!!!!!
notonebit of helpto me at all.

FarazAli at gmail dot com - 16 Oct 2008

Another one of the better uses for this tutorial would be to create an SQL parser. Just felt like sharing

-----
http://txtsql.sf.net



Add comment
Please note that by posting a comment here you are committing it to the public domain. This is important so that others can make use of your code themselves, and also so that I can incorporate helpful notes directly into the main text. Comments are limited to 2000 characters in length.

If you are reporting an error in the content, please tell me directly.

Your name/email address:
Your comment:
 
Now, in order to verify that you're a real person, please answer this simple question: what is ten plus seven?
The answer is:
(please write in
numbers, eg 19)


Top-right shadow
 
Bottom-left shadow Bottom shadow