+ 3
Question About Memory
Will a block of code that is multiple lines but syntactically the same as a block of code with less lines, take up more memory? Are you using whitespace when moving to a new line? I'm guessing if there is a difference in memory, it is probably negligible. I am genuinely curious about this and would like to learn more about computer memory. Could anyone suggest some good resources? Thank you.
9 odpowiedzi
+ 8
In c++, and many other langs, whitespaces and new lines mainly serve for aesthetic purposes and won't have any memory impact at runtime (are ignored during compiling time).
Whitespaces are usually removed from Javascript files before delivering to decrease their size. It's due to the fact that .js files are plain text files that occupy space on user storage(and to decrease download time), it has nothing to do with the memory used by the program itself at runtime.
Always use withespaces/tabs/newlines to increase code readability and make it easier to debug.
+ 5
This may help you in your studies Ian Stewart though you will want to Google and read further on the subject.
Thanks and happy coding
https://www.tutorialspoint.com/computer_fundamentals/computer_memory.htm
+ 3
Thank you, BroFar and Kevin Star!
+ 3
use the @ and a name window opens then click on desired name Ian Stewart
+ 2
Awesome! Thank you BroFar!
+ 2
Interesting question. Fortunately, compilers aren't that gullible. They compile they same assembly code, regardless of the whitespace, because the syntax remains the same. It will probably compile a microsecond or so slower, but the executable file will be identical, so it will run at the same speed.
+ 1
welcome Ian Stewart
+ 1
How do I mention you?
+ 1
Makes sense, Raphi Spoerri . Thanks!