Possible advantage
Posted Jun 13, 2008 16:17 UTC (Fri) by
giraffedata (subscriber, #1954)
In reply to:
Possible advantage by tialaramex
Parent article:
Implications of pure and constant functions
I don't really see any advantage of making the code resemble the output of the compiler.
Hear, hear. There are two distinct ways to look at a program: 1) instructions to a computer; 2) description of the solution of a computational problem. The primary audience for (1) is a computer; for (2) it's a human. In view (2), a compiler's job is to produce a machine program that computes the solution described by the source code. A lot of programmers like to do that work themselves, but I think that is an inefficient use of brain power (for everyone who works on that code).
The closer the
resemblance between source and executable, the more chance you have of understanding what
you're seeing in the debugger.
That's definitely my experience. But there is a middle ground. I write human-oriented code and let the compiler do its job normally. But when I debug at the machine level I add -O0 to the compile options. That's usually described as "don't optimize", but as I consider optimization to be an integral part of the compiler's job, I view it as, "Make the machine program track the source code as closely as possible."
(
Log in to post comments)