Do Empty spaces/text slow down code?

  • Thread starter Thread starter Jarfi
  • Start date Start date
  • Tags Tags
    Code Empty
Join the discussion
Registration is free. Ask a follow-up in this thread, or start your own.
1 reply · 1K views
Jarfi
Messages
384
Reaction score
12
If you are say running a for-loop with 5000 cycles, will 2 empty spaces and say 3-comments slow this operation down?
 
Physics news on Phys.org
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.
 
  • Like
Likes   Reactions: elusiveshame