I read your post and I have a lot of comments… It is true that mysql
is the most common db layer to use in PHP, but I cannot say that I can
find any limit to what kind of data-source you can use.

PHP is a language written for serving web-pages and it is really good
at it. It is not particularly slow as most service calls in it are
written in C. Sure it might not be the fastest to do calculations in,
but then you should really consider what you are writing. For creating
HTML or for that sake json/xml it is really easy to use.

As for writing good code - you can write bad code in any language.
When I do PHP I do use abstractions and I have written a small class
for shielding myself from the mysql specific code which also provides
me with an easier way of working with the data I get from the
database. For templating I've used several templating mechanisms, the
one from eZPublish being the most elegant one in my opinion, which I
would prefer to have had a similar one in Java any day. (It had a
totall separation of code and markup).

What I really love with PHP is the fact that it plays real nice with
Javascript and JSON. Pick any object in PHP and you can translate it
into json using json_encode and back again using json_decode. If you
write an ajax application and send an object from the server back to
the client it is dead simple. In most cases I find that I do not need
a lot of abstractions. I can do stuff like:

echo json_encode($db->query("select * from people"));

In my abstraction that turns into an array of maps where the columns
in the people table becomes the key with the value entry for the
value.  On the Javascript side I can just do:

  var people = transport.responseJSON;

and I can then access it as an array of maps. This is built into the
language - no need for some extra library that might happen to be able
to serialize your objects…


Scaling… if you write a Java application and use a database, there are
only so much you can do on the application layer before your database
becomes the bottleneck. For scaling up into the enterprise level you
must start partitioning your application/data so the application can
exist in smaller parts that can be served by several computers. PHP
does not differ there at all - it is the same tricks you must use to
scale PHP as well as Java.

That said, not all applications needs to scale to enterprise levels.
Most application does not. For a simple web application PHP is a good
fit, and as you wrote, it is dead simple to deploy as it involves
copying the source to the server and you are set to go. It's also
inexpensive as you can share resources with loads of other users on a
hosting service, as a PHP application does not require 500Mb of memory
to start up :)

PS: I have written enterprise applications for a living in Java and
I've written small applications in PHP for fun and for real use. My
mantra is that one language isn't a golden hammer - use Java or PHP
where it fits.

-- 
You received this message because you are subscribed to the Google Groups "The 
Java Posse" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/javaposse?hl=en.

Reply via email to