4 ms·
> from a "sane" language (PHP) to a less sane, but twice as fast language (C++) C++ is much faster than PHP, not just twice as fast.
by acangiano 17y ago
> from a "sane" language (PHP) to a less sane, but twice as fast language (C++)
C++ is much faster than PHP, not just twice as fast.
- angelbob 17y agoHand-coded C++ is much more than twice as fast, but 2x is what you get from machine-converted HipHop at this point.
- jwr 17y agoLanguages aren't "fast" or "slow", it's programs that can be fast or slow. If a higher-level language lets you implement a smarter algorithm, your program will run faster.
- acangiano 17y ago> Languages aren't "fast" or "slow", it's programs that can be fast or slow. We can say that "C++ is faster than PHP", because most, if not all, programs using the same algorithms will run faster when written in C++ and compiled to native code. > If a higher-level language lets you implement a smarter algorithm, your program will run faster. PHP is generally easier to master than C++, but both are high level enough to provide adequate tools to write efficient algorithms with comparable amount of effort, provided one is competent with the language at hand.
- Todd 17y agoAgreed. Scripted/interpreted languages are, in general, one to two orders of magnitude slower than a compiled language such as C/C++. It's damn difficult to go much better than 10x slower due to the nature of an interpreter--even fast opcode-based interpreters. There are some extensions to the GNU C/C++ compilers that can help here, though.