Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Do Empty spaces/text slow down code?

  1. Oct 27, 2014 #1
    If you are say running a for-loop with 5000 cycles, will 2 empty spaces and say 3-comments slow this operation down?
     
  2. jcsd
  3. Oct 27, 2014 #2

    jedishrfu

    Staff: Mentor

    In general, no.

    There are two methods of execution compile and run where code is converted to machine code and then run. This is the fastest option used for C/C++, Fortran...

    The second method is interpretive where each line is tokenized and the tokens are processed and run:

    http://en.wikipedia.org/wiki/Interpreter_(computing)

    If your spaces were within quotes and were being printed each time then that would slow things down very very slightly. The more data you process the longer it takes a program to run.

    However, in interpretive or compiled languages the spaces are removed from consideration as the code is converted to a more executable format.
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook