10 replies
Guys I just had a lecture in OOP and the lecturer said something like:

"The fastest Programming Language is C++"

I don't know what that meant and why?

Can anyone help me out? Thanks
#faster
  • Profile picture of the author Eddieheli
    What he said is absolute bollocks
    The lecturer is a lecturer because he doesn't have enough knowledge to work as a programmer in the real world.
    There is no such thing as a fastest programming language. Its horses for courses, thats why there are so many of them.
    Fastest at what exactly?
    Machine code will be faster than C++ as it works at the machine level, but it will take longer to write a machine code program to do certain things than it would in C++
    A statement like C++ is the fastest programming language is the same as making a statement that a Ferrari is the fastest car.
    Which then becomes rubbish when I tell you I need the fastest car to take 8 people from Berlin to Paris.
    Signature

    Eddieheli -
    "Forget about all the reasons why something may not work. You only need to find one good reason why it will." ~ Dr. Robert Anthony

    {{ DiscussionBoard.errors[2696185].message }}
  • Profile picture of the author caesargus
    Where's the applause button?

    I agree with what the poster said above. I probably wouldn't go as far as to say he couldn't make it in the real world. Maybe he wants to give back his knowledge with people. Just because he's teaching doesn't mean that he couldn't hack it.

    As far as why C++ is the fastest language ... (which it isn't) it's because 1 it's a compiled language. Compiled languages/programs have an advantage over interpreted languages (PHP is a great example). That's because compiled languages are broken down to machine code which the computer doesn't have to think about what it's doing. Think of it this way - Person A (C++) walks up to you and starts talking to you in your native language (compiled code) and you can do exactly what he wants because you can understand each other. Person B (PHP) walks up to you and makes the same request but it's in their language (interpreted) but you understand because you're a smart cookie - but it takes a bit longer because they are not talking to you in your native language.

    Make sense?

    C++ is faster - but what is it compared against? C++ is not faster than C and certainly not faster than Assembly language.
    {{ DiscussionBoard.errors[2697449].message }}
    • Profile picture of the author Tango_T50
      Originally Posted by caesargus View Post

      Where's the applause button?

      I agree with what the poster said above. I probably wouldn't go as far as to say he couldn't make it in the real world. Maybe he wants to give back his knowledge with people. Just because he's teaching doesn't mean that he couldn't hack it.

      As far as why C++ is the fastest language ... (which it isn't) it's because 1 it's a compiled language. Compiled languages/programs have an advantage over interpreted languages (PHP is a great example). That's because compiled languages are broken down to machine code which the computer doesn't have to think about what it's doing. Think of it this way - Person A (C++) walks up to you and starts talking to you in your native language (compiled code) and you can do exactly what he wants because you can understand each other. Person B (PHP) walks up to you and makes the same request but it's in their language (interpreted) but you understand because you're a smart cookie - but it takes a bit longer because they are not talking to you in your native language.

      Make sense?

      C++ is faster - but what is it compared against? C++ is not faster than C and certainly not faster than Assembly language.
      Definitely, it makes sense. Great explanation and example there mate!

      The lecturer compared C++ to other high level languages such as JAVA etc...

      Thank you very much.
      {{ DiscussionBoard.errors[2697621].message }}
      • Profile picture of the author emmamartin
        After saw above discussion I found many intersting review about this and as accoeding to me C++ is only assured a win when the program runs for a very short period of time or when compiled with the Intel C++ compiler . If you have long-running programs and compile with either MSVC or GCC, theres a good chance that Java will beat the pants off the C++ program.
        {{ DiscussionBoard.errors[2698250].message }}
        • Profile picture of the author garyk1968
          Originally Posted by emmamartin View Post

          After saw above discussion I found many intersting review about this and as accoeding to me C++ is only assured a win when the program runs for a very short period of time or when compiled with the Intel C++ compiler . If you have long-running programs and compile with either MSVC or GCC, theres a good chance that Java will beat the pants off the C++ program.
          Its highly unlikely java will 'beat the pants off' of C++. One is byte code run through a virtual machine, one is compiled, and typically the compiled app will run faster. Even with just in time compilation for Java to improve performance I dont think its as good as native code compilation.

          What the lecturer should have said is that native code compiled languages are typically faster. I use Delphi which is just as fast as C++ as it compiles to machine code.

          The other thing the lecturer missed is that in the 'real world' you are typically talking to a database across a network so you have DB and LAN performance to factor in.

          Gary
          {{ DiscussionBoard.errors[2719684].message }}
      • Profile picture of the author jminkler
        Originally Posted by Tango_T50 View Post


        The lecturer compared C++ to other high level languages such as JAVA etc...
        Better check his number, last I remember Java was kicking serious C++ butt (at most things)

        Paul Buchheit: Java running faster than C

        ok so maybe not at most things, but as other pointed out, its better when it is longer running.

        As a side note, Facebook compiles their PHP into C++ code
        {{ DiscussionBoard.errors[2714399].message }}
  • Profile picture of the author shawn.rodriges555
    Banned
    [DELETED]
    {{ DiscussionBoard.errors[2698552].message }}
  • Profile picture of the author iamjohnbrown
    I think that the professor might be saying it in the way that it is fast object oriented programming language. It is closer to the hardware I agree that but I think C is the most powerful one besides assembly.
    {{ DiscussionBoard.errors[2703119].message }}
  • Profile picture of the author wayfarer
    But don't get it wrong, C++ is extremely fast: more than 200 times faster than PHP in many cases.

    C, Java, and C++ all test in about the same range, with Java being faster at some things like object binding, and C and C++ being barely, but consistently faster than Java in the majority of benchmarks.

    Another fast language (that uses the JVM) is Scala.
    Signature
    I build web things, server things. I help build the startup Veenome. | Remote Programming Jobs
    {{ DiscussionBoard.errors[2712015].message }}
  • Profile picture of the author darthdeus
    If you want to compare execution speed of any algorithm, then Java is comparable, sometimes even faster than C++, but those are "lab benchmarks". Language itself is the last thing to consider with regard to speed.

    In programming and in life in general, there's this 80-20, or even 90-10 rule, which says, that 10% of the code takes 90% of execution speed.

    Let's say you have a website. You optimize your HTML generating library by 400%, which in result might be like 0,2ms difference, but what you don't realize is that connecting to the database takes 40ms.

    This is called Premature Optimization, it's basically trying to optimize before knowing and HAVING PROOF that you actually need it. By having proof I mean running profiler to figure out which parts of code take how long to execute.

    I can't stress out how important this is, it's the number one mistake all programmers make. Never ever ever ever ever ever optimize unless you know you you actually need to do it in that specific part of code, or you will waste incredible amounts of time on getting no result.

    You can go as far as writing obviously "slow" code to realize, that in the 50 methods you wrote this day, onle one was as slow as it seemed and needed to optimize.

    This way you might find out that you have one method that is called 40 000 times, while the others are called <100 times. That is the only time when you want to get into microoptimalization.

    In result, you might come to thinking that C++ is sometimes faster, so you write that part of code in native code and call it via JNI or something similar. That should work out right? But what if loading the native code to memory is slower than executing the same thing in Java? ...

    Can you see now, that speed is not about the language? C++ might be faster in some way, but Java is much faster to develop in, meaning you have more time to optimize the code.

    In lab settings, C++ is probably faster, but if you're writing big application, Java might give you 10% slower execution, but you also get 200% faster development so you can find those 10% that are slowing you down and optimize it.

    I have experience with programming in Java, Ruby, PHP and C++ and I can tell you, that even though PHP and Ruby is sometimes more than 4 times slower than C++, it doesn't matter at all. Unless you're working for NASA or doing some heavy math/physics simulations, in which case you wouldn't ask the question
    Signature
    Visit our website - Internet Marketing Tools on Darthopia

    And join the newsletter to get the Affiliate Sins Report with MRR!
    {{ DiscussionBoard.errors[2724683].message }}
  • Profile picture of the author sparckyz
    It maybe the fastest low level/high level hybrid language
    {{ DiscussionBoard.errors[2724727].message }}

Trending Topics