• 0

Java or php?


Question

Recommended Posts

  • 0
  On 13/07/2016 at 10:39, n_K said:

What a dimwitted view, let's just completely disregard that it runs one of the most popular and frequently visited sites on the internet... Sure PHP has it's problems but java isn't a perfect language either. I can spend 20 seconds making a quick script to do something in PHP which would take an hour to make in java, then there's java's ridiculous overhead: it is painfully slow and the memory usage is still a joke.

Expand  

Thank you. I'm glad that it not just me who also thinks that Java is slow and take much longer to create something (let alone more work involved).

  • 0
  On 13/07/2016 at 10:50, Danielx64 said:

Thank you. I'm glad that it not just me who also thinks that Java is slow and take much longer to create something (let alone more work involved).

Expand  

I'm not a fan of Java at all, but Java has been near native (performance is just slightly slower than C++ compiled code) in terms of speed for some time now.

I dislike Java because of the verbosity of the language and the amount of boilerpate it takes to achieve even the most simple of tasks.

 

I will still maintain that PHP is a horrible language, though.  If I wanted to create something quick, I would do it using Python well before I would even consider PHP.

  • 0
  On 12/07/2016 at 04:46, Angel78 said:

I'm planning to learn either java or php. Which language do you think will give better employment opportunity? 

Expand  

Don't learn a language just because of today's employment chances. They'll change any day.

By the way: PHP has always been a single-purpose language. Quickly set up a website on shared hosting? Chances are great that PHP will work. Good luck with { Java, Python, Ruby, COBOL, Assembler }.

  • 0
  On 13/07/2016 at 10:54, Fahim S. said:

I'm not a fan of Java at all, but Java has been near native (performance is just slightly slower than C++ compiled code) in terms of speed for some time now.

I dislike Java because of the verbosity of the language and the amount of boilerpate it takes to achieve even the most simple of tasks.

 

I will still maintain that PHP is a horrible language, though.  If I wanted to create something quick, I would do it using Python well before I would even consider PHP.

Expand  

I'd like to see proof of that because they've been claiming java is almost as fast as C++ for almost 20 years now, not even joking: http://www.javaworld.com/article/2076593/performance-tests-show-java-as-fast-as-c--.html?page=2. Anyone can tell when you're running a java program: slow startup and just general sluggishness of the whole thing. I hate to use minecraft as an example but just look at the specs required to run such a basic program that shouldn't be that demanding, then compare it to the original quake which will run fine on a 66Mhz original pentium?

  • 0
  On 13/07/2016 at 12:16, n_K said:

I'd like to see proof of that because they've been claiming java is almost as fast as C++ for almost 20 years now, not even joking: http://www.javaworld.com/article/2076593/performance-tests-show-java-as-fast-as-c--.html?page=2. Anyone can tell when you're running a java program: slow startup and just general sluggishness of the whole thing. I hate to use minecraft as an example but just look at the specs required to run such a basic program that shouldn't be that demanding, then compare it to the original quake which will run fine on a 66Mhz original pentium?

Expand  

What does Minecraft execution speed have to do with server side execution speed?

  • 0
  On 13/07/2016 at 10:39, n_K said:

What a dimwitted view, let's just completely disregard that it runs one of the most popular and frequently visited sites on the internet... Sure PHP has it's problems but java isn't a perfect language either. I can spend 20 seconds making a quick script to do something in PHP which would take an hour to make in java, then there's java's ridiculous overhead: it is painfully slow and the memory usage is still a joke.

Expand  

Dynamically typed languages are great for writing quick scripts. It's not surprising that it's easier to knock up scripts in PHP than in Java. However, if you're building large software, you want more safety. I'd rather do a refactor in a Java codebase than in a PHP one. Facebook felt the need to create Hack, which, surprise surprise, is meant to provide more safety than vanilla PHP.

 

As for performance, when Facebook created Cassandra they didn't choose to write it in PHP. Want to guess what language they used? The JVM is performant enough that it is currently the most popular technology in big data. Modern implementations often pick Scala over Java (e.g. Apache Spark), but it's still the JVM underneath.

 

I've written a fair bit of both PHP and Java in my career. These days I tolerate Java. I'd rather write Scala, Swift or even JavaScript (ES2015 with Flow is surprisingly enjoyable). PHP, however, I stay away from.

  • 0

Yea, I think it depends on what you want to do.

If it were me, I'd probably go with JavaScript and Node.js. If you haven't programmed before, Java has a steep learning curve.

Neither Java or JavaScript is going away soon but you might get "up and running" faster with JavaScript and that will give you a good base to learn other languages when you need to.

  • 0
  On 13/07/2016 at 15:18, tompkin said:

Yea, I think it depends on what you want to do.

If it were me, I'd probably go with JavaScript and Node.js. If you haven't programmed before, Java has a steep learning curve.

Neither Java or JavaScript is going away soon but you might get "up and running" faster with JavaScript and that will give you a good base to learn other languages when you need to.

Expand  

Knowing both, i would say that JS has a far steeper learning curve than Java. 

  • 0
  On 13/07/2016 at 15:45, adrynalyne said:

Knowing both, i would say that JS has a far steeper learning curve than Java. 

Expand  

Agreed, but once you know it you can work on (web based) client and serverside code.

  • 0
  On 13/07/2016 at 15:02, vhane said:

Dynamically typed languages are great for writing quick scripts. It's not surprising that it's easier to knock up scripts in PHP than in Java. However, if you're building large software, you want more safety. I'd rather do a refactor in a Java codebase than in a PHP one. Facebook felt the need to create Hack, which, surprise surprise, is meant to provide more safety than vanilla PHP.

 

As for performance, when Facebook created Cassandra they didn't choose to write it in PHP. Want to guess what language they used? The JVM is performant enough that it is currently the most popular technology in big data. Modern implementations often pick Scala over Java (e.g. Apache Spark), but it's still the JVM underneath.

 

I've written a fair bit of both PHP and Java in my career. These days I tolerate Java. I'd rather write Scala, Swift or even JavaScript (ES2015 with Flow is surprisingly enjoyable). PHP, however, I stay away from.

Expand  

PHP has had optional strict typing support for years now http://php.net/manual/en/functions.arguments.php

Of course they didn't write a backend server in PHP, that's not what PHP was designed for. That would be like using PHP to render the interface for a desktop: it's probably possible, would anyone sane ever do it? No. Is that even remotely like PHP's intended purpose? No.

"What does Minecraft execution speed have to do with server side execution speed?"

It gives you an overall view of the performance, and the performance of java is nothing short of shite. Not to say native PHP is much better, I've personally found PHP faster (and there's multiple different execution engines which again can vastly improve performance) not to mention every time you change something you don't have to recompile it (hiphop-vm for example will automatically cache the bytecoded version on the fly and redo this if the file changes)

  • 0
  On 13/07/2016 at 16:06, n_K said:

PHP has had optional strict typing support for years now http://php.net/manual/en/functions.arguments.php

Of course they didn't write a backend server in PHP, that's not what PHP was designed for. That would be like using PHP to render the interface for a desktop: it's probably possible, would anyone sane ever do it? No. Is that even remotely like PHP's intended purpose? No.

"What does Minecraft execution speed have to do with server side execution speed?"

It gives you an overall view of the performance, and the performance of java is nothing short of shite. Not to say native PHP is much better, I've personally found PHP faster (and there's multiple different execution engines which again can vastly improve performance) not to mention every time you change something you don't have to recompile it (hiphop-vm for example will automatically cache the bytecoded version on the fly and redo this if the file changes)

Expand  

The performance of Java is largely limited to the JVM running it. 

Edited by adrynalyne
  • 0
  On 13/07/2016 at 16:06, n_K said:

PHP has had optional strict typing support for years now http://php.net/manual/en/functions.arguments.php

Of course they didn't write a backend server in PHP, that's not what PHP was designed for. That would be like using PHP to render the interface for a desktop: it's probably possible, would anyone sane ever do it? No. Is that even remotely like PHP's intended purpose? No.

"What does Minecraft execution speed have to do with server side execution speed?"

It gives you an overall view of the performance, and the performance of java is nothing short of shite. Not to say native PHP is much better, I've personally found PHP faster (and there's multiple different execution engines which again can vastly improve performance) not to mention every time you change something you don't have to recompile it (hiphop-vm for example will automatically cache the bytecoded version on the fly and redo this if the file changes)

Expand  

Benchmarks show that JVM performance is actually pretty good. Certainly significantly better than anything on the PHP side. In practice this isn't likely to matter though since PHP programs aren't usually written to be asynchronous.

  • 0
  On 13/07/2016 at 15:45, adrynalyne said:

Knowing both, i would say that JS has a far steeper learning curve than Java. 

Expand  

Indeed. Things have moved very fast in JavaScript land. Java code from 10 years ago looks pretty much the same as today. Modern JavaScript is totally different from the bad old days when poking the DOM with spaghetti jQuery code was the state of the art.

 

I wrote this function today and it occurred to me that it doesn't even look like JavaScript to me.

// Create a new immutable model object for the protobuf message type
export const fromProto = (protobufType: () => Object): Object => {
  // Rename keys to be the same as what is defined in the .proto file that generated the imported JavaScript
  const toOriginalName = (key: string, value: any): string => {
    if (key.length > 4 && key.endsWith("List")) {
      return key.slice(0, -4)
    }
    return key
  }
  return u.freeze(fp.mapKeys(toOriginalName)(new protobufType().toObject()))
}

 

  • Like 2
  • 0
  On 13/07/2016 at 18:06, tompkin said:

Gees, I didn't know that. I'll probably be steering clear of JS unless I'm forced to.

Expand  

It's good to know. It's just a different beasty from a object oriented language. 

  • 0
  On 13/07/2016 at 17:13, vhane said:

Benchmarks show that JVM performance is actually pretty good. Certainly significantly better than anything on the PHP side. In practice this isn't likely to matter though since PHP programs aren't usually written to be asynchronous.

Expand  

Found a few benchmarks but they're all mostly old except this one, and no, it shows java is significantly slower than PHP (native, not even using hhvm): https://blog.famzah.net/2016/02/09/cpp-vs-python-vs-perl-vs-php-performance-benchmark-2016/

  • 0
  On 13/07/2016 at 12:56, Fahim S. said:

What does Minecraft execution speed have to do with server side execution speed?

Expand  

Java client side JVM is similar enough to the server JVM that benchmarks on the client would not be off by very much.

 

Minecraft runs on Java and yes that is a great example of the alice in wonderland thinking that is like a theme for this forum thread. Somehow, comparing Quake which is a 2.5D software BSP based dungeon game to an open world sandbox voxel based engine will provide insight on which web technology is better to learn!

 

To anyone who thinks Minecraft is somehow "trivial", it is doing something very hard. There are no voxel engines that work significantly better in some other programming language. Once you hit a GPU bottleneck it doesn't matter how you feed it! (Although all sorts of clever stuff goes on there as well)

 

  • 0

A lot of factors go into choosing programming technology and it is often additionally complicated because you don't get to start with a clean slate.

 

Some of the criteria for technology selection presented so far have been ROTFLOL

 

But if selecting the best bet for a career, then the performance and other factors of technical aesthetics just don't matter.

 

http://trends.builtwith.com/framework

 

PHP - 27%

ASP.NET - 21%

Java - 9%

Ruby - 9%

 

There are many ways to slice the data presented and really there is a lot of local variation in any career market so look at local ads and call up recruiters to get an idea.

 

That all being said, programming computers is HARD. And if you have to go to a forum and ask this question, the next question to ask yourself, is it something you crave? Famous Broadway Choreographer once said "I don't want people who want to dance, I want people who NEED to dance."

 

  • 0
  On 13/07/2016 at 10:39, n_K said:

What a dimwitted view, let's just completely disregard that it runs one of the most popular and frequently visited sites on the internet...

Expand  

"The reason Facebook hasn't migrated away from PHP is because it has incumbent inertia (it's what's there) and Facebook's engineers have managed to work around many of its flaws through a combination of patches at all levels of the stack and excellent internal discipline via code convention and style - the worst attributes of the language are avoided and coding style is rigidly enforced through a fairly tight culture of code review (failing to adhere to the style and "going cowboy" by writing sloppy code results in pitiless mockery by one's peers). (...)

There is also a lot of industry precedent indicating that re-writing an entire codebase in another language is usually one of the worst things you can do, so at all levels there is a reluctance to do that. The preferred strategy is to write new components in a de-coupled manner using a better language of choice (C++, python, Erlang, Java, etc); this is easily facilitated by Facebook's early development of thrift, an efficient multi-language RPC framework. This also helps avoid the worst effects of PHP: it can be totally avoided in subcomponents where the language is grossly-unsuitable. The broad effect is that the overall codebase slowly evolves away from depending as heavily on PHP, with the components that are still in PHP being written in tightly-controlled, disciplined ways by veteran members of the staff." http://www.zdnet.com/article/why-facebook-hasnt-ditched-php/

 

  Quote

Sure PHP has it's problems but java isn't a perfect language either. I can spend 20 seconds making a quick script to do something in PHP which would take an hour to make in java

Expand  

If you write anything large-scale then the syntactic overhead is quickly dwarfed by the advantages (maintainability, modularity, etc) of using a more strictly typed and better designed language. Sure PHP is ok for hacking small things quickly; today's web of rich applications has evolved well beyond that however and PHP is no longer an appropriate tool for handling that level of complexity.

 

  Quote

then there's java's ridiculous overhead: it is painfully slow and the memory usage is still a joke.

Expand  

Hum... this is likely spoken from ignorance, or perhaps "Minecraft is slow" meme. Java is highly optimized for server-side performance and uses state-of-the-art VM and GC technology.

  • 0
  On 14/07/2016 at 13:24, Andre S. said:

Hum... this is likely spoken from ignorance, or perhaps "Minecraft is slow" meme. Java is highly optimized for server-side performance and uses state-of-the-art VM and GC technology.

Expand  

Lol right...

mem-use.png

  • 0

Java is a better language to start learning anyway. Writing php shouldn't be an issue for a good java programmer. Writing java as a php programmer on the other hand...

 

I started with php and I regret not starting with java or C#. Starting with php made me a lazy programmer that just copy pasted snippets of code without knowing how it works... It took a while to learn proper programming.

  • 0
  On 14/07/2016 at 15:45, n_K said:

Lol right...

*posts graph from http://cppcms.com/wikipp/en/page/benchmarks_all*

Expand  

You're not leading the discussion anywhere. What exactly is being measured here? "Memory" could be many things, many of them meaningless (is it private bytes? reserved memory?) The JVM pre-allocate huge chunks of memory because it manages memory itself; this is a very effective strategy in general and especially for server-side programs.  What version of Tomcat is used? Is the app representative of a real-world scenario? All this benchmark could mean is that some version of Tomcat pre-allocates about 100MB on app startup, for all we know.

  • 0
  On 15/07/2016 at 00:55, Andre S. said:

You're not leading the discussion anywhere. What exactly is being measured here? "Memory" could be many things, many of them meaningless (is it private bytes? reserved memory?) The JVM pre-allocate huge chunks of memory because it manages memory itself; this is a very effective strategy in general and especially for server-side programs.  What version of Tomcat is used? Is the app representative of a real-world scenario? All this benchmark could mean is that some version of Tomcat pre-allocates about 100MB on app startup, for all we know.

Expand  

If you want to see how bad it is with memory management go and get the trial vcentre centos virtual machine and half the RAM (It's either 8GB or 16GB by default) and watch it fall over - it can't adapt at all to the lower memory constraint and it isn't even doing much, it just sits idle until a server is added but woah that's too much for to it apparently.

  • 0
  On 15/07/2016 at 07:05, n_K said:

If you want to see how bad it is with memory management go and get the trial vcentre centos virtual machine and half the RAM (It's either 8GB or 16GB by default) and watch it fall over - it can't adapt at all to the lower memory constraint and it isn't even doing much, it just sits idle until a server is added but woah that's too much for to it apparently.

Expand  

If Java had serious memory usage issues then I would expect to easily find information about this such as stackoverflow questions, blogs discussing workarounds, github issues, etc. If you have sources to share then please do, otherwise I'm not really willing to keep trying to track down what you're referring to, or run experiments by myself.

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.