aboutsummaryrefslogtreecommitdiff
path: root/content/posts/2023-08-22-comments-2.smd
diff options
context:
space:
mode:
authorMartin Ashby <martin@ashbysoft.com>2024-12-21 22:18:18 +0000
committerMartin Ashby <martin@ashbysoft.com>2024-12-21 22:18:18 +0000
commit82e7ac75954c973a5c59a02684788c0fb26e14dd (patch)
treea1b09939f30bc4c232e69f980c2a47e48625ee1d /content/posts/2023-08-22-comments-2.smd
parentff323f79e03174e4cdf2a709c095ff83e7ea3669 (diff)
downloadmfashby.net-82e7ac75954c973a5c59a02684788c0fb26e14dd.tar.gz
mfashby.net-82e7ac75954c973a5c59a02684788c0fb26e14dd.tar.bz2
mfashby.net-82e7ac75954c973a5c59a02684788c0fb26e14dd.tar.xz
mfashby.net-82e7ac75954c973a5c59a02684788c0fb26e14dd.zip
Bump zine 0.3.0 -> 0.8.0
Fix a lot of associated breakage Fix broken rss.xml file as highlighted to me by Matthijs van der Wild (thanks!)
Diffstat (limited to 'content/posts/2023-08-22-comments-2.smd')
-rw-r--r--content/posts/2023-08-22-comments-2.smd17
1 files changed, 17 insertions, 0 deletions
diff --git a/content/posts/2023-08-22-comments-2.smd b/content/posts/2023-08-22-comments-2.smd
new file mode 100644
index 0000000..c75b3d4
--- /dev/null
+++ b/content/posts/2023-08-22-comments-2.smd
@@ -0,0 +1,17 @@
+---
+.title = "Comments 2",
+.author = "Martin Ashby",
+.date = @date("2023-08-22T14:48:41+01:00"),
+.layout = "single.shtml",
+.custom = {"comments": true},
+---
+
+[Previously](/posts/2022-12-30-comments/) I added a basic comment system to my website using a separate web server which served only the comment HTML. This is fine, but it does require another program running continuously on my server. Since that server is a raspberry pi, and it is running a lot of other software as well, and my blog doesn't get a lot of hits (let alone comments), I thought I could do better by using the [Common Gateway Interface (CGI)](https://en.wikipedia.org/wiki/Common_Gateway_Interface). CGI doesn't require a daemon program, but instead will launch a program to generate dynamic content when someone loads the page. In this way, no memory or CPU is required until an actual page is requested. The downside is that a new process is launched for each page load, but I think that's an OK trade-off for me. I already have CGI configured on my web server for running [cgit](/posts/2022-12-31-cgit).
+
+I also wanted to explore the [zig](https://ziglang.org/) programming language some more by writing an actual program with it, so I chose to rewrite it in zig.
+
+I made a [quick exploratory program](https://code.mfashby.net/cgifun/about/) just to remind myself how CGI works in Caddy, then I ported my original comments app to a [CGI app](https://code.mfashby.net/mfashby.net/tree/comments). The new app has far fewer dependencies since it doesn't embed a web server or web framework. It depends on the [zig standard library](https://ziglang.org/documentation/master/std/), [libpq](https://www.postgresql.org/docs/current/libpq.html), [mustache-zig](https://github.com/batiati/mustache-zig) and some of my own shared code from another project to do page routing.
+
+The new comments app works just the same as the old one, although with some loss of functionality - it no longer emails me when a new comment is posted. I plan to implement this, however the zig ecosystem is much less mature than rust right now, and I could not find a good email library so I might end up rolling my own.
+
+Another spin-off from this project could be a pure-zig postgres database library. Libpq is great, however it's a C library and requires linking the C standard library, and makes code less easily portable to other platforms. The [pgx](https://github.com/jackc/pgx) project shows that it's possible to have a pure-go postgresql driver, and this might be inspiration for a zig version. Another advantage of using the host language rather than the C library is making use of future [asynchronous capabilities](https://ziglearn.org/chapter-5/). \ No newline at end of file