Thread: C++ v's Perl

  1. #1
    Kev
    Join Date
    Aug 2005
    Posts
    3

    C++ v's Perl

    Hi Guys,

    I was just wondering if anyone knows the answer to this question i got asked in an interview yesterday:

    what makes c++ faster than perl?

    I dont have very much knowledge of perl but i would have thought that perl was faster in some circumstances. Does anyone know in what circumstances c++ would be faster?

    Thanks,

    Kev

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    Funny, I thought perl was faster than C++.
    Well it is if you include the time it takes to write the program as well as the time it takes to run the program.

    People who get hung up on spending weeks trying to get the last millisecond of performance out of a program which only runs for a few seconds anyway miss the point IMO.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    Registered User major_small's Avatar
    Join Date
    May 2003
    Posts
    2,787
    maybe because PERL is interpreted and C++ is compiled?

    AFAIK, PERL was never intened to be the best... just to make things easier...

    http://en.wikipedia.org/wiki/Perl
    http://en.wikipedia.org/wiki/C_Plus_Plus
    Last edited by major_small; 08-13-2005 at 03:11 AM.
    Join is in our Unofficial Cprog IRC channel
    Server: irc.phoenixradio.org
    Channel: #Tech


    Team Cprog Folding@Home: Team #43476
    Download it Here
    Detailed Stats Here
    More Detailed Stats
    52 Members so far, are YOU a member?
    Current team score: 1223226 (ranked 374 of 45152)

    The CBoard team is doing better than 99.16% of the other teams
    Top 5 Members: Xterria(518175), pianorain(118517), Bennet(64957), JaWiB(55610), alphaoide(44374)

    Last Updated on: Wed, 30 Aug, 2006 @ 2:30 PM EDT

  4. #4
    Registered User Jaqui's Avatar
    Join Date
    Feb 2005
    Posts
    416
    c++ is compiled into machine understandable code, faster for execution.

    perl is interpreted / compiled on the fly, making it slower at execution

    perl is faster in development, the compile stage isn't there.
    the debug is for exactly the code you used, no compiler optimisations.

    it's more a matter of what is the purpose of the application as to which is better.
    for a bash script or cgi, perl is often a better choice than c++.
    Quote Originally Posted by Jeff Henager
    If the average user can put a CD in and boot the system and follow the prompts, he can install and use Linux. If he can't do that simple task, he doesn't need to be around technology.

  5. #5
    Kev
    Join Date
    Aug 2005
    Posts
    3
    excellent... thanks for that!

  6. #6
    Registered User major_small's Avatar
    Join Date
    May 2003
    Posts
    2,787
    what answer did you give?
    Join is in our Unofficial Cprog IRC channel
    Server: irc.phoenixradio.org
    Channel: #Tech


    Team Cprog Folding@Home: Team #43476
    Download it Here
    Detailed Stats Here
    More Detailed Stats
    52 Members so far, are YOU a member?
    Current team score: 1223226 (ranked 374 of 45152)

    The CBoard team is doing better than 99.16% of the other teams
    Top 5 Members: Xterria(518175), pianorain(118517), Bennet(64957), JaWiB(55610), alphaoide(44374)

    Last Updated on: Wed, 30 Aug, 2006 @ 2:30 PM EDT

  7. #7
    Kev
    Join Date
    Aug 2005
    Posts
    3
    I said that... "my knowledge of perl is minimal but I would assume that it is faster in some cases beacuse it is an object oriented language... but I was on the spot and i didn't really know... i dont think that was a good answer.

  8. #8
    aoeuhtns
    Join Date
    Jul 2005
    Posts
    581
    Quote Originally Posted by Jaqui
    perl is faster in development, the compile stage isn't there.
    the debug is for exactly the code you used, no compiler optimisations.
    perl does do some optimisations.

    At the very least, it considers inlining functions that take no arguments.

  9. #9
    Registered User Jaqui's Avatar
    Join Date
    Feb 2005
    Posts
    416
    Quote Originally Posted by Rashakil Fol
    perl does do some optimisations.

    At the very least, it considers inlining functions that take no arguments.
    ahh, I didn't know that, but then I don't really know perl all that well.
    close to not at all actually.
    Quote Originally Posted by Jeff Henager
    If the average user can put a CD in and boot the system and follow the prompts, he can install and use Linux. If he can't do that simple task, he doesn't need to be around technology.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. C structure in perl typemap
    By rotis23 in forum Linux Programming
    Replies: 1
    Last Post: 07-16-2003, 11:13 AM
  2. de facto perl book
    By rotis23 in forum Linux Programming
    Replies: 1
    Last Post: 05-22-2003, 04:43 AM
  3. perl program question
    By newbie2c in forum Tech Board
    Replies: 2
    Last Post: 02-03-2003, 10:19 AM
  4. From Perl to C
    By Heavenstrash in forum C Programming
    Replies: 4
    Last Post: 06-19-2002, 01:22 AM
  5. perl need help pls.....
    By magnum38 in forum A Brief History of Cprogramming.com
    Replies: 0
    Last Post: 12-12-2001, 10:35 PM