• 0

Java or php?


Question

Recommended Posts

  • 0
9 minutes ago, 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.

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
1 minute ago, 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).

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.7.2016 at 6:46 AM, Angel78 said:

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

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
1 hour ago, 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.

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
39 minutes ago, 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?

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

  • 0
3 hours ago, 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.

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
26 minutes ago, 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.

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

  • 0
19 minutes ago, adrynalyne said:

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

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

  • 0
1 hour ago, 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.

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
11 minutes ago, 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)

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

Edited by adrynalyne
  • 0
28 minutes ago, 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)

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
1 hour ago, adrynalyne said:

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

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
4 hours ago, 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.

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
9 hours ago, Fahim S. said:

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

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 2016-07-13 at 6:39 AM, 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...

"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

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.

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

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
9 hours ago, n_K said:

Lol right...

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

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
6 hours ago, 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.

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
7 hours ago, 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.

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.
  • Posts

    • Interesting image choice... reminds me of the human centipede poster
    • Get $50 of aloSIM Mobile Data Traveler eSim credit for just $24.97 by Steven Parker Today's highlighted deal comes via our Apps + Software section of the Neowin Deals store, where you can save 50% off aloSIM Mobile Data Traveler Lifetime eSim Credit: Pay $24.97 for $50. Stay connected affordably in 120+ countries/regions with your own lifetime eSIM! An eSIM is a digital SIM card. It's basically just mobile data. Once it's activated on your device, it can connect you to data networks in other countries – giving you an internet connection with NO roaming charges. With aloSIM, you can load prepaid eSIM data packages onto your phone, tablet, or computer. Your lifetime eSIM never expires, so it's yours forever and there are never any monthly charges. You'll get $50 in eSIM data credit, which is almost always enough to cover all your data roaming needs for a full year. But if you run out of data, you can always top up your lifetime eSIM and stay connected internationally. Pay $24.97 for a lifetime eSIM with $50 in travel data credit Use your eSIM to join data networks in 120+ countries Install your lifetime eSIM on a compatible device to roam on local data networks Your lifetime eSIM never expires, and can be topped up with more data anytime Many data packages cost as little as $4.50 and last 7 days. Depending on the package you choose, the length of time varies. Good to know Length of access: lifetime For NEW customers only Instant digital redemption Once you add your $50 credit to your aloSim account you have up to 12-months to use it — after that your credit will expire When you pay for a data plan you also get a free phone number (via Hushed) for the same duration of your plan that was purchased - IE 7 day eSim plan gives you a free 7-day phone number Purchased coupon must be redeemed and used within 12 months This deal is not stackable (one offer per aloSIM account) A $4.50 data package will last 7 days The data DOES expire, and you WILL NOT have any leftover data for your next trip unless it takes place within the validity period. While the eSIM never expires, the actual data package is only valid for the length of time stated at purchase (i.e. seven days after activation, 30 days after activation, etc.) So if you buy a seven-day package and only use a tiny bit, that package is still going to expire after seven days. Access options: mobile (check compatibility) Max number of device(s): 1 Updates included Here's the deal: This aloSIM Mobile Data Traveler eSim $50 Credit normally costs ... $50, but it can be yours for just $24.97 for a limited time, a saving of $25 (50% off). For specifications, and license info please click the link below. Get this aloSIM Mobile Data Traveler eSim for just $24.97 (was $50) Although priced in U.S. dollars, this deal is available for digital purchase worldwide. Support queries If you have queries or need support for any of the Neowin Deals, please use the contact form here. Neowin Deals are managed and sold by StackCommerce who represent Neowin on an affiliate basis. Why we post these deals We post these because we earn commission on each sale so as not to rely solely on advertising, which many of our readers block. It all helps toward paying staff reporters, servers and hosting costs. So for those that keep moaning and complaining, be thankful we're still online for you to even do that. Other ways to support Neowin Whitelist Neowin by not blocking our ads Create a free member account to see fewer ads Make a donation to support our day to day running costs Subscribe to Neowin - for $14 a year, or $28 a year for an ad-free experience Disclosure: Neowin benefits from revenue of each sale made through our branded deals site powered by StackCommerce.
    • WordArt was cool. We now have color fonts as a substitute although Word only supports COLRv0 and COLRv1 (Fraud OS 11 only). The OpenType SVG color font format needs to be supported by Office. Adobe's apps support it
  • Recent Achievements

    • First Post
      DrWankel earned a badge
      First Post
    • Reacting Well
      DrWankel earned a badge
      Reacting Well
    • Week One Done
      Supreme Spray LV earned a badge
      Week One Done
    • One Month Later
      Genuinetonerink- Dubai earned a badge
      One Month Later
    • Week One Done
      Genuinetonerink- Dubai earned a badge
      Week One Done
  • Popular Contributors

    1. 1
      +primortal
      498
    2. 2
      +Edouard
      158
    3. 3
      PsYcHoKiLLa
      90
    4. 4
      Steven P.
      74
    5. 5
      Michael Scrip
      72
  • Tell a friend

    Love Neowin? Tell a friend!