Show/Hide Navigation Tree
|
Navigation Tree
|
TOC Previous Next
Quick comparison to Java
PHP was invented and designed for creating Web applications. Java was designed as a general programming language. The PHP syntax is similar to C, Java, and Perl.
PHP is easier to get started with, especially for small to medium installations. Java works well for a large team that needs built-in management tools to coordinate large-scale development and deployment, or when the application is largely not Web-based. Some shops use both: Java on the back end and PHP on the front end. See the IBM developerWorks article "Pair J2EE with PHP to implement a common Web application infrastructure" by Dan Krook for an excellent discussion of this:
http://www.ibm.com/developerworks/websphere/techjournal/0505_krook/0505_krook.html
Although PHP and Java share some syntax and design, each has advantages and disadvantages. PHP advantages over Java include:
- Easy to use
PHP is a scripting language that can be embedded directly into HTML. This makes it easy to mix presentation with business operation and data access. However, unlike JavaScript where the script is executed in the browser on the client side, PHP runs on the server. This means that none of your PHP is visible to the end users in the final HTML source, which makes PHP more secure. Also, deployment is much easier because you do not have to compile PHP programs or spend time learning deployment tools to create PHP. You can simply insert changes into the Web page and get quick turnaround.
- Short learning curve
Getting started is easy. PHP also provides object oriented (OO) features that enable you to design modern Web-based applications that are robust and secure. With PHP, you can create Web pages that reflect current information from your favorite database quickly. You can get information from the user viewing your Web page to customize the page specifically for that user. Other functions provide access to e-mail, flat files, or other data such as Lightweight Directory Access Protocol (LDAP) data stores. PHP also includes a spell checker, XML functionality, image-generation, and other functions.
- Active and vibrant developer community
There are a number of Web sites, blogs, discussion forums, and other resources available to PHP developers. There are thousands of readily available PHP-based applications, libraries of functions, components, and frameworks that can be used to develop applications more quickly. Much of this software is free and can be used on any project. This provides a community an invaluable asset to assist developers with ideas, examples, techniques, and other advice on PHP.
Advantages of Java over PHP include:
- Full implementation of object-oriented language features
Java has a full implementation of object-oriented (OO) language features; PHP was not originally designed as an object-oriented language. Only later was OO programming introduced to PHP in Version 3, with limited functionality and based largely on C++ and Java. In PHP 5 many OOP components (such as interfaces, access control, and abstract class) were added, so PHP finally became "OO ready." However, it still lacks a number of OO features that Java provides today.
- Better code maintenance
Because PHP is very easy to start with, it is easy to write code that is difficult to maintain. Java has developed methods and concepts that more firmly encourage clean and maintainable code. If a PHP developer does not take care to follow common "best practice" programming rules (separation of business logic from GUI, database abstraction, and so forth), PHP applications can be hard to port to other platforms or databases. They can also be difficult to enhance later with new functionality.
- Enterprise manageability with J2EE
Most full J2EE implementations (for example, IBM WebSphere Application Server products) provide extensive support for clustering, failover, and overall management of an enterprise Web system. PHP implementations are generally not as advanced or tightly integrated in this respect.
This list of advantages and disadvantages of PHP and Java was current when this book was written. Both languages are changing rapidly, and many of the issues are improving. In addition, note that some of disadvantages of both languages can be eased by using extensions or other add-on products.
TOC Previous Next
|
Top 5 contributors to this page
|
The postings on this site solely reflect the personal views of the authors and do not necessarily represent the views, positions, strategies or opinions of IBM or IBM management.
|
|