Thread: Can C++ Replace PHP?

  1. #16
    Deprecated Dae's Avatar
    Join Date
    Oct 2004
    Location
    Canada
    Posts
    1,034
    Guys, I'm just saying you run into speed bumps re-implementing the PHP library. Sure, C++ CAN be faster and more secure, but it's NOT a guarantee. You can easily introduce bugs and exploits while re-implementing these basic functions, which PHP either doesn't suffer, or has fixed over the years.

    Quote Originally Posted by Sebastiani View Post
    Regular expressions are just tools - parsing a URL could be done with or without them
    Yup, that's what php's function does, although rather verbosely.

    Quote Originally Posted by Sebastiani View Post
    Personally I'd use my spirit-like parser template library
    Which I mentioned. It's still time-consuming redoing these functions. I just thought I'd mention it.

    Boost.Spirit URL parsing

    Oh, and the whole regex thing isn't a concern anymore. It's just something I thought I'd use as an example.
    Warning: Have doubt in anything I post.

    GCC 4.5, Boost 1.40, Code::Blocks 8.02, Ubuntu 9.10 010001000110000101100101

  2. #17
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Location
    Ireland
    Posts
    8,446
    What was the problem anyway?
    I'm curious because Boost::regex does support the PCRE implementation.
    Originally Posted by brewbuck:
    Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.

  3. #18
    "Why use dynamic memory?"
    Join Date
    Aug 2006
    Posts
    186
    It could
    but why would you use a saw to cut a small piece o cake ?
    "C makes it easy to shoot yourself in the foot; C++ makes it harder, but when you do, it blows away your whole leg."-Bjarne Stroustrup
    Nearing the end of finishing my 2D card game! I have to work on its 'manifesto' though <_<

  4. #19
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,708
    Quote Originally Posted by Hussain Hani View Post
    It could
    but why would you use a saw to cut a small piece o cake ?
    Anyone who's ever had to write a serious PHP program would tell you that the cake was actually made of wood. Unfortunately, all you get is a plastic knife.

  5. #20
    Deprecated Dae's Avatar
    Join Date
    Oct 2004
    Location
    Canada
    Posts
    1,034
    Quote Originally Posted by Sebastiani View Post
    Anyone who's ever had to write a serious PHP program would tell you that the cake was actually made of wood. Unfortunately, all you get is a plastic knife.
    I agree, but Python is a great middle-ground. PHP drives me crazy to no end, and yet I'll still use it when I need to get a small script up and running. I guess that's its purpose.
    Warning: Have doubt in anything I post.

    GCC 4.5, Boost 1.40, Code::Blocks 8.02, Ubuntu 9.10 010001000110000101100101

  6. #21
    & the hat of GPL slaying Thantos's Avatar
    Join Date
    Sep 2001
    Posts
    5,681
    Quote Originally Posted by Mario F. View Post
    ... Or following an established analogy, you can hammer a nail down with a screwdriver. Problem is that it's much more difficult.

    On another note though I do have a question: The idea PHP could also be used to replace C++ is news to me. Could PHP build, say, a C++ compiler, or didn't you need to go back to C or C++ to produce the relevant libraries for the PHP interpreter?
    I used PHP to sit on port 25 and pretended to be an SMTP server. It passed the commands onto Postfix for the actual processing. My goal was only to sniff the MAIL FROM, RCPT TO, and Message-ID parts of the email. I couldn't get Postfix's before queue to communicate correctly in a reasonable amount of time.

    As I worked the script I ended up putting in black list checking and checking Google (the email ultimately ends up in Google Apps but we needed our own record of the email for legal purposes) to ensure the account existed before accepting the email.

    And then I put in some small fixes to make things run smoother.

    I choose to do this in PHP as it involved quite a bit of database and socket communications (at the very least I had to open a socket to the actual Postfix install). If I had to do it in C++ (all of which I have done in the past) it would have taken me a lot longer and gained us nothing.

    As for your specific example: I would rather write the compiler in PHP than C++ due to better standard libraries. I would rather use the compiler written in C++ than the one written in PHP due to the speed.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. PHP installation
    By ssharish2005 in forum Tech Board
    Replies: 8
    Last Post: 11-23-2007, 09:42 PM
  2. Replace a list with a new entry?
    By niponki in forum C Programming
    Replies: 4
    Last Post: 08-17-2005, 10:41 AM
  3. PHP on my Computer!
    By xxxrugby in forum Tech Board
    Replies: 4
    Last Post: 03-15-2005, 09:34 AM
  4. Replies: 5
    Last Post: 05-25-2004, 04:36 PM
  5. Need a new way to replace a constant
    By RustGod in forum C++ Programming
    Replies: 5
    Last Post: 10-29-2001, 03:05 PM