[HN Gopher] Why I chose Lua for this blog
       ___________________________________________________________________
        
       Why I chose Lua for this blog
        
       Author : nairadithya
       Score  : 94 points
       Date   : 2025-10-02 16:58 UTC (6 hours ago)
        
 (HTM) web link (andregarzia.com)
 (TXT) w3m dump (andregarzia.com)
        
       | soapdog wrote:
       | Author of the blog here in case anyone has questions.
        
         | Imustaskforhelp wrote:
         | What are your thoughts on something like arturo which I know is
         | quite recent but it has a lot of features for scripting and an
         | argument might in fact be made that it is in fact it might have
         | too many batteries but it was an absolute pleasure to learn and
         | I had a lot of aha moments in their discord server and the
         | community was really pleasant to follow through actually.
         | 
         | I know its definitely smaller but I just want your opinions on
         | it and what you might think of the language and I may be a bit
         | sorry if this comes across as a little off topic but your blog
         | really reminded me of arturo and my attempts on creating
         | something like hugo in arturo but the project was abandoned mid
         | way but if I remember correctly it was just some 50 lines of
         | code to convert from markdown to complete website or even less
         | since arturo's battery include markdown syntax as well as well
         | as a web server and its written in nim which I cherish too.
         | 
         | I am genuinely interested in your opinions about it!
         | 
         | https://arturo-lang.io/
        
         | sneak wrote:
         | Why would you build your blog to fail if some article on it
         | ever gets popular? The fact that the most hits you ever
         | received was 50k in a week isn't relevant; a single important
         | post could receive that in seconds.
         | 
         | It basically costs nothing to pre-render a static site, which
         | then serves several orders of magnitude faster. I'm confused
         | why anyone would do it this way in this day and age.
        
         | roxolotl wrote:
         | I currently run a blog generator I wrote in fennel and have
         | been considering switching to pollen haha. Slightly surprised
         | you didn't pick fennel over lua since you used racket before.
         | Is there a reason you didn't?
        
         | its-kostya wrote:
         | I don't have a background in web development and have a genuine
         | question.
         | 
         | > Your blog is your place to experiment and program how you
         | want it
         | 
         | I 100% agree with your statement and people don't need to
         | justify their hobbies. I've done really pointless things simply
         | for lolz and because I wanted.
         | 
         | My question arises because I was surprised in how ...
         | architected and (dare I say) complex the tech stack in your
         | blog is. In my blogging days I wrote my own HTML/CSS and
         | published it on a Internet facing server. Later, I've used CSS
         | templates and Markdown-to-HTML to generate the static content.
         | What is the purpose of Lua and having a database and all the
         | other complexity for what seems like a static blog? Again,
         | "because I wanted to experiment" or "sharpen my skills" is a
         | totally valid answer but seeing I don't have a background in
         | web development I am inquiring to see if there is a technical
         | reason for doing this. Would be curious to learn what, if any,
         | technical problem warrants such a set up :)
        
         | lenkite wrote:
         | Why not choose Hugo (https://gohugo.io) or Zola
         | (https://www.getzola.org ?. Both are pretty well-supported by
         | communities and have tonnes of blog themes. (Hugo has a
         | truckload and is the top-3 widely deployed SSG's)
        
       | curiousss wrote:
       | Kinda curious why you did not go with OpenResty?
        
         | nmz wrote:
         | Why not go with redbean?
        
       | simonw wrote:
       | I miss the days when "implement your own blogging engine" was one
       | of the most popular learning projects for engineers.
       | 
       | We should bring that back! Its such a great way to play around
       | with client- and server-side development options in an almost
       | zero-risk environment.
        
         | zelphirkalt wrote:
         | Still a good project when one learns a new programming
         | language.
        
         | ganamadaduun wrote:
         | Everything web-facing, if it's not a static website delivered
         | by a well-tested web server, happens in a high-risk
         | environment. And doubly so, if, like in this case, stuff like
         | custom cgi libraries are involved. One has to be either very
         | confident in their skills to do that or very, very brave.
        
           | piker wrote:
           | What? Are you serious?
           | 
           | If you roll your own little cgi-bin perl script behind Apache
           | you're far from vulnerable compared to, say, a WordPress
           | website.
        
             | ganamadaduuun wrote:
             | In any web application all data that comes from the outside
             | world is potentially hostile. A decent web framework takes
             | care of basic security measures, does input sanitation,
             | provides referer checking and csrf for forms, etc. When you
             | roll your own, your _are_ on your own to do that all
             | properly yourself, if you even know all the potential
             | pitfalls. And if you write your own cgi library like the op
             | even more so. I'm not advocating for using WordPress
             | either. I'm advocating for either having a static blog or
             | using a decent, tested web framework or the the very least
             | cgi module that provides tested implementations of common
             | security features that in my experience are typically
             | missed in self-made cgi scripts.
        
               | talideon wrote:
               | Nah. There are ways to mitigate the blast radius of
               | experiments like this.
               | 
               | You can't utterly wrap developers up in cotton wool.
               | Ultimately, people learn strong lessons from screwing up.
               | You can at least make sure they're doing this learning
               | within a sandbox in which the damage is contained. Like,
               | maybe containerising it so it has limited access to
               | anything that could do any real damage. If somebody
               | builds a blogging app and the worst thing that happens is
               | that they learn the value of sanitising your input,
               | preventing SQL injection, that spam is an unfortunate
               | fact of life, and that you should be very careful with
               | how you manage cookies, I would consider that a _very_
               | big win for that novice developer.
               | 
               | Because we're talking about _developers_ here.
        
               | Imustaskforhelp wrote:
               | I am not exactly sure about using containers (most likely
               | you mean docker/podman) as sandboxes...
               | 
               | Please correct me wrong but for a better form of
               | sandboxing, I would recommend something like microvm and
               | the bottlefire thing which was recently shared if that
               | might pique your interest as I found it to be interesting
               | and then using it with something like
               | https://github.com/Zouuup/landrun
               | 
               | There is also tinykvm and other projects too which can
               | simply take a binary and run it and I think that maybe
               | developers should also try out all the different
               | sandboxes and different things just for understanding as
               | well I suppose too. To me, I really like playing with
               | different form of sandboxes or such technologies in
               | general.
               | 
               | Also do note that I am not sure if bottlefire provides
               | sandbox/isolation by default as they mention Sandbox with
               | Landlock seperately so I am now a bit confused if they
               | provide sandbox by default or not as I previously thought
               | it might have.
        
           | bji9jhff wrote:
           | Ok. I'll bite. What are the risks? As I see it, if you screw
           | up and someone get root access on your server, it's the worse
           | that may happens and then shut down the whole thing is a
           | click away.
        
       | behnamoh wrote:
       | I don't know man, every time I tried to learn Lua (to write nvim
       | plugins and HammerSpoon spoons) I disliked the ergonomics of the
       | language. I don't understand why people say it's an easy
       | language--                   easy [?] simple
        
         | vardump wrote:
         | Perhaps people's tastes vary? I find Lua an easy to use
         | language. Easy to embed into C/C++ projects for scripting
         | purposes. Also great when you can only spare 100 kB or so for
         | an interpreter. (Arguably that was more important in the past.)
        
           | fullstop wrote:
           | For me it is a much easier language than, say, Erlang.
        
             | dev_l1x_be wrote:
             | Erlang has multiple higher level barrier of entries than
             | other languages. For starting, its syntax.
        
             | behnamoh wrote:
             | but Erlang isn't a scripting language, it's a full-blown
             | language with a rich ecosystem and framework (BEAM).
        
               | fullstop wrote:
               | Lua is also a full blown language, with an ecosystem as
               | well.
               | 
               | Perhaps the road block that you've run into is because
               | you've been treating it as just a scripting language.
        
         | fullstop wrote:
         | I would suggest using it to add scripting functionality to your
         | own C or C++ project. That's when it really clicked for me.
         | 
         | When you're doing stuff in nvim or HammerSpoon, you're dealing
         | with someone else's interface and the decisions that they've
         | made.
        
         | pmarreck wrote:
         | There are languages that compile to Lua. Have you investigated
         | those? For example, you can use a TypeScript syntax and pick up
         | free typechecking along the way:
         | https://typescripttolua.github.io/
         | 
         | There's also the venerable MoonScript: https://moonscript.org/
         | 
         | And YueScript, a personal fave: https://yuescript.org/doc/
         | 
         | A whole list: https://github.com/hengestone/lua-languages
        
           | gorjusborg wrote:
           | Don't forget Fennel, if you are a Lisp lover!
        
         | vyskocilm wrote:
         | It really depends. I learned Lua in order to contribute to
         | kulala plugin for neovim and found the language nice and easy
         | to learn.
         | 
         | Of course it has its warts, but given the topic, almost
         | everything is better than a vimscript imho.
        
         | cheriot wrote:
         | Agree, I find it a PITA. I think the good reviews are in
         | contrast to C++ and vimscript. Fine for a small embedded
         | script, but I hope WASM or some better language ecosystem
         | starts to fill this niche.
        
         | electroglyph wrote:
         | it's easy, but the 1 indexes and global by default suck
        
           | WolfeReader wrote:
           | The 1 indexes are only a difference from what you're used to.
           | Lua was made by mathematicians, who of course wanted to
           | address the first element as 1, the second element as 2, etc.
           | 
           | 0-indexing makes sense in the context of C where the index
           | operator is syntactic sugar for pointer arithmetic. In
           | higher-level languages like C# and Python and others, it's
           | pretty much just a leftover habit from C devs that we all got
           | used to.
           | 
           | Global by default is a perpetual issue, agreed.
        
             | DavidVoid wrote:
             | And a lot of the time it makes the syntax more compact than
             | it would be with 0-indexing.                 for i=1,#arr
             | do         foo(arr[i])       end
             | 
             | I don't feel that strongly for or against either way of
             | indexing though, they both have their pros and cons.
        
       | azhenley wrote:
       | I spend a lot of time blogging but all I use is a ~50 line Python
       | file that converts my markdown pages to HTML, adds my template,
       | and generates the ToC page. Then I push to GitHub Pages.
       | 
       | I can't imagine needing more than that. Why are these blog stacks
       | so complex?
        
         | shanedrgn wrote:
         | Sometimes people just want to have fun
        
         | WorldMaker wrote:
         | Speaking for myself at least, after you've been blogging for a
         | quarter century or more there are some nice features you might
         | want like pagination of your table-of-contents, RSS feeds (do
         | it, everyone should do it), support for redirects so that
         | ancient links mostly work across those decades (I've kept
         | redirects from like three or four blogging systems now), tags
         | pages for finding lost treasures and silly things. I been on
         | both sides of "needing" comments tools over the decades,
         | similar with things like WebMentions. With so much of blogging
         | on social media WebMentions don't seem that big a deal this
         | decade as it was in the one where every other person (in
         | college) had at least one Blogger.com Blog or LiveJournal and a
         | lot of discussions were cross-links between blogs.
         | 
         | Admittedly most of my blogging history has been something of a
         | path towards simplification from hand-rolled PHP+MySQL, with
         | custom "forum code" markup language, stuff before "blogging"
         | was even an agreed upon term for it (and before Markdown was
         | anywhere near as pervasive), to complex third-party beasts like
         | Drupal, to homegrown Python (and reStructuredText), to very
         | simple SSG tools (these days still Jekyll, but I don't like
         | working in Ruby much, so I keep debating a switch to Lume but I
         | don't think its Redirects plugin is yet compatible enough with
         | GitHub Pages for my liking and I haven't tested its RSS support
         | yet, both of which are personal hard requirements).
        
         | ksymph wrote:
         | I had that thought too. My own blogging engine is ~100 lines of
         | lua that accomplishes the same as you describe, plus RSS, with
         | one additional library for markdown parsing. The author
         | mentions Mustache templates and WebMentions, but ten
         | dependencies still seems like a lot; I wonder what they are.
        
         | radiator wrote:
         | I just write HTML directly (and use GitHub pages)
        
       | rwky wrote:
       | I use perl for the same reasons. The few dynamic scripts that I
       | need I want to write and forget them for years. Odds are with
       | perl they'll still work 20 years from now.
        
         | bilekas wrote:
         | This. I'm still sitting on some almost core code that's written
         | on an over enthusiastic teenagers idea of a plan.
        
       | indigodaddy wrote:
       | You could also do something like this, have Caddy webserver parse
       | your md files through a template
       | 
       | https://github.com/dbohdan/caddy-markdown-site/blob/master/C...
       | 
       | ^^ the above combined with caddy git fs to have your md files
       | cloned in memory and refresh every X interval is kind of magical.
       | Git push a new md file and wait X minutes and your website
       | updates.
       | 
       | https://github.com/mohammed90/caddy-git-fs
       | 
       | ====
       | 
       | Or a one-file FastHTML (python web framework) solution:
       | 
       | https://gist.github.com/simonMoisselin/f63c52f087704c99b6a62...
        
       | pmarreck wrote:
       | LuaJIT is awesome.
       | 
       | I've been converting my Bash scripts/functions to it, with much
       | success thus far.
        
         | gorjusborg wrote:
         | You may want to benchmark lua versus luajit if you are writing
         | scripts or other short-lived programs.
         | 
         | JIT-compiled languages aren't generally faster in starting up,
         | they generally are used to speed up long-lived programs that
         | have hot sections.
        
           | haberman wrote:
           | LuaJIT bucks the trend of slow-warmup JITs. It is extremely
           | quick to compile and load, and its interpreter is very fast
           | -- faster than the JIT-compiled code from LuaJIT v1 IIRC, and
           | certainly faster than the interpreter of Lua.
           | 
           | It wasn't until LuaJIT that I realized that JIT didn't
           | inherently have to be these slow lumbering beasts that take
           | hundreds of milliseconds just to wake from their slumber.
        
             | gorjusborg wrote:
             | Yet I've witnessed Lua 5.1 launching faster than luajit for
             | some of my use cases.
             | 
             | My point still stands though. Don't just use LuaJIT
             | thinking it will magically make things faster in all cases.
             | If you are embedding, LuaJIT is a no-brainer. If you are
             | using a stand-alone interpreter, measure if you care about
             | reality.
        
       | mochja wrote:
       | https://redbean.dev/ could be just perfect fit for you
        
       | mcdow wrote:
       | I liked this post, and I can totally understand where you're
       | coming from...
       | 
       | But couldn't anything you say about Lua also be said about JS?
       | You mentioned how Lua wasn't batteries included, so you try to
       | limit your libraries. Couldn't you say the same for JS? JS itself
       | doesn't change much, it's the ecosystem. Couldn't you just pick
       | out some small and stable libraries the same way you could with
       | Lua?
        
         | mrbonner wrote:
         | For me, it isn't 100% language warts. It is the customer
         | experience that matters the most for me. Can I compile and ship
         | my products to my customers without having them to install a
         | VMs, container runtime or a language runtime? That the question
         | that is critical for me.
        
           | Imustaskforhelp wrote:
           | I agree, I think that you must really like golang and how
           | easy it can make cross compilation and how fast it is to
           | build.
           | 
           | Golang has one of the best developer experiences and there
           | are only very very few minor nitpicks I might have of the
           | language but the whole ecosystem on packaging software and
           | what not is just so easy and I love golang.
        
       | akkartik wrote:
       | I use Lua for almost all my custom tools these days.
       | 
       | https://akkartik.name/freewheeling-apps
       | 
       | https://git.sr.ht/~akkartik/gen_site
        
         | veqq wrote:
         | Why not Fennel?
        
           | akkartik wrote:
           | Fennel looks quite great! And I love Lisp so there is
           | definitely some allure there. I don't use it for mostly the
           | reasons mentioned in OP:
           | 
           | * to minimize dependencies. Lua < Lua + Fennel. I'm more
           | extreme than OP in that I don't even use LuaRocks. When I
           | need a library I copy it in, and I pick a library that won't
           | change often so that is a reasonable approach. I try to avoid
           | native libraries.
           | 
           | * for even greater stability. Fennel is pretty stable, but I
           | use Lua 5.1 for the most part which hasn't changed since 2008
           | or so. I'm more extreme than OP in even avoiding later
           | versions of Lua.
           | 
           | Bottomline: the reasons I like Lua have nothing to do with
           | syntax and are much more about these operational meta
           | characteristics of the language. If I cared more about syntax
           | I'd be on Fennel in a heartbeat.
        
       | vogu66 wrote:
       | I've been thinking of how to make a blog simple recently, and I
       | came across xslt. It looks really cool and seems pretty set in
       | stone, so I thought I'd ask, what are the advantages/drawbacks of
       | making your own tech stack versus xslt? At first glance, it seems
       | perfectly able to handle rss and other simple linking patterns,
       | and pretty much anything can easily be turned into an xml then
       | xslt could be used to generate an html (server-side, or rather
       | writer-side, not like the blog is gonna change) that you serve?
        
         | ksymph wrote:
         | XSLT might be removed from the HTML spec soon, see discussion
         | here: https://news.ycombinator.com/item?id=44952185
        
           | vogu66 wrote:
           | that would be client side if it happens, though, I'm talking
           | about server side generation
           | 
           | xsltproc was preinstalled on my machine actually, the fact I
           | could just run it without installing anything is pretty cool
        
         | spc476 wrote:
         | XSL is neat, and it is a functional language, but between XSL
         | and XPath, it is quite verbose. Here's a small section of XSL I
         | use to generate my website ( _not_ my blog):
         | <xsl:choose>                    <!-- ... other code -->
         | <xsl:when test="name(.) = 'subsection'">
         | <xsl:choose>               <xsl:when
         | test="not(boolean(ancestor-or-self::*/@next)) or ancestor-or-
         | self::*/@next != 'rev'">                 <xsl:if
         | test="boolean(following-sibling::subsection[@listindex !=
         | 'no']/attribute::directory)">                   <link
         | rel="next"  href="../{following-sibling::subsection[@listindex
         | != 'no']/attribute::directory}" title="{following-
         | sibling::subsection[@listindex != 'no']/child::title}"/>
         | </xsl:if>                 <xsl:if test="boolean(preceding-
         | sibling::subsection[@listindex !=
         | 'no'][position()=1]/attribute::directory)">
         | <link rel="prev"  href="../{preceding-
         | sibling::subsection[@listindex !=
         | 'no'][position()=1]/attribute::directory}" title="{preceding-
         | sibling::subsection[@listindex !=
         | 'no'][position()=1]/child::title}"/>                 </xsl:if>
         | <link rel="first" href="../{../subsection[@listindex !=
         | 'no'][position()=1]/@directory}"
         | title="{../subsection[@listindex !=
         | 'no'][position()=1]/title}"/>                 <link rel="last"
         | href="../{../subsection[@listindex !=
         | 'no'][position()=last()]/@directory}"
         | title="{../subsection[@listindex !=
         | 'no'][position()=last()]/title}"/>               </xsl:when>
         | <xsl:otherwise>                 <xsl:if
         | test="boolean(preceding-sibling::subsection[@listindex !=
         | 'no'][position()=1]/attribute::directory)">
         | <link rel="next" href="../{preceding-
         | sibling::subsection[@listindex !=
         | 'no'][position()=1]/attribute::directory}" title="{preceding-
         | sibling::subsection[@listindex !=
         | 'no'][position()=1]/child::title}"/>                 </xsl:if>
         | <xsl:if test="boolean(following-sibling::subsection[@listindex
         | != 'no']/attribute::directory)">                   <link
         | rel="prev" href="../{following-sibling::subsection[@listindex
         | != 'no']/attribute::directory}" title="{following-
         | sibling::subsection[@listindex != 'no']/child::title}"/>
         | </xsl:if>                 <link rel="first"
         | href="../{../subsection[@listindex !=
         | 'no'][position()=last()]/@directory}"
         | title="{../subsection[@listindex !=
         | 'no'][position()=last()]/title}"/>                 <link
         | rel="last"  href="../{../subsection[@listindex !=
         | 'no'][position()=1]/@directory}"
         | title="{../subsection[@listindex !=
         | 'no'][position()=1]/title}"/>               </xsl:otherwise>
         | </xsl:choose>           </xsl:when>                <!-- ...
         | other code ... -->         </xsl:choose>
         | 
         | And yes, there is other code I've omitted for brevity. This is
         | used to generate the navigation links for the site. I initially
         | write this ... prior to 2009 (that's when I moved it into git).
         | There have been some minor fixes to the XSL over the years, but
         | it's largely unchanged (for a reason that I hope is obvious).
         | Yes, I still use it, because it still works, and it's for a
         | static website.
        
       | Levitating wrote:
       | glad to see cgi being loved again
        
       | amrutha_ wrote:
       | waldium can be good for blogs if you dont want to do a custom
       | build. its geo-specific though
        
       | librasteve wrote:
       | ha - I'm well behind you trying to get my blog from Mullenweg
       | hell to pure Raku
        
       | asdfman123 wrote:
       | tl;dr: because no one uses Lua
        
       | TheCycoONE wrote:
       | Lua 5.1 to 5.2 was a fairly significant breaking change; one that
       | has forked the community to this day with luaJIT never coming on
       | board. 5.2 to 5.3 also broke things with the introduction of
       | integers but mostly at the level of bindings. There is also very
       | little included in terms of standard library and while luarocks
       | exists many significant packages go abandoned. There are breaking
       | language changes in the upcoming 5.5 as well though they are
       | relatively minor.[1]
       | 
       | All to say I think if long term compatibility is the primary goal
       | there are probably better languages.
       | 
       | Have you already discounted php or perl?
       | 
       | [1] https://www.lua.org/work/doc/manual.html#8
        
         | 0cf8612b2e1e wrote:
         | Why stay on the upgrade treadmill? For such a minimal language,
         | are the updates really that compelling?
         | 
         | NeoVim is committing to 5.1 and leaving it at that.
        
       ___________________________________________________________________
       (page generated 2025-10-02 23:00 UTC)