Neco

Languages and libraries

coroutine library

SHOW HN2024

145points
36comments
#584of 3,515 in 2024
Top 17%of 2024 by points

How HN took it

LovedMost comments that take a side are positive

4 positive, 10 neutral or asking, 0 mixed, 0 critical, out of 14 comments about the project. Thread score +0.18.

Design: 2 for, 0 againstExecution: 1 for, 0 againstPerformance: 1 for, 0 against

The thread, comment by comment

Each row is a top-level comment and its replies, in HN's order. Select a cell to open that comment on HN.

positive neutral or mixed critical about another commenter or something else the maker

What HN said

What people liked

  • Simple, elegant API and clean code

    From 3 comments
    • I love how simple and elegant is this to use: https://github.com/tidwall/neco/blob/main/examples/echo-server.c I was going to actually implement an echo server for load balancer…
      plagiat0r on HN
    • yeah i like this model. then you can use whatever synchronization junk you prefer to share state between the threads, if you have any. your library looks well written and clean.…
      trebecks on HN
    • This library aims to be the simplest and most efficient thing for what it does. And what it does is perfect for is managing communications with things that themselves may be…
      btilly on HN
  • Useful for I/O-bound work and multiplexing on a thread

    From 3 comments
    • the scheduler is probably simpler if coroutines can't bounce between cores. you can have a single thread per core that runs the scheduler to multiplex a bunch of coroutines on…
      trebecks on HN
    • Coroutines are still very useful for multitasking even if you're not sharing tasks between CPU cores. Other coroutines can just execute whenever something would normally block,…
      LoganDark on HN
    • This library aims to be the simplest and most efficient thing for what it does. And what it does is perfect for is managing communications with things that themselves may be…
      btilly on HN

Objections

  • Coroutines are not goroutines; no multi-core scheduling by default

    From 2 comments
    • Can someone help elucidate why "It's a non-goal for Neco to provide a scalable multithreaded runtime, where the coroutine scheduler is shared among multiple cpu cores [...]" this…
      dingdingdang on HN
    • Goroutines aren't coroutines. This isn't a nitpick, it's pretty essential to understanding the goals and non-goals of Neco. Coroutines are a control-flow primitive which allows…
      samatman on HN
  • Debate over whether it truly provides symmetric/asymmetric coroutine semantics

    From 2 comments
    • I think the replies l got here more or less proves my point. So a coroutine is basically something you can explicitly yield control flow from or give control flow to. neco…
      nialv7 on HN
    • These are coroutines. Just... look at the code, this isn't a proprietary binary product where you have to take someone's word for it. They're very clearly coroutines. I don't…
      samatman on HN

Requests

  • Clarify the naming and documentation of coroutine semantics

    From 2 comments
    • These are cooperatively scheduled green threads... I feel the word "coroutine" is slowly losing its original meaning, similar to what happened to "lambda".
      nialv7 on HN
    • In "Example 4", I don't understand where the "arg2" in `free(arg2)` is coming from?
      Karellen on HN

Questions

  • How does it work on WebAssembly without native stack switching?

    From 2 comments
    • How does it work on WebAssembly, where there's no native support for stack switching? Does it rely on Emscripten's Asyncify transformation?
      comex on HN
    • Yes according to the caveats section in the llco subproject: > Webassembly: Must be compiled with Emscripten using the -sASYNCIFY flag.
      StayTrue on HN
  • How does neco_sleep avoid saturating the CPU?

    From 2 comments
    • Can someone explain how this works please? How does it prevent this from saturating the CPU? ``` while (1) { neco_sleep(NECO_SECOND*2); printf("tock\n"); } ```
      burntcaramel on HN
    • I encourage you to dig through the source. There's not that much. Either this is a library you might use, so you should obviously review the code before you include it in your…
      swatcoder on HN

Alternatives named

  • libaco

    From 2 comments
    • I’ve used libaco with a lot of success in the past (mixing uv, curl, and zlib in a way that made the zlib loop easier to manage (since it looked like a normal read, decompress…
      jonhohle on HN
    • yeah i like this model. then you can use whatever synchronization junk you prefer to share state between the threads, if you have any. your library looks well written and clean.…
      trebecks on HN
  • libco

    From 1 comment
    • yeah i like this model. then you can use whatever synchronization junk you prefer to share state between the threads, if you have any. your library looks well written and clean.…
      trebecks on HN
  • Bunki

    From 1 comment
    • It's a little lower level than what you have, but you may find somethings interesting here: https://github.com/Keith-Cancel/Bunki
      anfilt on HN

Category, keywords, summaries and labels on this page were made by AI (Thread Reader v2) and not checked by hand. Each point links to the comments it came from.

Add a badge to your READMEShown on HackerShow
[![Shown on HackerShow](https://hackershow.org/badge.svg)](https://hackershow.org/show/39971984)