Skip to main content
add examples of runtime libraries to show GCs aren’t special
Source Link
Konrad Rudolph
  • 13.1k
  • 4
  • 58
  • 76

Or does the compiler include some minimal garbage collector in the compiled program's code.

That’s an odd way of saying “the compiler links the program with a library that performs garbage collection”. But yes, that’s what’s happening.

This is nothing special: compilers usually link tons of libraries into the programs they compile; otherwise compiled programs couldn’t do very much without re-implementing many things from scratch: even writing text to the screen/a file/… requires a library. Or

But maybe GC is different from these other libraries, as mentioned in comments onwhich provide explicit APIs that the other answeruser calls?

No: in most languages, allocating dynamic storage for objects atthe runtime requireslibraries do a librarylot of behind-the-scenes work without public-facing API, beyond GC. Consider these three examples:

  1. Exception propagation and stack unwinding/destructor calling.
  2. Dynamic memory allocation (which is usually not just calling a function, as in C, even when there’s no garbage collection).
  3. Tracking of dynamic type information (for casts etc).

So a garbage collectingcollection library isn’t at all that special, and a priori has nothing to do with whether a program was compiled ahead of time.

Or does the compiler include some minimal garbage collector in the compiled program's code.

That’s an odd way of saying “the compiler links the program with a library that performs garbage collection”. But yes, that’s what’s happening.

This is nothing special: compilers usually link tons of libraries into the programs they compile; otherwise compiled programs couldn’t do very much without re-implementing many things from scratch: even writing text to the screen/a file/… requires a library. Or, as mentioned in comments on the other answer, allocating dynamic storage for objects at runtime requires a library.

So a garbage collecting library isn’t all that special, and a priori has nothing to do with whether a program was compiled ahead of time.

Or does the compiler include some minimal garbage collector in the compiled program's code.

That’s an odd way of saying “the compiler links the program with a library that performs garbage collection”. But yes, that’s what’s happening.

This is nothing special: compilers usually link tons of libraries into the programs they compile; otherwise compiled programs couldn’t do very much without re-implementing many things from scratch: even writing text to the screen/a file/… requires a library.

But maybe GC is different from these other libraries, which provide explicit APIs that the user calls?

No: in most languages, the runtime libraries do a lot of behind-the-scenes work without public-facing API, beyond GC. Consider these three examples:

  1. Exception propagation and stack unwinding/destructor calling.
  2. Dynamic memory allocation (which is usually not just calling a function, as in C, even when there’s no garbage collection).
  3. Tracking of dynamic type information (for casts etc).

So a garbage collection library isn’t at all special, and a priori has nothing to do with whether a program was compiled ahead of time.

deleted 1 character in body
Source Link
Konrad Rudolph
  • 13.1k
  • 4
  • 58
  • 76

Or does the compiler include some minimal garbage collector in the compiled program's code.

That’s an odd way of saying “the compiler links the program with a library that performs garbage collection”. But yes, that’s what’s happening.

It isn’t very odd eitherThis is nothing special: compilers usually link tons of libraries into the programs they compile; otherwise compiled programs couldn’t do very much without re-implementing many things from scratch: even writing text to the screen/a file/… requires a library. Or, as mentioned in comments on the other answer, allocating dynamic storage for objects at runtime requires a library.

So a garbage collecting library isn’t all that special, and a priori has nothing to do with whether a program was compiled ahead of time.

Or does the compiler include some minimal garbage collector in the compiled program's code.

That’s an odd way of saying “the compiler links the program with a library that performs garbage collection”. But yes, that’s what’s happening.

It isn’t very odd either: compilers usually link tons of libraries into the programs they compile; otherwise compiled programs couldn’t do very much without re-implementing many things from scratch: even writing text to the screen/a file/… requires a library. Or, as mentioned in comments on the other answer, allocating dynamic storage for objects at runtime requires a library.

So a garbage collecting library isn’t all that special, and a priori has nothing to do with whether a program was compiled ahead of time.

Or does the compiler include some minimal garbage collector in the compiled program's code.

That’s an odd way of saying “the compiler links the program with a library that performs garbage collection”. But yes, that’s what’s happening.

This is nothing special: compilers usually link tons of libraries into the programs they compile; otherwise compiled programs couldn’t do very much without re-implementing many things from scratch: even writing text to the screen/a file/… requires a library. Or, as mentioned in comments on the other answer, allocating dynamic storage for objects at runtime requires a library.

So a garbage collecting library isn’t all that special, and a priori has nothing to do with whether a program was compiled ahead of time.

Source Link
Konrad Rudolph
  • 13.1k
  • 4
  • 58
  • 76

Or does the compiler include some minimal garbage collector in the compiled program's code.

That’s an odd way of saying “the compiler links the program with a library that performs garbage collection”. But yes, that’s what’s happening.

It isn’t very odd either: compilers usually link tons of libraries into the programs they compile; otherwise compiled programs couldn’t do very much without re-implementing many things from scratch: even writing text to the screen/a file/… requires a library. Or, as mentioned in comments on the other answer, allocating dynamic storage for objects at runtime requires a library.

So a garbage collecting library isn’t all that special, and a priori has nothing to do with whether a program was compiled ahead of time.