frontpage.
newsnewestaskshowjobs

Open Source @Github

fp.

Open in hackernews

Show HN: Cwist; a hobby-grade C17 web framework that keeps your app simple

https://github.com/c4punks/cwist
1•gg582•42m ago
First of all, I'm not claiming that my framework will save industrial C/C++ development. It's just a hobby project.

Industrial code needs safer code, not easier code. But when you're developing a blog at 8 PM, long template errors are annoying.

You need CRUD and RDBMS. It's simple.

CWIST is for that kind of work.

It sacrifices memory safety, smart pointers, and modern C++ abstractions. In return, compile errors are more predictable.

  #include <stdio.h>
  #include <cwist/app.h>
  #include <cwist/core/db/pool.h>
  #include <cwist/core/template/template.h>
  
  static cwist_db_pool_t *g_db_pool;
  
  static void send_error(cwist_http_response *res, const char *msg) {
    res->status_code = CWIST_HTTP_INTERNAL_ERROR;
    cwist_http_header_add(&res->headers, "Content-Type", "text/plain");
    cwist_sstring_assign(res->body, msg);
  }
  
  static void render(cwist_http_response *res, const char *path, cJSON *ctx) {
    cwist_sstring *html = cwist_template_render_file(path, ctx);
    if (html) {
      cwist_http_header_add(&res->headers, "Content-Type", "text/html");
      cwist_sstring_assign(res->body, html->data);
      cwist_sstring_destroy(html);
    }
    cJSON_Delete(ctx);
  }
  
  static void handle_index(cwist_http_request *req, cwist_http_response *res) {
    (void)req;
    cJSON *ctx = cJSON_CreateObject();
    cJSON_AddStringToObject(ctx, "title", "CWIST Example");
    cJSON_AddStringToObject(ctx, "greeting", "Hello from CWIST");
    render(res, "templates/index.html", ctx);
  }
  
  static void handle_users(cwist_http_request *req, cwist_http_response *res) {
    (void)req;
    if (!g_db_pool) return send_error(res, "database pool unavailable");
  
    cwist_db_pool_exec(g_db_pool,
      "CREATE TABLE IF NOT EXISTS users (id INTEGER PRIMARY KEY, name TEXT);"
      "INSERT INTO users (name) SELECT 'Alice' WHERE NOT EXISTS "
      "(SELECT 1 FROM users WHERE name = 'Alice');"
      "INSERT INTO users (name) SELECT 'Bob' WHERE NOT EXISTS "
      "(SELECT 1 FROM users WHERE name = 'Bob');");
  
    cJSON *rows = NULL;
    if (cwist_db_pool_query(g_db_pool,
        "SELECT id, name FROM users ORDER BY id;", &rows).error.err_i16)
      return send_error(res, "failed to query database");
  
    cJSON *ctx = cJSON_CreateObject();
    cJSON_AddItemToObject(ctx, "users", rows ? rows : cJSON_CreateArray());
    render(res, "templates/users.html", ctx);
  }
  
  static void handle_health(cwist_http_request *req, cwist_http_response *res) {
    (void)req;
    cwist_http_header_add(&res->headers, "Content-Type", "text/plain");
    cwist_sstring_assign(res->body, "ok");
  }
  
  int main(void) {
    g_db_pool = cwist_db_pool_create("./app.db", 1);
    if (!g_db_pool) return 1;
  
    cwist_app *app = cwist_app_create();
    cwist_app_get(app, "/", handle_index);
    cwist_app_get(app, "/users", handle_users);
    cwist_app_get(app, "/health", handle_health);
    cwist_app_use_https(app, "cert.pem", "key.pem");
    cwist_app_listen(app, 8082);
    cwist_app_destroy(app);
    cwist_db_pool_destroy(g_db_pool);
    return 0;
  }

Code style is old and still small. The code is simple and stupid.

CWIST functions use the same `cwist_xx_xx` naming format. It's consistent. It's harder to make a slop in CWIST.

Features

- CWIST GC for fast prototyping. It's closer to a garbage sweeper than a traditional GC, and lighter. - Dev blog engine - HTML Template Engine - WASM

External benchmark: https://web-frameworks-benchmark.netlify.app/compare?f=cwist...

Latest results may be masked: https://github.com/the-benchmarker/web-frameworks/issues/977...

Unofficial results (not reliable): https://github.com/c4punks/CWIST/actions/runs/39000473564/jo...

Dev blog: https://oborona.zip Org: https://c4punks.github.io

It doesn't help my portfolio, but please star the project if you enjoyed it.

Special thanks to https://github.com/thegoodengineer for inviting organization members.

Decomp.dev Shuts Down Because AI Has Made It Too Easy to Decompile Games

https://www.404media.co/video-game-reverse-engineering-community-shuts-down-because-ai-has-made-i...
1•dmitrygr•4m ago•0 comments

What We Talk to When We Talk to Language Models (David J. Chalmers) [pdf]

https://philpapers.org/archive/CHAWWT-8.pdf
1•networked•7m ago•0 comments

Show HN: Calcy – unit-aware, uncertainty-propagating math

https://habitathq.github.io/calcy/
2•themantri•7m ago•0 comments

What has happened to Clipper2 development?

https://github.com/AngusJohnson/Clipper2/discussions/1118
1•abetusk•8m ago•0 comments

Show HN: I built a free collection of browser-based 3D tools

https://3dvalley.com
2•lucak5s•19m ago•0 comments

The Case Against Canadian Nuclear Weapons

https://ras-nsa.ca/en/the-case-against-canadian-nuclear-weapons/
1•JumpCrisscross•22m ago•0 comments

Rival Radar

https://rivalradar.me
1•pork1977•27m ago•0 comments

Why Math Dumped OpenAI

https://raymyers.org/post/math-dumped-openai/
1•xeonmc•29m ago•0 comments

OpenAI outperforms Chinese models in cost per task

https://nikvdp.com/notes/cost-per-task-is-the-number-to-watch/
1•crazyphoton•30m ago•0 comments

Fired Georgia officer gave Flock surveillance camera access to ICE agent husband

https://www.wbrc.com/2026/10/16/police-officer-fired-sharing-flock-login-with-husband-who-works-ice/
2•chirau•35m ago•0 comments

'I'm Not Going to Have Blood on My Hands'

https://www.cjr.org/the-interview/nicole-noren-espn-producer-quit-protest-sports-betting-gambling...
1•Michelangelo11•35m ago•0 comments

Dha Best

http://kitchencooking.42web.io/
1•agasto•41m ago•0 comments

Ask HN: What is the most useful thing AI has done for you?

3•yitchelle•42m ago•3 comments

Show HN: Cwist; a hobby-grade C17 web framework that keeps your app simple

https://github.com/c4punks/cwist
1•gg582•42m ago•0 comments

Letters with 'suspicious substances' sent to US senators and election offices

https://www.bbc.com/news/articles/cmq8n513x523o
1•geox•44m ago•0 comments

Veda: An Operating System with Soul

https://github.com/vahmoh25/Veda/blob/main/documentation/images/paint.png
1•saeedmh100•46m ago•0 comments

Wernelo – Discover Communities, Creators and Projects

https://www.wernelo.com
1•koleemendov•47m ago•0 comments

Ukraine's data centre strikes have thrown Russia into turmoil

https://www.ft.com/content/dc21da0b-25b7-402e-8dbe-e7d9f7431b93
2•uxhacker•49m ago•0 comments

How an agentic chat interface can break

https://astralbeam.ai/blog/ten-agentic-chat-interface-failures
2•aakashns•51m ago•0 comments

Dependently Sorted Syntax and its Semantics – Carlo Angiuli [video]

https://www.youtube.com/watch?v=tTZFKkyJEtw
1•matt_d•52m ago•0 comments

Existential Risk from AI: An Exposition for Mathematicians

https://alkjash.github.io/ai-risk/
1•reasonableklout•56m ago•0 comments

The 39 pictures that changed the way we see men (for good and for bad)

https://www.theguardian.com/society/2026/oct/17/39-pictures-that-changed-the-way-we-see-men-for-g...
1•mellosouls•58m ago•0 comments

El Niño: Chief Minister 'prays' to farmers to save drinking water

https://www.downtoearth.org.in/amp/story/climate-change/super-el-ni%C3%B1o-telangana-chief-minist...
2•erbdex•58m ago•1 comments

Claude CRISPR-like sequence may be a parallel discovery of unpublished research

https://recul.ai/news/claude-viral-dna-pattern-priority-dispute/
2•opello•59m ago•1 comments

Networking problems after the October Windows update? NTLM might be to blame

https://www.theregister.com/security/2026/10/16/networking-problems-after-the-october-2026-window...
1•wondersky•1h ago•0 comments

Sterile Knowledge: Artificial Intelligence, and the Genealogy of Understanding

https://medium.com/@smoking2man/sterile-knowledge-artificial-intelligence-models-and-the-genealog...
1•Aldus551•1h ago•0 comments

Israeli settlers attack olive framers & Washington Post journalist in West Bank

https://www.theguardian.com/world/2026/oct/16/israeli-settlers-attack-olive-farmers-west-bank-was...
52•0x54MUR41•1h ago•10 comments

Mapping the China AI Ecosystem with Rui Ma [video]

https://www.youtube.com/watch?v=-RDpqweadlE
1•hunglee2•1h ago•0 comments

MIT Scientist (Sabatini) Wins $6M in Sexual Harassment Defamation Suit

https://www.nytimes.com/2026/10/16/us/mit-scientist-sexual-harassment-defamation-lawsuit-david-sa...
2•osnium123•1h ago•0 comments

Ask HN: For those who left Big Tech for early-stage startups, do you regret it?

3•Peaceful-Hours•1h ago•1 comments