Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

When I search for source-code of Linux parts (applications, kernels, ...), I often find commentaries to clarify the code.

Now, I know that those commentaries are useful to help a human reading the code, but I was wondering about the impact they have on the machine.

The commentaries aren't read by the machine, but I'm assuming the machine must at least read the first character of the line to know if it needs to read it or not :

Machine - "Does this line start with a # ? Yes, OK, moving on ! Uh, another line, does this one start with a # ? No !! AHA, let's read that mo****er !"

So, my question is :

  • Do the commentaries in the source-code slow down the machine (in a significant way, like 0,01% or more) ?

PS : maybe the builder which reads the code doesn't include the commentaries in the final program ?

share|improve this question

closed as off-topic by roadmr, Thomas Ward, dobey, Braiam, karel Jan 25 '14 at 0:31

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This is not about Ubuntu. Questions about other Linux distributions can be asked on Unix & Linux, those about Windows on Super User, those about Apple products on Ask Different and generic programming questions on Stack Overflow." – roadmr, Thomas Ward, dobey, Braiam, karel
If this question can be reworded to fit the rules in the help center, please edit the question.

You maybe want to ask at Programmers. – Braiam Jan 25 '14 at 0:26
Sorry about the off-topic thing. I have an acceptable answer from Roadmr (thanks to him). Should I ask anyway on Stack-Exchange and delete this thread, or do I leave this one as it and move on ? – MrVaykadji Jan 25 '14 at 1:35
up vote 4 down vote accepted

You mention the kernel as a program of concern. The kernel, and everything written in C, is compiled, so the source code is read and translated into machine code. All comments are stripped during this process. So you don't need to worry about any slowdown in comments.

Interpreted code, in, say, shell or python, could potentially suffer from comment-induced slowdown. But I'm certain it would be negligible. Comments are processed when parsing the program, at which point they would be stripped, thus they would affect the initial parsing time but not execution time.

Here's more on that topic:

So the bottom line is, you don't really need to worry about this slowing down things in any perceptible or relevant way.

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.