Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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 W., dobey, Braiam, karel Jan 25 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 W., dobey, Braiam, karel
If this question can be reworded to fit the rules in the help center, please edit the question.

1  
You maybe want to ask at Programmers. –  Braiam Jan 25 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 at 1:35

1 Answer 1

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:

http://stackoverflow.com/questions/2731022/do-comments-slow-down-an-interpreted-language

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.