Programming for the Web.
Programming for the web today, IMHO is far harder than it should be
The problem
PHP and ASP have done wonderful things to improving the interactivity on the web. However, as anyone who has done serious programming in PHP will tell you, it’s a nasty language to use for writing “applications.” Mixing HTML and code sounds like a great idea, when you mostly have HTML and just a hint of code, but when you have a whole chunk of code and just a hint of HTML then it’s a pain. Most php starts with “>?” and goes down hill from there.
PHP has had a whole slew of bad design decisions. Registering global variables being obvious amongst them, but less well known are issues like form posting and the like. PHP doesn’t treat HTML as a “First class” object, you can’t pass around HTML fragments and process them easily. This is surprising as the language is designed to deal with HTML! PHP in general doesn’t even make things like talking to a database easy.
<
PHP allows for people to use classes, and OOP, however it’s “built in” libraries are all done in the functional style. (Mostly, I suspect, due to the fact that people are just wrapping the C API’s.) PHP 5 promises to resolve a lot of these issues, and I hope it will
So, I propose, the world needs yet-another language to fill this space
The requirements
- Must be simple
The language must be easy for nearly-programmers to write in. C may be a powerful language, but, in the end, people just want the job done.
- Should be treat HTML as a first class object
You should be able to pass around HTML fragments, and do things like iterate over them.
- Generated HTML should validate
It should take significant effort to generate broken HTML, or, ideally be impossible. The engine should be able to use browser detection to serve up the best possible HTML for your browser automatically.
- Should be easily “Themable” or “Skinnable”.
Content != Display.
The Solution
I Propose (With help from Jon/Matthias) that we create a new engine to replace PHP. It should use Javascript as the programming language, and you should pass around a DOM of the page you are trying to construct. You should be able to provide an XSLT filter to “skin” your page. (And if the browser supports it, this could be done on the browser side).
I believe that you want to use Javascript, as the language is mature, it’s modern and easy to write and to find documentation about. It’s was designed to deal with the web (admittidly from the reverse point of view — on the client) and the skills learnt on the server side can be used to make client side scripts as well.
The DOM is a well documented, and well understood way of handing around HTML/XML document fragments which is advantagous as outlined above.
And XSLT is well a good idea, it’s a pain to have to go and change all your code to add a new stylesheet, particularly if you are trying to integrate multiple, unrelated projects (phpMyAdmin + phpWiki + cacti + a few index pages to glue it all together makes a great internal website, but is a pain to theme so it all looks the same).