Space after if, while, etc (and before the paren)

I always thought that it was in order to differentiate them from function calls.


It's very subjective question, but there are code conventions. Example in Java: https://www.oracle.com/java/technologies/javase/codeconventions-whitespace.html

"Blank spaces should be used in the following circumstances: ...A keyword followed by a parenthesis..."

while (

or

for (

But with modern IDEs it's not a critical question anymore, in my opinion.

I prefer NOT to add a space in these cases (after keywords like for, but in function/method calls function() as well. I think, function () is less readable.