Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Advantages to using GWT over PHP

Tags:

php

gwt

I'm looking at creating a site for a start-up and I'm trying to decide if I want to build it with GWT. I've done alot of PHP before and would like to continue that but a colleague of mine suggested using GWT instead. I read the information that Google has published about it and I see that all of the scripting is Python. I've never used Python before but it doesn't seem that challenging.

Anyway, question is, to all of you that have used GWT, what do you think of it as opposed to sticking with a PHP approach? Is there anything you can do with GWT that you can't with PHP and vis versa.

Thanks!

EDIT: Sorry, confused the Python in GAE with GWT.

like image 716
Siege898 Avatar asked Dec 23 '22 00:12

Siege898


2 Answers

GWT and PHP are not mutually exclusive.

GWT, or Google Web Toolkit, started as a Framework that will let you write Java code which produces an AJAX Application interface. You write Java, HTML/CSS/Javascript comes out. The UI layer of GWT has nothing to do with the backend server. GWT produces a UI that calls AJAX URLs. There's no reason those URLs couldn't be implemented in PHP. GWT doesn't care what technology is on the other end of a URL, so long as it returns data in the correct format. You can read more in the Communicating with a Server section.

GWT is a decent approach if the you're happy with the general look/feel/behavior of the widgets it produces, and if you know Java.

If you need/want fine grained control over the HTML output of your application (common for a lot of PHP developers), GWT is going to introduce more headaches than it solves (unless you like spending a lot of time in Java land)

like image 144
Alan Storm Avatar answered Dec 24 '22 14:12

Alan Storm


This is a subjective and argumentative question and thus should be closed - you don't provide any info about your startup so it's hard to provide a concrete answer, so you'll only hear subjective opinions from either sides of the camp :)

That being said, let's get some things straightened out :) GWT and PHP can work together (and do nicely too - I've used PHP in my previous GWT project). You use GWT for your frontend, while PHP for the (server) backend. Communication is usually done via JSON. GWT provides a very nifty thing called JavaScript Overlay Types that allow for a very smooth (and fast, since it uses browser for the parsing) integration in your GWT app of the JSONs you get from the server. Also, if you're an (experienced or not :)) PHP programmer, UiBinder should be a breeze to learn and it offers a familiar environment to create templates for your widgets.

With the advent of GWT 2.1 however, it might more advantageous to stick with "pure" GWT, for client and server. This is mostly because GWT 2.1 does a lot of work for the programmer when it comes to communication between server-client (caching, auto-updates Comet style, etc). See this presentation from Google IO 2010 for more info.

Oh, and PHP and GWT as a whole aim for different things: PHP is for sites with dynamic content (so most "normal" sites nowadays), while GWT is best for creating RIA (Rich Internet Applications - think GMail and the like). While you can create RIA with PHP, it's cumbersome - the same goes for GWT and "normal" sites (you'd rather just create small widgets in GWT to embed into a normal, maybe PHP generated, site).

PS: One think that is definitely (IMHO, of course) that GWT has advantage over PHP is language. It's a matter of preference, but I prefer strongly typed, object-oriented language like Java, over PHP, that's trying to be many things at once (adding object-oriented functionalities, some info about types, etc.) - the one thing I didn't like about my GWT+PHP experience was the PHP language - maybe it was just my lack of experience in PHP, but I just didn't like the type of code PHP made me write.

like image 24
Igor Klimer Avatar answered Dec 24 '22 15:12

Igor Klimer