PHP is a very slow light layer that translates SQL into HTML. This explains the myth that PHP is 'fast'. No it isn't:
It's dead slow. However, a slow interpret across a script file is simply a drop in the bucket compared to a serious SQL query. The DB is the bottleneck, not the lightweight rewrite of the result into HTML. Furthermore, by letting the code layer ONLY statelessly transmute the result of an SQL query, scalability is simple: 'just' scale the database. Most java web frameworks aren't written for this model, because it's a shitty model if your name is not 'Wikipedia'. There's absolutely nothing stopping you from writing your java web app the same way - parse the incoming form data + URL, run some queries into JPA, and rewrite these into HTML. As a general rule java is in fact a lot better at this, and ruby, groovy, and scala are _even_ better at this (because unlike java those languages are a bit more at home in ad-hoc DSL libraries) - after all, unlike PHP you've got database independence and nice templating tools. But none of this matters to sites like wikipedia. The whole point of wikipedia is turning a web request into an SQL query + a transformation of that to HTML. There's simply nothing more to do. Therefore PHP is a decent fit. Furthermore, wikipedia (and certain other sites) put such a ridiculous (and mostly unavoidable) load on the database, these queries need to be crazy finetuned, and thus the database independence offered by something like JPA, ActiveRecord, or the django DB layer actually get in the way because they make it hard to add DB-engine-specific tweaks. But yet again nothing is stopping you from doing this in java: You can write all your queries in raw SQL and sending them to the raw JDBC driver. Hence we arrive at our answer: For certain specific sites, the only answer is a development model that PHP enforces on you, and other languages can easily emulate, but PHP wins the fight for fairly arbitrary reasons; experts in this kind of site building are more familiar with PHP, it's somewhat easier to deploy as, with all due credit to PHP, they've done a bang up job on making it easy for a virtual web host to offer PHP hosting, and as the language pretty much enforces the ordinarily bad code design principles of working for a specific database engine, mixing templates and code, and enforced statelessness, the beginner to intermediate PHP developer is way, way better at it than a java programmer. Or a ruby programmer. Or a python programmer. This also explains why PHP is usually the 'public facing' language for big sites. The front-end just has to render db results and this is done in PHP. The backend, on the other hand, has to do all sorts of complex operations massaging the db, producing new results, and tracking state (example: handling the auto-bid and auction completed events for eBay). This is the complex code in the system and this is pretty much never written in PHP, because the PHP model sucks at it. You'd have to set up a cron job to ping a page every so often which runs the PHP code to set this stuff up. Yich. On Apr 27, 12:52 pm, robilad <[email protected]> wrote: > MediaWiki (the wiki part of Wikipedia) is written in PHP. The search > engine is Lucene (Java), the ogg vorbis & theora media from the > commons played back by Java applets on platforms without native Ogg > support. The servers run on Ubuntu, afair from an ars technica article > a while ago. > > -- > 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 > athttp://groups.google.com/group/javaposse?hl=en. -- 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.
