Original Summary

First of all, I&#x27;m not claiming that my framework will save industrial C&#x2F;C++ development. It&#x27;s just a hobby project.<p>Industrial code needs safer code, not easier code. But when you&#x27;re developing a blog at 8 PM, long template errors are annoying.<p>You need CRUD and RDBMS. It&#x27;s simple.<p>CWIST is for that kind of work.<p>It sacrifices memory safety, smart pointers, and modern C++ abstractions. In return, compile errors are more predictable.<p><pre><code> #include &lt;stdio.h&gt; #include &lt;cwist&#x2F;app.h&gt; #include &lt;cwist&#x2F;core&#x2F;db&#x2F;pool.h&gt; #include &lt;cwist&#x2F;core&#x2F;template&#x2F;template.h&gt; static cwist_db_pool_t g_db_pool; static void send_error(cwist_http_response res, const char msg) { res-&gt;status_code = CWIST_HTTP_INTERNAL_ERROR; cwist_http_header_add(&amp;res-&gt;headers, &quot;Content-Type&quot;, &quot;text&#x2F;plain&quot;); cwist_sstring_assign(res-&gt;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(&amp;res-&gt;headers, &quot;Content-Type&quot;, &quot;text&#x2F;html&quot;); cwist_sstring_assign(res-&gt;body, html-&gt;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, &quot;title&quot;, &quot;CWIST Example&quot;); cJSON_AddStringToObject(ctx, &quot;greeting&quot;, &quot;Hello from CWIST&quot;); render(res, &quot;templates&#x2F;index.html&quot;, ctx); } static void handle_users(cwist_http_request req, cwist_http_response res) { (void)req; if (!g_db_pool) return send_error(res, &quot;database pool unavailable&quot;); cwist_db_pool_exec(g_db_pool, &quot;CREATE TABLE IF NOT EXISTS users (id INTEGER PRIMARY KEY, name TEXT);&quot; &quot;INSERT INTO users (name) SELECT &#x27;Alice&#x27; WHERE NOT EXISTS &quot; &quot;(SELECT 1 FROM users WHERE name = &#x27;Alice&#x27;);&quot; &quot;INSERT INTO users (name) SELECT &#x27;Bob&#x27; WHERE NOT EXISTS &quot; &quot;(SELECT 1 FROM users WHERE name = &#x27;Bob&#x27;);&quot;); cJSON rows = NULL; if (cwist_db_pool_query(g_db_pool, &quot;SELECT id, name FROM users ORDER BY id;&quot;, &amp;rows).error.err_i16) return send_error(res, &quot;failed to query database&quot;); cJSON ctx = cJSON_CreateObject(); cJSON_AddItemToObject(ctx, &quot;users&quot;, rows ? rows : cJSON_CreateArray()); render(res, &quot;templates&#x2F;users.html&quot;, ctx); } static void handle_health(cwist_http_request req, cwist_http_response res) { (void)req; cwist_http_header_add(&amp;res-&gt;headers, &quot;Content-Type&quot;, &quot;text&#x2F;plain&quot;); cwist_sstring_assign(res-&gt;body, &quot;ok&quot;); } int main(void) { g_db_pool = cwist_db_pool_create(&quot;.&#x2F;app.db&quot;, 1); if (!g_db_pool) return 1; cwist_app *app = cwist_app_create(); cwist_app_get(app, &quot;&#x2F;&quot;, handle_index); cwist_app_get(app, &quot;&#x2F;users&quot;, handle_users); cwist_app_get(app, &quot;&#x2F;health&quot;, handle_health); cwist_app_use_https(app, &quot;cert.pem&quot;, &quot;key.pem&quot;); cwist_app_listen(app, 8082); cwist_app_destroy(app); cwist_db_pool_destroy(g_db_pool); return 0; } </code></pre> Code style is old and still small. The code is simple and stupid.<p>CWIST functions use the same cwist_xx_xx naming format. It&#x27;s consistent. It&#x27;s harder to make a slop in CWIST.<p>Features<p>- CWIST GC for fast prototyping. It&#x27;s closer to a garbage sweeper than a traditional GC, and lighter. - Dev blog engine - HTML Template Engine - WASM<p>External benchmark: <a href="https:&#x2F;&#x2F;web-frameworks-benchmark.netlify.app&#x2F;compare?f=cwist,drogon" rel="nofollow">https:&#x2F;&#x2F;web-frameworks-benchmark.netlify.app&#x2F;compare?f=cwist...</a><p>Latest results may be masked: <a href="https:&#x2F;&#x2F;github.com&#x2F;the-benchmarker&#x2F;web-frameworks&#x2F;issues&#x2F;9775" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;the-benchmarker&#x2F;web-frameworks&#x2F;issues&#x2F;977...</a><p>Unofficial results (not reliable): <a href="https:&#x2F;&#x2F;github.com&#x2F;c4punks&#x2F;CWIST&#x2F;actions&#x2F;runs&#x2F;39000473564&#x2F;job&#x2F;117302127557" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;c4punks&#x2F;CWIST&#x2F;actions&#x2F;runs&#x2F;39000473564&#x2F;jo...</a><p>Dev blog: <a href="https:&#x2F;&#x2F;oborona.zip" rel="nofollow">https:&#x2F;&#x2F;oborona.zip</a> Org: <a href="https:&#x2F;&#x2F;c4punks.github.io" rel="nofollow">https:&#x2F;&#x2F;c4punks.github.io</a><p>It doesn&#x27;t help my portfolio, but please star the project if you enjoyed it.<p>Special thanks to <a href="https:&#x2F;&#x2F;github.com&#x2F;thegoodengineer" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;thegoodengineer</a> for inviting organization members.


  • 情报分类:工作与职业机会
  • 分类依据:内容涉及招聘、求职或职业发展
  • 信息来源:Hacker News 新项目
  • 发布时间:2026/10/17 14:06:10