• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Process exec() in Java vs PHP exec()

 
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello!!

I was told that the Process exec() method in Java is not good at all compared to PHP exec() function, on a same command.

Could someone possibly help me find any benchmark or study that could deny this information? Thank you.
 
Marshal
Posts: 67446
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not much to do with JSP, so I'm moving this along to the Java In General (intermediate) forum.
 
author and iconoclast
Posts: 24203
43
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you expand on "not good at all?" Ease of use, performance, features, power, elegance, Windows-likeness, UNIX-likeness?

A little advice for you: in general, if someone makes a clearly subjective blanket statement like this, the best way to get clarification is to ask them to explain it. If you askk other people, then all we could do would be to guess what that other guy meant. Best to cut out the middleman if you can!
 
Jos� Alberto Mu�iz Navarro
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well.. he was actually referring to performance, meaning PHP takes less time to execute a command than Java.
 
Ernest Friedman-Hill
author and iconoclast
Posts: 24203
43
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I can believe that, because Java probably does a lot more work. Java sets up a dedicated thread to wait for each executed process's exit, and creates buffered streams attached to the process's stdin/stdout/stderr. If you don't need any of that, then you can get beter performance by avoiding it. Of course, it you do need all of that, then it's just more work to duplicate it in PHP.

But the differences are going to be on the order of microseconds, not orders of magnitude. For an operation as slow as executing a process, I doubt that the difference amounts to as much as a factor of two in elapsed time.
 
Ranch Hand
Posts: 3178
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by Ernest Friedman-Hill:
I can believe that, because Java probably does a lot more work. Java sets up a dedicated thread to wait for each executed process's exit, and creates buffered streams attached to the process's stdin/stdout/stderr. If you don't need any of that, then you can get beter performance by avoiding it. Of course, it you do need all of that, then it's just more work to duplicate it in PHP.

But the differences are going to be on the order of microseconds, not orders of magnitude. For an operation as slow as executing a process, I doubt that the difference amounts to as much as a factor of two in elapsed time.



It's great... I didn't even know that PHP got exec() method like in Java... I used to develop a PHP-based accounting application, but I've never known that method before...

I also doubt that Java's exec() is pretty slow, when comparing to C++ native methods and Unix ShellScript codes... I'm looking forward to the comments on comparing Java's exec() and other languages' native-related methods too...
 
Where all the women are strong, all the men are good looking and all the tiny ads are above average:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic