zz/2024/4/19 22:53:38




Simpler API: PHP's API is much more intuitive than java. Takes less time to get productive with PHP than with Java 

PHP was not a resource hog: This is more relevant to the situation 9-10 years ago, than it is today. But the damage was already done. PHP did not need as much memory or as much processor power as a java web app running in a JVM. So PHP was more suitable to commodity hardware in those days. 9 to 10 years ago, I was told about JSP developer experiences, where people would write JSP and then go have a cup of tea for half an hour while the compiler compiled and server deployed it. Then even the simplest JSP requests would take another 30 seconds to couple of minutes. JVMs became much more performant only later on. Performance is much better nowadays of course, but even now, a request to a java web app requires more memory than one to a PHP app. 

PHP所消耗的资源不多:相较今天,这个优势在9-10年前更明显。与运行在java虚机上的web应用相比,PHP所需的内存或CPU电耗较少。那时候,PHP可以在更多的硬件上运行。9、10年前,我听说JSP开发人员常常有这样的经历:写完一段JSP后可以喝上半个小时的茶以等待编译和部署。即使今天,一个最简单的JSP请求也要花上30秒到几分钟的时间。直到最近JVM效率才有显著提高。不过,即使现在,一个java web应用的请求也需要更多的内存。

Less typing. Faster to write code: PHP was a procedural language that later got OOP extensions. So global functions are still common in PHP. Makes for less typing. 

The untyped nature of language too makes for less typing. 


PHP is not strongly typed while java is. This is both a boon and a bane. It's a boon because you have to do less typing. 
But it's a bane - specially in large projects - because one developer will have no idea what data is being passed by another component unless it's documented well. 

This is not so much of a problem when single developer is developing and uses some common sense coding conventions. 


Had open source server support much earlier than java (I believe this was one of the main reasons for its popularity): Apache - 1995 I think. Apache Tomcat - 1999. 

开源的PHP服务器出现得更早。Apache -1995就有了。Apache Tomcat - 1999

Arrived much earlier on the scene than JSP (I believe this was one of the main reasons for its popularity): PHP - 1995; JSP - 1999 


Easier for web designers to pick up: PHP is easier for web designers to pick up, I believe this is another main reason it got traction 


No installation complications: PHP interpreter usually comes bundled with Apache in most installation packages. Java on the other hand requires JRE to be installed. 

安装简单:大多数安装包将PHP 解释器与Apache捆绑在一起。而Java需要额外装JRE

Development cycles take less time: Changes can be made to a PHP file and these changes can be seen immediately on a refresh. This is due to PHP's shared-nothing architecture. PHP has no concept of shared memory, unlike java's static data and session data which remain in memory between requests. Once a PHP request is finished, all data created on the heap is deallocated. PHP session data is saved on file by default, but can be saved to DB. 

In java web development, on the other hand, the only way to make a JSP change or java servlet change active is to rebuild the war and redeploy the web application, thus making it much less nimble than PHP. Of course, some commercial tools like JRebel make this easier, but it's still not as nimble as PHP. 


More hosting options: I agree with Stephen's point. It's much easier and cheaper to host PHP websites than it is to host Java websites. 

有更多的主机host选择:host PHP站点比host java站点更容易也更便宜



Not good support for DB transactions: DB transactions are by nature complex. Java has extremely good standardised APIs for transactions (JDBC) and for distributed transactions(JTA). 
PHP on the other hand had no such support. Even now, some DB agnostic APIs are available - like PDO - but I don't think transaction support is any better. 


No multithreading: PHP has no native threading API. The runtime is also said to be not threadsafe (there's lots of heated debate about this depending on whether the poster is a PHP fanboy or not). I have not done any detailed analysis, so my knowledge is borrowed. But what I understand is some PHP extensions (these are the adapter plugins that add functionality to the PHP interpreter) are thread unsafe, and since nobody seems to know exactly which ones aren't, it's risky to use threading. 

No asynchronous processing support: Because there's no multithreading support in PHP. This is a strong point of java, making java a good candidate to deploy in the services (business logic) layer when some heavy backend processing is involved. It's possible to deploy webdesigner friendly PHP in the web tier and deploy scalable java (or other JVM language) in the business logic tier - and then integrate them through web services. 

Linkedin uses java extensively. Twitter uses Scala (a JVM language) for its backend. Any site based on Liferay CMS or Alfresco CMS (they're called "portal"s in java world but are comparable to the CMSes of PHP world, like wordpress and joomla) is running on a java stack.

LinkedIn站点大量使用java. Twitter使用Scala( 一种JVM语言)作为它的后端。任何基于Liferay CMS or Alfresco CMS(在java世界中他们称作portal,在php中称为CMS,就像wordpress和 joomia)的站点运行于java栈



tars-php 改造 invoke 支持多个tcp请求

现在“微服务”越来越少流行, 公司内部很多接口原来是CGI, 或者直接读DB,都改成用微服务接口, 不用CGI接口,其实挻好的,不好暴露接口到公网,网络延时也少,不需要做鉴权,直…

golang []map[string][string] , 先按大小,再按键名排序

type IpSortItem struct {Value int json:"value"Name string json:"name" } // 先按数量排序,再按名称排序 func sortIPView(rspData []map[string]string) []*IpSortItem {var totalList []intdataList : make(map[int][]string)for _, …

Java eclipse 设置代码折叠

1 windows->perferences->General->Editors->Structured Text Editors 选中Enable folding 效果 2 windows->perferences->Java->Editors->Folding 效果

javac 命令找不到

环境配置出错 仔细的查看每一个配置 复制黏贴的还是出现错误 在自己的电脑中生成的时候错误 仔细查看对比就可以了 使用命令也可以 set java_homeC:\Program Files\Java\jdk1.6.0_26 安装JDK的根目录 set classpath%JAVA_HOME%\lib\tools.jar;%JAVA_HOME%\lib\dt.jar; …


使用Git安装thinkPHP: 1 git clone https://gitee.com/liu21st/thinkphp5.git tp5 ; clone thinkPHP的基础框架 ,tp5为文件名字。 2 切换到tp5目录下在命令行中使用 3 git clone https://gitee.com/liu21st/framework.git thinkphp 4 git checko…


多线程同步I/O和单线程异步I/O 2014-08-24 同步I/O与异步I/O 线程在执行中如果遇到磁盘读写或网络通信(统称IO操作),通常要耗费较长的时间,这时OS会剥夺此线程的CPU控制权,使其暂停执行,同时将资源让给其…

nodejs 调试技巧

1, 命令行调试 run 执行脚本,在第一行暂停 restart 重新执行脚本 cont, c 继续执行,直到遇到下一个断点 next, n 单步执行 step, s 单步执行并进入函数 out, o 从函数中步出 setBreakpoint(), sb() 在当前行设置断点 setBreakpoint(‘f()’), sb(...) 在函数f的第一…




ubuntu系统查找命令 一.以文件名查找: 1. find 命令 find / -name "filename" 目的:在根目录“/”开始搜被称为filename的文件,“filename”文件名可以包含通配符(*,?)&#xff0…

kudu 文件描述符 更改

kudu 文件描述符超过阀值 kudu 文件描述符缺省打开文件数为32768 在/etc/security/limits.d/下找到了cloudera的limit配置文件,里面限制为32768 /etc/security/limits.d/cloudera-scm.conf 修改: 32768会覆盖系统配置,cm启动的进程最大打…