Java vs. PHP.

PHP is a server-side scripting language whereas Java is a general-purpose language. In other words, PHP is only used as a server-side language where Java is both for server-side and desktop programming language. Moreover, Java is compiled and strongly-typed language. On other hand, PHP is a dynamic typed language.

PHP, in contrast, is weakly typed, essentially meaning it is more flexible and reliant on “common sense programming” in how a task is accomplished.  While this may sound more attractive because it requires less formal knowledge, some contend that it complicates certain tasks, particularly in object oriented programming, with its lack of standards.

Most small and medium projects are better with PHP vs. Java. However, larger projects are better with Java vs. PHP.

Security

v Java Application servers enforce security model. Each application runs in its own container. v Java/JVM has its own extensive security framework.

v No security guarantees from PHP: Administrators run PHP in CGI mode in order to avoid security nightmare. That is, PHP engine is forked for each page hit.

v Even Administrator chroots (each time to you hit a page) for security.

And finally, Java has traditionally been considered a more secure option. While this has been contested, particularly following exposure of security vulnerabilities earlier this year, many enterprise systems are unlikely to move to PHP, which is hard pressed to make claims of decreased vulnerabilities. For this and the other reasons stated here, a lot of big businesses (not all) prefer to build with Java.

Debugging

- All Java editors allow you to debug your project within the editor.

- PHP debugging is just “print” statements.

Language features & libraries

v Java is OO. So is PHP now (PHP 5.0).

v Java Provides reflection (reverse-engineer classes, interfaces, functions). PHP is finally added the same feature in PHP 5.0. Note: Reflection enable you to architecture your application better.

v Java has a richer set of API.

v Java provides management API (JMX) for managing and monitoring devices and applications.

v There thousands of OSS projects for Java (apache.org). Java provides a clean mechanism to combine these libraries (jar) to compose a complex application. v Java provides native transaction mechanism.

v Java has a persistence mechanism to convert Java objects to database table entries and table entries to Java objects.

v Java has annotations: Annotations can be used for both compile-time and run-time.

v Java has thread support: Executing tasks in parallel.

v There are many other languages that can run within Java or on JVM (Ruby, Groovy, Python, JavaFX etc).

Programmers

Everybody is a PHP programmer. Even monkeys! Changing or creating a page in PHP is easy

for a complex application, monkeys cannot do programming in Java.

Ultimately, these characteristics imply that java can be a good choice when development is complicated and relies on teams of professional developers. Rather than making work more challenging, the precisely defined standards allow for easier understanding and greater efficiency among teams. On the other hand, PHP is more accessible to inexperienced programmers. If a web product intends to allow users to work with the code (such as web and blog creation software or small business sites) PHP can fit the bill nicely. It can also be a nice economical and nimble choice for small teams using agreed coding standards and when dealing with simple functions.

 

猜你喜欢

转载自blog.csdn.net/weixin_37380784/article/details/89556229
今日推荐