Languages Without Garbage Collection

Continuing the discussion from Thinking about learning Crystal, let’s discuss - I was wondering which languages don’t GC - maybe we can compile a list and discuss some of them :nerd_face:

3 Likes

Well the basic common systems languages (I.E. languages for any purpose)
Assembly
C
C++
D
Fortran
Rust

Even things like Forth don’t either, lol.

There are a ton of non-GC languages though, but ‘most’ are of course specialized, like Brainf**k.

3 Likes

Corresponding tweet for this thread:

Share link for this tweet.

2 Likes

Haha, somehow I predicted you’d do something like this from the comment over there. What’s the status of Nim there? I heard it had an option of sorts? Zig maybe? I could be wrong about both.

2 Likes

Oh right, forgot about Zig, it’s GC-less too!

3 Likes

I just found this list:

no-new-objects:

  • Algol
  • Assembly (?)
  • C using the MISRA recommendations for embedded automotive systems
  • Fortran
  • SlideRule (ha ha, very funny…)

new objects, but no automatic collection:

  • Ada (originally)
  • C
  • CeePlusPlus (but see GarbageCollectionInCpp)
  • Cobol (prior to OO-COBOL)
  • Forth
  • ObjectiveC (but the standard frameworks and runtimes use ReferenceCounting [and optionally GarbageCollection in MacOsx 10.5+ and GnuStep])
  • Pascal
  • Pli
  • ExtendedObjectTcl
  • Rust
  • no runtime automatic collection - calls to malloc/free are handled at compile-time

From:

https://wiki.c2.com/?LanguagesWithoutGarbageCollection

Thi I think most of the more widely used ones are in your post @OvermindDL1 :smiley:

2 Likes

Swift, like Objective-C before it, uses automatic reference counting. So you don’t retain/release yourself. But it’s not garbage-collected. When a retain count goes to 0, the object goes away.

2 Likes

Thanks Jon! Looks like we can call Swift via Elixir/Erlang NIFs too:

The Mac series with the Apple Silicon M1 chip has been released. Weren’t you surprised by the amazing performance of it? I was also. I hoped we can use the wonderful power and Apple’s ecosystem for Elixir programming, so I tried to write Elixir code to call Swift code. This article shows how to call Swift code from Elixir via NIF.

https://zacky1972.medium.com/how-to-call-swift-5-3-code-from-elixir-via-nif-e317bac49c15

:smiley:

1 Like

What about V ?

Most objects (~90-100%) are freed by V’s autofree engine: the compiler inserts necessary free calls automatically during compilation. Remaining small percentage of objects is freed via reference counting.

The V Programming Language - DevTalk Forum

3 Likes