Replies inline. On Apr 28, 10:16 am, Knubo <[email protected]> wrote: > 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.
There's no limit, but there's no database abstraction layer either, *AND* each individual database package uses wildly different functions with different conventions in naming and e.g. parameter ordering. If you really want this crappy model, you can do so, in java, by working on either raw JDBC or very lightly wrapped JDBC and writing raw queries. At least you'll find that things like avoiding sql injection attacks is done the same way regardless of underlying platform. Technically there are db independent layers on top of PHP but this eats away at the entire point of PHP (jump right in, whatever works, patch it together, and don't give a crap about code cleanliness), and as a result isn't all that popular out in the wild. Most people just go with mysql for everything and in that way 'normalize' their DB work. This is, rather obviously, crap, compared to wicket, grails, play, rails, django, spring, etc. > > 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. It's 2010, not 1992. The argument "It is written in C, therefore it must be fast" is ludicrous. Define "it is really good at it", because unlike you I gave quite a list of reasons why PHP isn't very good at it. Unless perhaps you've got some credentials as to why your opinion should be taken by itself as particularly convincing, I don't see why just saying "But it is good!" is going to convince anyone. > 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. PHP is easy to create XML? Er, no, it isn't. XML isn't PHP, and 'writing' XML by outputting raw strings, while a common pastime for many programmers, is no more or less easy in PHP than in other languages, and, as with most PHP things, isn't really the right way to do it. > > As for writing good code - you can write bad code in any language. Sure, but PHP makes it particularly easy to write bad code. More to the point, perhaps, the PHP community is built on horrible code practices. If you google around for just about any example on how to do X in PHP, in general the answer is completely insane. Java doesn't fare particularly well here, but for such a popular language it really doesn't do so bad. The true shine of fantastic communities can be found amongst the clojure, scala, and haskell crowd, but there's a rather obvious correlation between popularity and community quality. Nevertheless, PHP and java are comparable in popularity and yet java's community is orders of magnitude more interested in 'the right way to do it' vs. the PHP model of 'Hey, it works for me'. See PHP screwing up backwards compatibility in a point release, being completely broken in turkey due to stupid case sensitivity rules in regards to PHP's case insensitive function names, the slap-dash API design that has zero consistency, 'magic includes', and many other head scratchers. > 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. I don't think rolling your own db layer for every project jibes with your earlier assertion that PHP "is really good at [the web]". > 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). You and maybe 1% of the PHP community have seen this particular light. Again, java isn't the shining beacon of perfection here either, but it fares far better than the PHP community. Also, the more you introduce stuff like this, the worse PHP's ideosyncracies become. For example, by <%including%> such a massive amount of library code ON EVERY PAGE, you're either going to be slow as molasses or you need to invest in fancy HiPHoP or Zend framework stuff, which is like java's much maligned compile step, except worse. > > 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. You can do the exact same thing in java, of course. Unfortunately, not all frameworks include a particularly well designed JSON library (which is somewhat more work for java, as JSON is focussed on dynamically typed languages and java isn't, but, it's a library. Design it well once, problem solved forever). > If you > write an ajax application and send an object from the server back to > the client it is dead simple. In java, too. > is that one language isn't a golden hammer - use Java or PHP > where it fits. Bad mantra. Becoming an expert in any one language is so incredibly difficult, and takes so much maintainance (continuously working with it so you don't forget and you keep up to date with new libraries and developments) that, time-wise and code quality-wise you're far better off hammering that nail into place instead of using a screwdriver. You SHOULD investigate and play around with new languages, partly so that, if the once-in-a-decade moment comes along that you should move to a new main programming language you've got a clue, but mostly so you can take that language's good things and apply this knowledge to your hammer. In other words, play around with Scala or Haskell and get some familiarity with a more functional approach which, even in java which makes the functional approach rather wordy, is sometimes just the better way to do it. This also explains why no java programmer should ever bother with PHP. The only lessons you're ever going to learn there are bad ones, and it's rather obvious it's not going to be the next big thing either. -- 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.
