JavaEE vs PHP - 为什么这么多人认为 Java 更好?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/9479495/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-26 06:55:00  来源:igfitidea点击:

JavaEE vs PHP - why so many people thinks Java is better?

phpspringhibernatecodeigniterjakarta-ee

提问by alasarr

I need to valorate what technology use for a web project, the team is composed by 4 developers and the time of the project is 1 year.

我需要评估 Web 项目使用的技术,团队由 4 名开发人员组成,项目时间为 1 年。

I'm more familiarized with php but the client is asking me to do it with JAVA EE.

我对 php 比较熟悉,但客户要求我用 JAVA EE 来做。

I always have the same perception with Java and its frameworks:

我对 Java 及其框架始终持有相同的看法:

  • So much xml and class in order to do simple things. In codeigniter I've to use 3 files (model, view and controller) with hibernate + spring + JSF I need more than 10 files!!!
  • An abusive use of the server. The javascript code lose importance and it's not good nowadays. Of course we can add javascript code but It seems "java web guys" prefer do the stuff on the server instead of the client.
  • Not good-looking application. Richfaces seems like a web of several years ago.
  • When I see a java application like liferay, alfresco, they looks heavy and very slowly.
  • 这么多xml和class是为了做简单的事情。在 codeigniter 中,我必须在 hibernate + spring + JSF 中使用 3 个文件(模型、视图和控制器),我需要 10 个以上的文件!!!
  • 滥用服务器。javascript 代码失去了重要性,现在不好了。当然,我们可以添加 javascript 代码,但似乎“java web 人员”更喜欢在服务器上而不是在客户端上执行这些操作。
  • 不好看的应用程序。Richfaces 似乎是几年前的网络。
  • 当我看到像 liferay、alfresco 这样的 Java 应用程序时,它们看起来很重而且很慢。

I think I can be a little confused because lots of people and big companies continues using JAVA for the web. Why? it's about integration?

我想我可能有点困惑,因为很多人和大公司继续在网络上使用 JAVA。为什么?是关于整合?

On the other hand Java is faster than PHP, but JAVA's servers need lots of memory (more expensive). In a server with many request we can improve with a language like php with bigger time per process and less memory per process because the server never is collapsed because of memory. Sometimes a JAVA server could collapsed because of memory and the average of response time in a real production environment would be bigger than php.

另一方面,Java 比 PHP 快,但 JAVA 的服务器需要大量内存(更昂贵)。在有很多请求的服务器中,我们可以使用像 php 这样的语言进行改进,每个进程的时间更长,每个进程的内存更少,因为服务器永远不会因为内存而崩溃。有时 JAVA 服务器可能会因为内存问题而崩溃,并且在实际生产环境中的平均响应时间会比 php 大。

I'm really pleased with Codeigniter, why so many people thinks Java is better?

我对 Codeigniter 非常满意,为什么这么多人认为 Java 更好?

Thanks in advance,

提前致谢,

Alberto

阿尔贝托

回答by wemu

well I'm not using CodeIgniter so my comparison is already incomplete.

好吧,我没有使用 CodeIgniter,所以我的比较已经不完整了。

Question one would be: why do they ask for Java? Often big companies only offer Java or .Net environments for productive systems so they might not have the people to productively run PHP applications. I know its not complicated but the maintenance people define what they are running.

第一个问题是:为什么他们要求使用 Java?通常大公司只为生产系统提供 Java 或 .Net 环境,所以他们可能没有人来高效地运行 PHP 应用程序。我知道它并不复杂,但维护人员定义了他们正在运行的内容。

Ofter people talk on languages and their features but when the first business use case has to be discussed no framework will save you that amount of time to make it count. Most programming language will somehow solve the issue.

人们经常谈论语言及其功能,但是当必须讨论第一个业务用例时,没有任何框架可以为您节省大量时间来使其发挥作用。大多数编程语言都会以某种方式解决这个问题。

Java is not only RichFaces or JSF. There is a lot to choose from. A LOT. Not an advantage.

Java 不仅仅是 RichFaces 或 JSF。有很多可供选择。很多。不是优势。

Stuff often forgotten is the tool support. Java comes along with a JVM that can be analyzed in detail what it does with its memory, garbage collector, threads and so on. Profilers in Java allow you to identify almost any memory leak within a few hours. Most of the JVM monitoring works in realtime (with about 5% overhead). Talking about tool: refactoring support is far beyond what PHP IDEs come along with.

经常被遗忘的是工具支持。Java 附带了一个 JVM,可以详细分析它的内存、垃圾收集器、线程等等。Java 中的分析器允许您在几个小时内识别几乎所有内存泄漏。大多数 JVM 监控都是实时工作的(大约有 5% 的开销)。谈论工具:重构支持远远超出 PHP IDE 提供的范围。

You are correct if the first look at Java compared to PHP looks like elephants and horses. (ok the logo of php is an elephant, perfect comparison...). Horses are more flexible to turn around corners but they might not carry that much around. I think from a language perspective Java is still more advanced than PHP. Namespaces, Classes, Type-Safety. These are somewhat available in PHP but still quite new.

如果第一眼看 Java 与 PHP 相比看起来像大象和马,那么您是对的。(好吧,php的标志是一头大象,完美的比较......)。马在转弯时更灵活,但它们可能不会携带那么多。我认为从语言的角度来看,Java 仍然比 PHP 先进。命名空间、类、类型安全。这些在 PHP 中有些可用,但仍然很新。

Frameworks like Spring allow you to leverage your application on an architectural level and are more than just libraries.

像 Spring 这样的框架允许您在架构级别上利用您的应用程序,而不仅仅是库。

I'm not the biggest Java EE fan, so I'll not complain on that.

我不是 Java EE 的最大粉丝,所以我不会抱怨。

A simple approach for you could be Tomcat+Spring+SpringMVC and a template engine for the GUIs. There is also GWT (Vaadin) if you target higher speed client behaviour (still a lot more out there).

一个简单的方法可能是 Tomcat+Spring+SpringMVC 和 GUI 的模板引擎。如果您的目标是更高速度的客户端行为(还有更多),那么还有 GWT (Vaadin)。

There are lightweight approaches in Java too. I agree the standards in Java do have a more fatty tendency.

Java 中也有轻量级的方法。我同意 Java 中的标准确实有更胖的倾向。

In my experience Java has no major drawbacks compared to PHP. The language choice will only affect success of the project if people come with less knowledge than required and spend too much time in learning things. And trying to find the right book about Java could be a project by its own :) (counting as an advantage)

根据我的经验,Java 与 PHP 相比没有什么大的缺点。如果人们的知识少于要求并且花太多时间在学习上,那么语言选择只会影响项目的成功。并试图找到关于 Java 的正确书籍可能是一个独立的项目:)(算作一个优势)

But I have no doubts PHP would allow you to finish the project.

但我毫不怀疑 PHP 会允许您完成该项目。

I would rather look into the goals and requirements before choosing the technology. This often implies or simplifies a decision.

我宁愿在选择技术之前先研究目标和要求。这通常暗示或简化了决定。

I hope I did answer at least one question here :)

我希望我在这里至少回答了一个问题:)