4

Background

I have just finished writing a compiler for a functional language compiling to the JVM as a learning project. However, since I'm just doing this to learn, I thought it might be interesting to write a native backend and a RTS for it.

As I've been planning out what this new backend will look like, the one point I'm stumbling on is the garbage collector. I've implemented the compiler in Haskell. But I have no desire to write the GC in Haskell since, while it may be possible, it'd suck.

Question

I've looked at several FOSS garbage collectors prior to posting and most of them were implemented in good old ANSI C. Is this still the most accepted choice for writing a GC nowadays?

I've seen that this site tends to frown upon questions with multiple answers so I hope this will make it more specific: If some startup was writing a professional grade gc today, are the only viable choice for them C or C++?

It's my first question here so please comment and let me know if this question is ill-suited for for programmers.

6
  • 3
    There are dozens of options: hardware GC, Forth, even a managed language-based GC (e.g., first prototype of .NET GC was implemented in Lisp).
    – SK-logic
    Jun 30, 2013 at 15:08
  • 3
    Are there any actively maintained GCs like this? It'd be nice to see how they differ from the ones I've looked at so far.
    – user95312
    Jun 30, 2013 at 15:11
  • Take a look at Tachyon meta-circular JavaScript JIT compiler, its GC is written in JavaScript, and it seems to be actively maintained.
    – SK-logic
    Jul 1, 2013 at 16:21
  • @SK-logic The .NET GC was written in Lisp yes, but the Lisp was compiled to C++ and avoided closures + other advanced lisp features.. See comments of blogs.msdn.com/b/patrick_dussud/archive/2006/11/21/… Jul 2, 2013 at 1:07
  • @SK-logic: Very good to know. From where did you get this information? I want to know about .NET internals, like in what language is .NET's language and its compilers etc is written in. There's a lot of that say C++ but I think that they just assume this because is the language that almost all Microsoft product is written in (data from Microsoft).
    – Jack
    Jul 4, 2013 at 2:30

1 Answer 1

3

If some startup was writing a professional grade gc today, are the only viable choice for them C or C++?

No.

C is simply the lingua franca of systems programming, and often the first tool developers reach for when developing a new language, VM, or OS. That many GCs are written in C is simply a result of that fact.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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