# Languages Without Garbage Collection

**URL:** <https://forum.devtalk.com/t/languages-without-garbage-collection/9104>\
**Category:** General Dev Chat\
**Tags:** garbage-collection\
**Created:** [26 April 2021 17:46 UTC](https://forum.devtalk.com/t/languages-without-garbage-collection/9104 "2021-04-26T17:46:52Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![AstonJ](https://forum.devtalk.com/user_avatar/forum.devtalk.com/astonj/32/7_2.png) [@AstonJ](https://forum.devtalk.com/u/AstonJ)\
**Post date:** [26 April 2021 17:46 UTC](https://forum.devtalk.com/t/languages-without-garbage-collection/9104/1 "2021-04-26T17:46:52Z")

</div>

Continuing the discussion from [Thinking about learning Crystal, let’s discuss](https://forum.devtalk.com/t/thinking-about-learning-crystal-lets-discuss/9056/4) - I was wondering which languages don’t GC - maybe we can compile a list and discuss some of them 🤓

---

<div class="post-metadata">

**Author:** ![OvermindDL1](https://forum.devtalk.com/user_avatar/forum.devtalk.com/overminddl1/32/52_2.png) [@OvermindDL1](https://forum.devtalk.com/u/OvermindDL1)\
**Post date:** [26 April 2021 17:57 UTC](https://forum.devtalk.com/t/languages-without-garbage-collection/9104/2 "2021-04-26T17:57:05Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![mafinar](https://forum.devtalk.com/user_avatar/forum.devtalk.com/mafinar/32/723_2.png) [@mafinar](https://forum.devtalk.com/u/mafinar)\
**Post date:** [26 April 2021 18:01 UTC](https://forum.devtalk.com/t/languages-without-garbage-collection/9104/4 "2021-04-26T18:01:29Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![OvermindDL1](https://forum.devtalk.com/user_avatar/forum.devtalk.com/overminddl1/32/52_2.png) [@OvermindDL1](https://forum.devtalk.com/u/OvermindDL1)\
**Post date:** [26 April 2021 20:59 UTC](https://forum.devtalk.com/t/languages-without-garbage-collection/9104/5 "2021-04-26T20:59:48Z")

</div>

> [@mafinar](#):
>
> Zig

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

---

<div class="post-metadata">

**Author:** ![AstonJ](https://forum.devtalk.com/user_avatar/forum.devtalk.com/astonj/32/7_2.png) [@AstonJ](https://forum.devtalk.com/u/AstonJ)\
**Post date:** [26 April 2021 21:32 UTC](https://forum.devtalk.com/t/languages-without-garbage-collection/9104/6 "2021-04-26T21:32:35Z")

</div>

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](https://wiki.c2.com/?LanguagesWithoutGarbageCollection)

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

---

<div class="post-metadata">

**Author:** ![jonreid](https://forum.devtalk.com/user_avatar/forum.devtalk.com/jonreid/32/910_2.png) [@jonreid](https://forum.devtalk.com/u/jonreid)\
**Post date:** [29 April 2021 21:24 UTC](https://forum.devtalk.com/t/languages-without-garbage-collection/9104/7 "2021-04-29T21:24:25Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![AstonJ](https://forum.devtalk.com/user_avatar/forum.devtalk.com/astonj/32/7_2.png) [@AstonJ](https://forum.devtalk.com/u/AstonJ)\
**Post date:** [29 April 2021 22:47 UTC](https://forum.devtalk.com/t/languages-without-garbage-collection/9104/8 "2021-04-29T22:47:27Z")

</div>

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](https://zacky1972.medium.com/how-to-call-swift-5-3-code-from-elixir-via-nif-e317bac49c15)

😃

---

<div class="post-metadata">

**Author:** ![DevotionGeo](https://forum.devtalk.com/user_avatar/forum.devtalk.com/devotiongeo/32/1140_2.png) [@DevotionGeo](https://forum.devtalk.com/u/DevotionGeo)\
**Post date:** [6 May 2021 05:54 UTC](https://forum.devtalk.com/t/languages-without-garbage-collection/9104/9 "2021-05-06T05:54:58Z")

</div>

What about [V](https://vlang.io/) ?

> 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](https://forum.devtalk.com/t/the-v-programming-language)
