View Full Version : Converting PHP codes into highly optimized c++ codes
letom
11-28-2013, 07:39 PM
Converting php codes into highly optimized c++ codes reduces the overheads in all sections of server side, how this hiphop procedure is doing? how a php function can be transfers to a c++ code ?
Converting php codes into highly optimized c++ codes reduces the overheads in all sections of server side …
In general, yes. c/c++ is faster than php. How much of a benefit you see will depend on how well your particular php code can be converted (for example, if 95% of your script execution time is spent waiting - for example, for responses from a database - then you won't see much difference anyway).
how this hiphop procedure is doing? how a php function can be transfers to a c++ code ?
hiphop reads your php source, and writes c code that does the same thing. After all, php is written in c in the first place.
letom
11-29-2013, 04:55 AM
hiphop reads your php source, and writes c code that does the same thing. After all, php is written in c in the first place.
Thanks..
It reads from your statement there is no need to convert php code into an optimized c++ code ? In my POV normally people don't want to do this, but for a website having high traffic will reduce the usage of server resources 90% if it convert php into c++
Any special libraries must uploaded to run c++ in Linux server support php hosting ?
It reads from your statement there is no need to convert php code into an optimized c++ code ? In my POV normally people don't want to do this…
In many cases, it would not lead to the improved performance you might expect - especially for the average user. Yes, the PHP code itself will run faster, but code execution is almost never the performance bottleneck (unless you have serious problems in your code, for example, memory leaks, deep nested loops, etc.—in which case, those problems will likely still exist once converted to c). In most cases, slow code is the result of external calls, disk i/o, and similar things. Typical website php scripts will see a much bigger performance gain by taking all of their database queries out of loops than by adopting hiphop.
…a website having high traffic will reduce the usage of server resources 90% if it convert php into c++
As I said, this may or may not be the case for any given website.
Actually, it would appear to _not_ be the case. Hiphop claims an average 5x improvement …over php 5.2. But php 5.4 (I couldn't find numbers on 5.5) is nearly twice as fast (http://www.lornajane.net/posts/2012/php-5-4-benchmarks) as 5.2 anyway.
Facebook, for example, got good use from this because the rest of their software base was already so well-developed that php execution time actually was the bottleneck (plus, with such a large, high-use application, they needed all they could get).
To be plain, even if php execution times were decreased by a factor of 5, the vast majority of php websites would never even notice. "High traffic" -in Facebook context- is nearly incomprehensible for any other website.
Any special libraries must uploaded to run c++ in Linux server support php hosting ?
Obviously, your host would have to support hiphop. I would not expect that many do.
The alternative would be to get a private server, and install it yourself.
letom
11-30-2013, 07:11 AM
Thanks,
NOW PHP is best language which is more flexible than any other languages for web development , because the majority of website seeing online are developed in php, there is no debate over that.
Linkedin is another big traffic website, i think developed with java only, says better scalable language ?
Yes, the PHP code itself will run faster, but code execution is almost never the performance bottleneck (unless you have serious problems in your code, for example, memory leaks, deep nested loops, etc.—in which case, those problems will likely still exist once converted to c). In most cases, slow code is the result of external calls, disk i/o, and similar things.
From reading above statement i came to a conclusion that chances came for using hiphop is because of the ancient depreciated coding formats, it is not replaced with latest php codings but instead using c++ for that.. it is true ?
NOW PHP is best language which is more flexible than any other languages for web development , because the majority of website seeing online are developed in php, there is no debate over that.
Popularity is not a measure of quality.
PHP is very popular, but this has more to do with its low entry barrier (new/amateur programmers can accomplish basic things very quickly) and tolerance of errors, poor coding design, etc..
Likewise, php can be used for many tasks, but I wouldn't call it particularly "flexible" in comparison to other languages. I can do just about anything with php, but some things aren't convenient at all.
Once you get into how PHP actually works, and the quirks and oddities that it has, it quickly becomes obvious that it is actually quite haphazard and has problems from the lowest levels. The last two versions have done wonders for performance, but there is still a lot to be desired, and some of it seems to be unfixable.
Linkedin is another big traffic website, i think developed with java only, says better scalable language ?
Likewise, java is very popular, but that doesn't automatically make it good.
Yes, the PHP code itself will run faster, but code execution is almost never the performance bottleneck (unless you have serious problems in your code, for example, memory leaks, deep nested loops, etc.—in which case, those problems will likely still exist once converted to c). In most cases, slow code is the result of external calls, disk i/o, and similar things.
From reading above statement i came to a conclusion that chances came for using hiphop is because of the ancient depreciated coding formats, it is not replaced with latest php codings but instead using c++ for that.. it is true ?
I am not sure what you mean by that. What I was pointing out is that code optimization has more to do with the design/"plan" of the code itself, and less to do with which language it's written in.
letom
12-01-2013, 05:01 AM
Popularity is not a measure of quality.
Not saying things about popularity, all languages have its own benefits and its own disadvantages, every thing is human made, what ever things which is introduced by a human is not 100% reliable, In php inexperienced programmers can do small things, experienced programmers can do big things, all languages are equally qualified. But my question is why a need arise that a complied language like c++ is using with php, but not arising a need with java? But this question set to active only for websites having big traffic(just 1 or 2 websites).
PHP is very popular, but this has more to do with its low entry barrier (new/amateur programmers can accomplish basic things very quickly) and tolerance of errors, poor coding design, etc..
Poor coding and design ? Absolutely wrong, if any of the programmers is saying any of the languages have "Poor coding and design"(not in ur case) they are only making a debate that the the language they are using are best , I would like to refer it as Senseless, Meaningless, Unworthy and Disqualified,
Poor coding will leads to a lot of security issues, and will not bring correct output, is it happening in the case of php ?
Security of an applications are mainly depend on the logic we are applying, not with what type of language we are using, we can add as much off security modules to our application which depends on view of a security analyst. In POV if anybody saying " using this language will provide added security", that is an advertising technique or that person have only knowledge about the language he is working nothing beyond that
Likewise, java is very popular, but that doesn't automatically make it good.
All languages have its own advantages and disadvantages, because all are developed by humans and all are best suited for humans, but i give priority for web development as PHP, JAVA, .NET, PYTHON, RUBY
[/QUOTE]
I am not sure what you mean by that. What I was pointing out is that code optimization has more to do with the design/"plan" of the code itself, and less to do with which language it's written in.
Yes according to above statement code optimization will reduce the overheads ? due to overhead and to reduce overheads php is converting to optimized c++ codes, then cause of overheads is due to lack of code optimization means poor coding,
Finally if we build a fine programming architecture in php there is no need to convert it into other languages ?
…But my question is why a need arise that a complied language like c++ is using with php, but not arising a need with java?
Java is a compiled language.
Poor coding and design ? Absolutely wrong, if any of the programmers is saying any of the languages have "Poor coding and design"(not in ur case) they are only making a debate that the the language they are using are best , I would like to refer it as Senseless, Meaningless, Unworthy and Disqualified,
By "poor coding design," I was referring to scripts that may not be written as well as they could be; not to the PHP language itself.
Poor coding will leads to a lot of security issues, and will not bring correct output, is it happening in the case of php ?
In the case of badly written programs, yes. Again, I wasn't talking about the language itself (though php has had its share of security vulnerabilities).
Yes according to above statement code optimization will reduce the overheads ? due to overhead and to reduce overheads php is converting to optimized c++ codes, then cause of overheads is due to lack of code optimization means poor coding
IIUC, yes and no. "Optimization" can apply to many different aspects of a program. Converting to c will certainly remove the overhead of interpreting your php to bytecode on each request, but you can achieve that by using APC/similar. However, it won't magically fix an inefficiently written script, and it won't affect things like disc i/o time or network communications (e.g., querying an external database) at all.
Here's what I was getting at. Most of the time spent running your script is not spend running the script itself, but on other things. Hypothetical example:
---| apache
-----| php interpreter
---| php execution
-----------------------------| disc i/o (e.g., writing a file)
--| php execution
----------------------------------------------------------| do some image manipulation
--------------------------------------------------------------------------------------------------------------------| query DB and wait for reply
---| php execution
-------------------------------------------------------------------------------------------------------------------------------------------------| send response to user
Say hiphop removes the time spent interpreting your script, and makes execution five (or even ten) times faster. What about all the other stuff? And this is not an exaggeration; putting stuff on the HD easily takes hundreds of times longer than the parts of your program that execute in memory; network activity is hundreds of times slower again.
Finally if we build a fine programming architecture in php there is no need to convert it into other languages ?
For most people, probably not. The requirements would usually outweigh the benefits. In high-use cases, where every small performance increase counts, then yes. If you've already made every other practical optimization, then yes. And either way, if you want to, then why not?
letom
12-01-2013, 07:35 PM
And either way, if you want to, then why not?
I will try my best not to copy the idea and architecture of others, instead of that finding an advanced one for freely distribution, but if not possible do it as same..
letom
12-02-2013, 11:29 AM
Java is a compiled language.
Java is running through JVM(Java Virtual machine), says neither compiled nor interpreted..
IIUC, Java is compiled into a specialized form of bytecode (not to machine language, for example, as c is), and is then interpreted at runtime by the JVM. I don't know too much about it, though.
letom
12-03-2013, 06:01 AM
Yes, then JVM will interpret the code into machine language..
Then why it says Java is faster than Php ,
PHP is only interpreting the human language(code) into machine codes and execute the program (1 step process)
Java is first compiling pgrm codes into byte code and then interpreted by JVM at run time (2 step process),
even if compilation is done only once, then interpretation retains, then the statement JAVA FASTER is false ?
Other wise i think interpreting byte codes is faster than interpreting human language codes directly,
djr33
12-04-2013, 06:01 AM
It doesn't matter how many steps there are. What matters is how fast the code runs.
C++ runs faster than PHP because PHP is inefficient in design, mostly because it isn't compiled into machine code.
So for Java the question is how fast compiled Java runs, not how quickly it is converted/compiled.
letom
12-04-2013, 07:17 PM
Thanks.. Hope future versions of php will solve these issues and additionally make it fully completable to develop client side applications
djr33
12-05-2013, 12:54 AM
Hope future versions of php will solve these issuesThat's not really possible. The goals of PHP are not to make it the fastest language. The goal is to make it easy to use on webservers. Therefore, it is not the best language to run extremely complicated or processor-intensive code. But usually websites don't require that. That's best in C++ or Java, when you are creating an application to run natively on the computer.
and additionally make it fully completable to develop client side applications This is not what PHP is designed to do. Just like cars are not designed to fly in the air or float in water, PHP is not designed to work client-side. There are many reasons: 1) it is secure on the server, and would not be secure client-side (like JS is not secure); 2) it is meant to work on a server with databases and other server-side things; and 3) it is designed as a "hypertext pre-processor"-- it is designed to generate webpages (HTML output), not to interact with a user.
However, in the future technologies like AJAX (or perhaps node.js) will be improved and extended so that interaction between client-side scripting (like JS) and server-side programming (like PHP) is made much smoother. Really, this is the whole idea of (or at least one major aspect of) "Web 2.0".
But PHP will never be a client-side technology. Or at least it will not be client-side without such major changes that it would no longer really be PHP any more. Maybe it would have the same name, but that would probably be more confusing than helpful.
Powered by vBulletin® Version 4.2.2 Copyright © 2021 vBulletin Solutions, Inc. All rights reserved.