# Async has not been implemented in the self-hosted compiler yet

**URL:** <https://ziggit.dev/t/async-has-not-been-implemented-in-the-self-hosted-compiler-yet/8360>\
**Category:** Help\
**Tags:** compiler\
**Created:** [February 4, 2025, 4:17pm UTC](https://ziggit.dev/t/async-has-not-been-implemented-in-the-self-hosted-compiler-yet/8360 "2025-02-04T16:17:51Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![carlhung](https://ziggit.dev/user_avatar/ziggit.dev/carlhung/32/4153_2.png) [@carlhung](https://ziggit.dev/u/carlhung)\
**Post date:** [February 4, 2025, 4:17pm UTC](https://ziggit.dev/t/async-has-not-been-implemented-in-the-self-hosted-compiler-yet/8360/1 "2025-02-04T16:17:51Z")

</div>

I have just started learning zig. When I tried to learn async/await, I got the error below:

```zig
carlhung@orangepi5:~/externalDisk/projects/zigProjects/playground$ /home/carlhung/zig-linux-aarch64-0.13.0/zig build run
run
└─ run playground
   └─ install
      └─ install playground
         └─ zig build-exe playground Debug native 1 errors
src/main.zig:24:12: error: async has not been implemented in the self-hosted compiler yet
    frame: anyframe,
           ^ ~~~~~~~
error: the following command failed with 1 compilation errors:
/home/carlhung/zig-linux-aarch64-0.13.0/zig build-exe -ODebug -Mroot=/home/carlhung/externalDisk/projects/zigProjects/playground/src/main.zig --cache-dir /home/carlhung/externalDisk/projects/zigProjects/playground/.zig-cache --global-cache-dir /home/carlhung/.cache/zig --name playground --listen=- 
Build Summary: 2/7 steps succeeded; 1 failed (disable with --summary none)
run transitive failure
└─ run playground transitive failure
   ├─ zig build-exe playground Debug native 1 errors
   └─ install transitive failure
      └─ install playground transitive failure
         └─ zig build-exe playground Debug native (reused)
error: the following build command failed with exit code 1:
/home/carlhung/externalDisk/projects/zigProjects/playground/.zig-cache/o/7d48377dd31240794169e97adf718a28/build /home/carlhung/zig-linux-aarch64-0.13.0/zig /home/carlhung/externalDisk/projects/zigProjects/playground /home/carlhung/externalDisk/projects/zigProjects/playground/.zig-cache /home/carlhung/.cache/zig --seed 0x1369ce92 -Z2a9ce52a4416686f run

```

I checked the version of zig:

```zig
$ zig version
0.13.0

```

my device:

```zig
$ cat /etc/os-release
PRETTY_NAME="Armbian 24.11.3 bookworm"
NAME="Debian GNU/Linux"
VERSION_ID="12"
VERSION="12 (bookworm)"
VERSION_CODENAME=bookworm
ID=debian
HOME_URL="https://www.armbian.com"
SUPPORT_URL="https://forum.armbian.com"
BUG_REPORT_URL="https://www.armbian.com/bugs"
ARMBIAN_PRETTY_NAME="Armbian 24.11.3 bookworm"

```

---

<div class="post-metadata">

**Author:** ![floooh](https://ziggit.dev/user_avatar/ziggit.dev/floooh/32/2989_2.png) [@floooh](https://ziggit.dev/u/floooh)\
**Post date:** [February 4, 2025, 4:23pm UTC](https://ziggit.dev/t/async-has-not-been-implemented-in-the-self-hosted-compiler-yet/8360/2 "2025-02-04T16:23:58Z")

</div>

I think this FAQ entry might be relevant 🙂

> **[FAQ](https://github.com/ziglang/zig/wiki/FAQ#what-is-the-status-of-async-in-zig)**
>
> General-purpose programming language and toolchain for maintaining robust, optimal, and reusable software. - ziglang/zig

---

<div class="post-metadata">

**Author:** ![Sze](https://ziggit.dev/user_avatar/ziggit.dev/sze/32/496_2.png) [@Sze](https://ziggit.dev/u/Sze)\
**Post date:** [February 4, 2025, 4:49pm UTC](https://ziggit.dev/t/async-has-not-been-implemented-in-the-self-hosted-compiler-yet/8360/3 "2025-02-04T16:49:42Z")

</div>

> [@What is the status of async with Zig?](https://ziggit.dev/t/what-is-the-status-of-async-with-zig/5715):
>
> I’m just wondering what is the status and if the core team has plans on adding it back at all. My core use of Zig is to build HTTP services and on that space async is really needed.

---

<div class="post-metadata">

**Author:** ![carlhung](https://ziggit.dev/user_avatar/ziggit.dev/carlhung/32/4153_2.png) [@carlhung](https://ziggit.dev/u/carlhung)\
**Post date:** [February 9, 2025, 11:31pm UTC](https://ziggit.dev/t/async-has-not-been-implemented-in-the-self-hosted-compiler-yet/8360/4 "2025-02-09T23:31:00Z")

</div>

This is disappointing. I think I will come back again once they have implemented async/await.

---

<div class="post-metadata">

**Author:** ![ForeverZer0](https://ziggit.dev/user_avatar/ziggit.dev/foreverzer0/32/2443_2.png) [@ForeverZer0](https://ziggit.dev/u/ForeverZer0)\
**Post date:** [February 10, 2025, 1:13am UTC](https://ziggit.dev/t/async-has-not-been-implemented-in-the-self-hosted-compiler-yet/8360/5 "2025-02-10T01:13:09Z")

</div>

> async/await

To be pedantic, I would reconsider if/when Zig gets native _concurrency_ support, which may or not use the async/await paradigm. In my perfect world, I would personally rather see something more akin to Go’s channels, as I am not a fan of function coloring.

---

<div class="post-metadata">

**Author:** ![AndrewKraevskii](https://ziggit.dev/user_avatar/ziggit.dev/andrewkraevskii/32/2564_2.png) [@AndrewKraevskii](https://ziggit.dev/u/AndrewKraevskii)\
**Post date:** [February 10, 2025, 1:54am UTC](https://ziggit.dev/t/async-has-not-been-implemented-in-the-self-hosted-compiler-yet/8360/6 "2025-02-10T01:54:59Z")

</div>

If async comes back it will be colorblind as it was before [What is Zig's “Colorblind” Async/Await? | Loris Cro's Blog](https://kristoff.it/blog/zig-colorblind-async-await/) so function coloring is not an issue

---

<div class="post-metadata">

**Author:** ![ForeverZer0](https://ziggit.dev/user_avatar/ziggit.dev/foreverzer0/32/2443_2.png) [@ForeverZer0](https://ziggit.dev/u/ForeverZer0)\
**Post date:** [February 10, 2025, 2:36am UTC](https://ziggit.dev/t/async-has-not-been-implemented-in-the-self-hosted-compiler-yet/8360/7 "2025-02-10T02:36:53Z")

</div>

Interesting read. I liked his closing statement:

> I think goroutines are preferable in that context because async/await is a much lower level tool that is easy to misuse, but when it comes to writing code with critical requirements of correctness and efficiency, you need async/await and you need Zig’s philosophy that we all should strive to write **robust** , **optimal** , and **reusable** software.

This is a very compelling point that I didn’t think of. So long as function-coloring is a non-issue, I wouldn’t mind async/await, it is an intuitive pattern to use.

---

<div class="post-metadata">

**Author:** ![floooh](https://ziggit.dev/user_avatar/ziggit.dev/floooh/32/2989_2.png) [@floooh](https://ziggit.dev/u/floooh)\
**Post date:** [February 10, 2025, 10:21am UTC](https://ziggit.dev/t/async-has-not-been-implemented-in-the-self-hosted-compiler-yet/8360/8 "2025-02-10T10:21:28Z")

</div>

async/await also has a ‘hidden complexity’ (or even hidden-control-flow) problem, e.g. the function bodies produced by the compiler have not much in common with the sequential code you’re writing since the sequential code is split into a switch-case state machine with an imlicit context parameter.

The only advantage over ‘green-thread coroutines’ is that it works even on runtime environments which don’t allow to switch the stack (but the only relevant target platform which doesn’t allow stack switching is WASM - but that is being worked on: [GitHub - WebAssembly/stack-switching: A repository for the stack switching proposal.](https://github.com/WebAssembly/stack-switching))

Debuggability is also a concern (I think both approaches need special debugger support).

IMHO: I would like to see that most Zig libraries simply using completion callbacks for asynchronous code as the least common denominator, since completion callbacks are the common base that can then wrapped in async/await, green-threading or multithreading code (e.g. such a Zig library would be usable with all those concurrency and parallelism concepts)

---

<div class="post-metadata">

**Author:** ![D-Berg](https://ziggit.dev/user_avatar/ziggit.dev/d-berg/32/4195_2.png) [@D-Berg](https://ziggit.dev/u/D-Berg)\
**Post date:** [February 12, 2025, 2:24pm UTC](https://ziggit.dev/t/async-has-not-been-implemented-in-the-self-hosted-compiler-yet/8360/9 "2025-02-12T14:24:47Z")

</div>

Haven’t personally used it but maybe it’s worth looking into using [GitHub - libuv/libuv: Cross-platform asynchronous I/O](https://github.com/libuv/libuv)

---

<div class="post-metadata">

**Author:** ![Cloudef](https://ziggit.dev/user_avatar/ziggit.dev/cloudef/32/1370_2.png) [@Cloudef](https://ziggit.dev/u/Cloudef)\
**Post date:** [February 12, 2025, 11:58pm UTC](https://ziggit.dev/t/async-has-not-been-implemented-in-the-self-hosted-compiler-yet/8360/10 "2025-02-12T23:58:42Z")

</div>

I don’t personally like callback based async, so I wrote [https://github.com/Cloudef/zig-aio](https://github.com/Cloudef/zig-aio)
