-5

As we know that C is a compiled language. According to C language Wikipedia it says that:

It was designed to be compiled using a relatively straightforward compiler, to provide low-level access to memory, to provide language constructs that map efficiently to machine instructions, and to require minimal run-time support. It also says that by design, C provides constructs that map efficiently to typical machine instructions, and therefore it has found lasting use in applications that had formerly been coded in assembly language, including operating systems, as well as various application software for computers ranging from supercomputers to embedded systems.

But when I read this & according to Thinking in C++ 2 by Bruce Eckel it says that in Chapter 2 titled Iostreams: (I've omitted some parts)

The big stumbling block is the runtime interpreter used for the variable-argument list functions. This is the code that parses through your format string at runtime and grabs and interprets arguments from the variable argument list. It’s a problem for four reasons.

Because the interpretation happens at runtime there’s a performance overhead you can’t get rid of. It’s frustrating because all the information is there in the format string at compile time, but it’s not evaluated until runtime. However, if you could parse the arguments in the format string at compile time you could make hard function calls that have the potential to be much faster than a runtime interpreter (although the printf( ) family of functions is usually quite well optimized).

this link also says that:

  • More type-safe: With , the type of object being I/O’d is known statically by the compiler. In contrast, cstdio uses "%" fields to figure out the types dynamically.

So before reading this I was thinking that interpreter isn't used in compiled language like C, but Is it really true that the runtime interpreter also available during execution of C program? Was I wrong before reading this? Is it really so much overhead occurs for this runtime interpretation compared to Iostreams?

Destructor
  • 14,123
  • 11
  • 61
  • 126
  • @Downvoters: Who downvoted? Why downvotes? I am not saying that this is runtime interpretation of code I am saying about functions format string interpretation. – Destructor Jul 02 '15 at 14:29
  • 3
    The language is compiled. One of the things that is compiled is a format string interpreter. – Raymond Chen Jul 02 '15 at 14:31
  • This is *not* the compiler it is a *library function* that is doing the interpreting. – Galik Jul 02 '15 at 14:38

1 Answers1

5

What?

This is not runtime interpretation of the code, just inside functions using formatting strings.

Of course they have to loop over the format string to learn about the arguments and the desired formatting, which takes time.

unwind
  • 391,730
  • 64
  • 469
  • 606