开发者

Switch from PHP to Java or .Net [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 11 years ago.

I currently run a website on LAMP, I am currently in the process of refactoring my code from normal php to Zend framework with Doctrine. I am happy with setup but often find function not found errors on live site cause I have renamed function. Which is frustrating as most of time is wasted is patching these errors. So I have decided to switch from php to java as the code gets compiled, so just error will not go to live site. With java netbeans will work better.

But as I have not been in touch to j2ee for many years. What is the best replacement for my above setup in java?

  • Option 1. Jsf 2 with Hibernate

  • Option 2. Seam

  • Option 3. Spring

  • Option 4. Struts with Hibernate

My server has 24 gig ram and 2 core i7 processor and ssd drive on raid 0

Will my server handle the same amount of visitors if java was used without any performance issues?

I like the way I can update my site without losing live sessions(logged-in users). Can I do the same in Java? from my experience each update to site will redeploy the App which resets all the Active Sessions.

I love to consider .Net but from what I have read on most forums, no one recommends it?

Kind regards

开发者_如何学Go

Zerone


You problem is not switching to Java from PHP your problem is an good test coverage via unit and in particular with integration tests. From what you wrote the best thing might be to take a look at Selenium and to automate testing as most as possible. You need a complete infrastructure to deploy to a test system and run integration tests on it (Selenium) and after that you can say everything is ok.


Java will perform better, but switching to Java seems like overkill for this situation. That said, I would recommend something based on Spring and Hibernate. Spring can be a real godsend for configuring just about anything in Java and Hibernate is similar to Doctrine.

Apache Tapestry would make a good presentation toolkit for your site. It's a great templating library that is cleaner than JSP.


Java has a large variety of solutions to the same problem. Currently, the mainline Java solution to presenting items on the web is Java Server Faces.

Older (which doesn't always mean worse) solutions include Struts, Apache Tapestry, (parts of) Spring, etc. These solutions benefit from maturity, having an established following, etc. Basically they are good solutions because people already know the points where they fail, and already know how to work around them. The new solutions attempt to remove these pain points, and thus suffer from new pain points. Think of it as not noticing your headache until after you fix your broken arm.

Java will perform much better because the code that delivers the web pages is already in memory, so it avoids a number of items that take time (process spawning, disk access, webserver to language engine communications, etc). There are other PHP solutions which also attempt to solve similar problems using similar techniques; however, PHP has a different coding background and style. For example, Java doesn't need to discard any state between web page requests, something that PHP does (and often uses a number of libraries and workarounds to mitigate).

My recommendation is to use Java, but realize that a direct port will incur a lot of unnecessary expense. Choose a web facing toolkit (JavaServerFaces is the newest and part of the Java EE standard), and start off by porting the static portions of the HTML web pages. Organize your requests by scope (how long the side effect of the request should persist), and use the Servlet standard to store the artifacts generated by the request in the appropriate application, session, request, etc scope.

On the database side of things, there are many standards and solutions to pick from too. Personally, as you don't have a lot of legacy concerns, I would go with JPA. While it is not really a 100% complete solution, it will push you to use an interface which can be replaced by better implementations over time, without the need to recode your application. By stating it isn't 100% complete, I mean that you need to select a JPA provider as the default provider probably won't meet your real-world production needs. That said, the default provider should sustain development oriented work, and JPA's standards should protect you from unexpected differences when you run the code against different environments.

Whether you wish to fully restructure you code into a Java EE multi-tier architecture, of if you just want to embed a large Servlet (server faces is a type of servlet solution) that does everything is more of a function of how much you wish to architect your code. It is not a porting problem. That said, the biggest benefits of a typical Java solution over a typical PHP solution is that the Java architecture is designed to work faster and provide more features out-of-the-box. If you intend to do a port with no rearchitecting, you might be better off just finding out the bottlenecks in the PHP code and fixing them.


if you dont use ajax, i prefer 4 (struts + hibernate):

  • jsf needs an little bit of expiriences on such heavy load (getter-methods must be fast and so on).

if you use ajax, i prefer an combination of 3 and 1

regards peter

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜