{"id":18014812,"url":"https://github.com/zevv/cpstest","last_synced_at":"2025-04-04T15:14:22.842Z","repository":{"id":150598993,"uuid":"378704641","full_name":"zevv/cpstest","owner":"zevv","description":null,"archived":false,"fork":false,"pushed_at":"2024-03-03T12:09:37.000Z","size":104,"stargazers_count":6,"open_issues_count":0,"forks_count":1,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-02-10T00:43:38.892Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Nim","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zevv.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2021-06-20T17:36:37.000Z","updated_at":"2024-09-12T13:20:20.000Z","dependencies_parsed_at":"2024-03-03T13:25:53.408Z","dependency_job_id":null,"html_url":"https://github.com/zevv/cpstest","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zevv%2Fcpstest","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zevv%2Fcpstest/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zevv%2Fcpstest/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zevv%2Fcpstest/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zevv","download_url":"https://codeload.github.com/zevv/cpstest/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247198466,"owners_count":20900081,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-30T04:11:11.262Z","updated_at":"2025-04-04T15:14:22.820Z","avatar_url":"https://github.com/zevv.png","language":"Nim","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n# CPS test\n\nThis is a test project to do some \"real\" work with CPS to see where CPS can\nshine, or to find where it is still lacking.\n\nIt is growing into small library for doing nice things with async CPS, providing\nbasic event queue handling, I/O primitives and network protocols.\n\n## Results so far\n\n### The good\n\n- CPS is fun! I'm having a blast - with a few lines of code I move continations\n  to run on a different thread, for example for DNS resolving. See `dial()` in\n  `conn.nim`\n\n- The quality of the CPS transformation is getting better by the day. For\n  day-to-day code I have not ran into big surprises, and any issues I did find\n  were often fixed within hours by the CPS authors.\n\n- CPS in it's current state offers a nice and usable API; it allows for a very\n  natural \"thread like\" feel, writing linear code and hiding all the gory async\n  details to CPS.\n\n- Performance of CPS is pretty good, the bottlenecks in this application are\n  mostly caused by me being lazy with memory allocations and string handling,\n  not by CPS.\n\n- I like how the CPS continuation type can be used to silently carry state\n  through the code without having to explicitly pass that around: in this case\n  the event queue instance is part of the continuation type, and allows all cps\n  code to do seamless I/O or timer handling.\n\n### The bad\n\n- Stack traces in CPS result in the \"real\" trace, typically from main() into\n  the event() queue into the current continuation leg. From a users perpsective\n  it would be nice if the trace could unwind over the cps 'mom' stack to give a\n  better idea of \"how I got there\".\n\n- Generics would come handy - I've been told these are to be expected shortly.\n\n- At this time there is no way to create CPS \"function pointers\" or \"closures\",\n  which makes it harder to compose with CPS and do things like callback\n  functions or vtables. Given the nature of CPS I'm not sure if something like\n  this would be feasible though.\n\n- Compilation times: CPS compilation is becoming a bit slow. Not a show stopper\n  for me yet.\n\n### The ugly\n\n- CPS and for loops don't play well - this is mostly a limitation of the Nim\n  macro system.\n\n\n## Contents\n\nThis project consists of the following parts:\n\n- types.nim: Shared types, including the basic continuation type\n- evq.nim: The core event queue for suspending continuations on I/O or timers\n- conn.nim: Low level CPS async socket handling: `dial()`, `bind()`, `send()`, `recv(), `close()`\n- bconn.nim: Async CPS bufferd I/O layer on top of conn. `readLine()` and friends\n- http.nim: Shared http code for reading and writing http requests and responses\n- httpclient.nim: Basic HTTP client\n- httpserver.nim: Basic HTTP server\n- main.nim: main application\n\n## Running\n\nnim r --gc:arc main.nim\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzevv%2Fcpstest","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzevv%2Fcpstest","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzevv%2Fcpstest/lists"}