<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Stephen Molyneaux</title>
    <link>https://stephen.molyneaux.ca/</link>
    <description>Blog posts by Stephen Molyneaux</description>
    <generator>Hugo -- gohugo.io</generator>
    <language>en-us</language>
    <lastBuildDate>Fri, 20 Nov 2026 13:30:35 -0500</lastBuildDate>
    <atom:link href="https://stephen.molyneaux.ca/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>AI’s Expensive Compliment</title>
      <link>https://stephen.molyneaux.ca/blog/ai_s_expensive_compliment/</link>
      <pubDate>Fri, 20 Nov 2026 13:30:35 -0500</pubDate>
      <guid>https://stephen.molyneaux.ca/blog/ai_s_expensive_compliment/</guid>
      <description>&lt;p&gt;There&amp;rsquo;s a saying &amp;ldquo;commoditize your compliments&amp;rdquo;. Traditional computer hardware is a compliment to AI and agentic development. We&amp;rsquo;re seeing a tight squeeze on RAM and storage now, but increasingly the rate of AI adoption will be limited by tradition hardware. If you dont have enough machines for agents to run on, you&amp;rsquo;ll naturally consume less tokens.&lt;/p&gt;
</description>
    </item>
    <item>
      <title>The Human Moat is Empathy</title>
      <link>https://stephen.molyneaux.ca/blog/the_human_moat_is_empathy/</link>
      <pubDate>Thu, 19 Nov 2026 09:31:12 -0500</pubDate>
      <guid>https://stephen.molyneaux.ca/blog/the_human_moat_is_empathy/</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;I think the secret to building a good product has actually not changed, and I believe it&amp;rsquo;s empathy. Empathy for the user. Empathy for the use-case. Empathy for trying to figure out if this is actually valuable for the person who&amp;rsquo;s ultimately going to pay for it&amp;hellip; I think this has always been the key ingredient in any entrepreneurial team.&lt;/p&gt;
&lt;p&gt;-Felix Rieseberg&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;&lt;a href=&#34;https://youtu.be/D-SVFneJ_Nk?t=1928&#34;&gt;Claude Engineering Lead: &amp;ldquo;Stop Using Claude Like It’s 2024&amp;rdquo; [32:06 - 32:26]&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;The most impactful software engineers I&amp;rsquo;ve worked with have always had
a strong sense of empathy and judgement. They&amp;rsquo;re in-tune with what&amp;rsquo;s
good and bad and can place themselves in other people&amp;rsquo;s position.
They have the imagination for how much better a system &lt;em&gt;could&lt;/em&gt; be.&lt;/p&gt;
&lt;p&gt;That has always been the case, and AI is just making that more stark.&lt;/p&gt;
</description>
    </item>
    <item>
      <title>Where&#39;s the Productivity?</title>
      <link>https://stephen.molyneaux.ca/blog/where_s_the_productivity/</link>
      <pubDate>Tue, 17 Nov 2026 10:40:05 -0500</pubDate>
      <guid>https://stephen.molyneaux.ca/blog/where_s_the_productivity/</guid>
      <description>&lt;p&gt;AI-skeptics often ask (rightly) something along the lines of
&amp;ldquo;If agents provide X times the productivity, why haven&amp;rsquo;t we seen X times
the programming output?&amp;rdquo;&lt;/p&gt;
&lt;p&gt;This is my attempt at documenting specific advances that are attributable
to agents, and reasons why this argument isn&amp;rsquo;t as strong of a statement
as it might first appear.&lt;/p&gt;
&lt;p&gt;In general, my belief is that agents pre-Opus (November 2025) did not do
much to accelerate development without significant effort creating
harnesses to work around limited agent capabilities. Then it took a few
months before non-AI-pilled (pre-AI-pilled?) developers actually got
on-board.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;The clock starts at November 2025&amp;hellip;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Developers then needed time to actually recognize the improvement and to
start using it themselves. For a lot of developers, they got a chance to
play around with it around Christmas.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&amp;hellip;or maybe even January 2026&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;From there, a substantial number of enterprises would put heavy barriers
to agents running independently. No yolo-mode allowed. Agents could
read the files system and write changes, but only commands in an
allowlist would be run automatically. This is the phase where developers
would joke about their job being to continually press enter.&lt;/p&gt;
&lt;p&gt;It wasn&amp;rsquo;t until March/April that &amp;ldquo;Auto&amp;rdquo; approves were introduced where a separate LLM could validate commands on behalf of the user.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&amp;hellip;or maybe even April&amp;hellip;?&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;From &lt;em&gt;there&lt;/em&gt; you had people learning how to effectively use agents in
their own workflow.&lt;/p&gt;
&lt;p&gt;So you might have people say for years that LLMs multiply programmer productivity. Those people might now claim that they saw the future and
were there early. I don&amp;rsquo;t buy it. To me, the clock starts in Spring 2026.&lt;/p&gt;
&lt;p&gt;Let&amp;rsquo;s get into specifics now.&lt;/p&gt;
&lt;h1 id=&#34;specific-public-changes&#34; class=&#34;text-3xl font-bold&#34;&gt;
  Specific Public Changes
&lt;/h1&gt;
&lt;p&gt;&lt;em&gt;Work-in-progress&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href=&#34;https://x.com/DiscordPreviews/status/2117900707168739472&#34;&gt;2026-11-04 - Discord client moving to Rust&lt;/a&gt; - Discord was on Electron and seemed like it
was going to continue this forever if agents didn&amp;rsquo;t allow them to
reasonably swap to Rust. Not released, but I don&amp;rsquo;t think this would happen
without agents&lt;/p&gt;
&lt;h1 id=&#34;grab-bag&#34; class=&#34;text-3xl font-bold&#34;&gt;
  Grab-Bag
&lt;/h1&gt;
&lt;ul&gt;
&lt;li&gt;People are now the limiting factor. Programming is X times faster but now
non-programming reasons are limiting production.&lt;/li&gt;
&lt;li&gt;Once products are released, marginal changes provide less and less
value&lt;/li&gt;
&lt;/ul&gt;</description>
    </item>
    <item>
      <title>Fearless Ubuntu Upgrades</title>
      <link>https://stephen.molyneaux.ca/blog/fearless_ubuntu_upgrades/</link>
      <pubDate>Tue, 03 Nov 2026 21:00:52 -0500</pubDate>
      <guid>https://stephen.molyneaux.ca/blog/fearless_ubuntu_upgrades/</guid>
      <description>&lt;p&gt;I&amp;rsquo;ve never updated Ubuntu to a new major version without issues. The worst instance of this was not being able to login in to a desktop environment at all.&lt;/p&gt;
&lt;p&gt;At least now we have agents to save us. I updated Ubuntu on my laptop today and firefox lost all my browser data. Thankfully Claude was able to pull in the history/cookies/tabs from the previous install and bring them into the snap install.&lt;/p&gt;
&lt;p&gt;I don&amp;rsquo;t think I would have updated today if I didn&amp;rsquo;t have an agent to clean up whatever eventually broke.&lt;/p&gt;
</description>
    </item>
    <item>
      <title>Vibe the Software You Would Download</title>
      <link>https://stephen.molyneaux.ca/blog/vibe_the_software_you_would_download/</link>
      <pubDate>Mon, 02 Nov 2026 08:08:42 -0500</pubDate>
      <guid>https://stephen.molyneaux.ca/blog/vibe_the_software_you_would_download/</guid>
      <description>&lt;p&gt;You can still enjoy writing software even in the age of agents. It&amp;rsquo;s the same as the old days where you would download someone else&amp;rsquo;s project if it met your needs. In the past, you might have avoided
downloading the project because you
wanted to write it yourself. Today you
wouldn&amp;rsquo;t get an agent to write it for
the same reason.&lt;/p&gt;
&lt;p&gt;There has always been a little
disappointment when you thought you
had a clever idea, just to find out
that someone else has already done
it. The non-existance was motivation
to see it started. With agents, that
has shifted. Existance is a fuzzier thing now, but the effect remains.&lt;/p&gt;
&lt;p&gt;If you would have downloaded it, you would be fine with vibe-coding it.&lt;/p&gt;
</description>
    </item>
    <item>
      <title>Senior Employees Reap Rewards of AI</title>
      <link>https://stephen.molyneaux.ca/blog/hn_quote_2026_10_28/</link>
      <pubDate>Wed, 28 Oct 2026 13:01:49 -0400</pubDate>
      <guid>https://stephen.molyneaux.ca/blog/hn_quote_2026_10_28/</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;The only gains seem to be those short-term kinds (a program can be made faster, rewards can be reaped by senior people who have thought about stuff for a while), rather than encouraging a healthy environment of creativity&amp;hellip;.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;&lt;a href=&#34;https://news.ycombinator.com/item?id=50258391&#34;&gt;bemtevi&lt;/a&gt; on &lt;a href=&#34;https://oioannou.com/blog/ai-promised-less-work/&#34;&gt;AI Promised Less Work. I Have Never Worked More&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;This comment stuck out to me. As a more senior developer, I&amp;rsquo;ve seen
programs I&amp;rsquo;ve always wanted materialize in front of me with AI agents.
I hadn&amp;rsquo;t considered that knowing &lt;em&gt;what&lt;/em&gt; to make is such a differentiator.&lt;/p&gt;
</description>
    </item>
    <item>
      <title>Artisanal Code Trap</title>
      <link>https://stephen.molyneaux.ca/blog/artisanal_code_trap/</link>
      <pubDate>Fri, 23 Oct 2026 10:41:56 -0400</pubDate>
      <guid>https://stephen.molyneaux.ca/blog/artisanal_code_trap/</guid>
      <description>&lt;p&gt;For various reasons, people do not want others to assume their
hand-written code is actually written by an agent. At some level there&amp;rsquo;s
an implication that hand-written code is higher quality, but there&amp;rsquo;s also
some pride in saying &amp;ldquo;I made this&amp;rdquo;.&lt;/p&gt;
&lt;p&gt;The trap is that writing &lt;strong&gt;bad&lt;/strong&gt; code is a marker that a human wrote it.
If you have git commits with partially-implemented features and bad commit
messages it&amp;rsquo;s probably written by a person. If you write code by hand you
have an incentive to leave around these human markers if only to point to
them with pride at your own fallibility.&lt;/p&gt;
</description>
    </item>
    <item>
      <title>AI Programming is Okay</title>
      <link>https://stephen.molyneaux.ca/blog/ai_programming_is_okay/</link>
      <pubDate>Tue, 20 Oct 2026 11:25:08 -0400</pubDate>
      <guid>https://stephen.molyneaux.ca/blog/ai_programming_is_okay/</guid>
      <description>&lt;p&gt;As someone who cares about the &lt;em&gt;craft&lt;/em&gt; of programming the discussions
around this article didn&amp;rsquo;t resonate with me:
&lt;a href=&#34;https://chriskiehl.com/article/it-is-still-ok-to-enjoy-programming&#34;&gt;It&amp;rsquo;s still OK to enjoy programming&lt;/a&gt; (&lt;a href=&#34;https://news.ycombinator.com/item?id=50134472&#34;&gt;HN Thread&lt;/a&gt;)&lt;/p&gt;
&lt;p&gt;I want software to be high quality. I want the &lt;em&gt;code itself&lt;/em&gt; to be high
quality. I enjoy programming by hand. I think coding agents are a net good.&lt;/p&gt;
&lt;p&gt;Somehow these are aligned for me in a way that doesn&amp;rsquo;t match the typical
online discourse.&lt;/p&gt;
&lt;p&gt;Is programming art? Or science? Or a means-to-an-end? Does it reveal some
kind of foundational truth? Is it more like cooking? Or like playing an
instrument? Or working on a car? Or carpentry? Or running a marathon? Or a
puzzle?&lt;/p&gt;
&lt;p&gt;It&amp;rsquo;s not quite like any of these, but it has aspects of each. I&amp;rsquo;d like to
explore this more, but I just wanted to get down the thought.&lt;/p&gt;
&lt;p&gt;Roller Coaster Tycoon&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;It&amp;rsquo;s a good game&lt;/li&gt;
&lt;li&gt;Runs on a potato&lt;/li&gt;
&lt;li&gt;Hand-written ASM&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;McMansion&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Bad architecture, but still houses people&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Bad Renovation&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;A century home ruined by a bad addition&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Cooking&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Home-cooked food is precise, can be repeated, can be unique&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Music/Dance&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Songs are endlessly replayable on Spotify&lt;/li&gt;
&lt;li&gt;Music/Dance is personal and subtle, vivid and unique&lt;/li&gt;
&lt;/ul&gt;</description>
    </item>
    <item>
      <title>Easier Safer Plugins With Agents</title>
      <link>https://stephen.molyneaux.ca/blog/easier_safer_plugins_with_agents/</link>
      <pubDate>Sat, 17 Oct 2026 12:12:26 -0400</pubDate>
      <guid>https://stephen.molyneaux.ca/blog/easier_safer_plugins_with_agents/</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;Generate vim syntax for the odin programming language&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;I didn&amp;rsquo;t need to download a plugin manager or find someone&amp;rsquo;s existing
package/plugin for handling Odin. I don&amp;rsquo;t need to worry about updates
injecting malware. I wanted Odin syntax highlighting in vim and I got it.&lt;/p&gt;
&lt;p&gt;This is inefficient and perhaps even a bit anti-social. But I didn&amp;rsquo;t
leave my terminal, didn&amp;rsquo;t lose any sense of flow, and didn&amp;rsquo;t waste time
comparing overly-many options. It worked, first try, in a minute.&lt;/p&gt;
</description>
    </item>
    <item>
      <title>Coding Agents and Knowability</title>
      <link>https://stephen.molyneaux.ca/blog/coding_agents_and_knowability/</link>
      <pubDate>Thu, 08 Oct 2026 17:07:24 -0400</pubDate>
      <guid>https://stephen.molyneaux.ca/blog/coding_agents_and_knowability/</guid>
      <description>&lt;p&gt;For much of my 8 years of fulltime software development career, understanding some software problems was (seemingly) impossible. Rare events caused unusual code paths to be taken. Race conditions, bad configs, an unknown confluence of factors. Sometimes all the pieces are there if you just have enough time and patience to work through the wreckage.&lt;/p&gt;
&lt;p&gt;Agents change that. They can look at the logs and code to find the gaps. They can whip through log files across a half dozen systems. They have a corpus of software maladies baked into their weights. They have the time, they have the knowledge, and they have the persistence that a single engineer with a dozen other tasks can&amp;rsquo;t manage to take on.&lt;/p&gt;
&lt;p&gt;I can now solve problems I never could have hoped to solve in the past. Yes, agents can make bad guesses, but so much more is within our grasp to understand than ever before.&lt;/p&gt;
</description>
    </item>
    <item>
      <title>Shimlang Odin Prototype</title>
      <link>https://stephen.molyneaux.ca/blog/shimlang_odin_prototype/</link>
      <pubDate>Tue, 06 Oct 2026 10:43:25 -0400</pubDate>
      <guid>https://stephen.molyneaux.ca/blog/shimlang_odin_prototype/</guid>
      <description>&lt;p&gt;Shimlang has been written in Python, Zig, Rust, Zig, and Rust again. Each step has improved the implementation has added crucial functionality.&lt;/p&gt;
&lt;p&gt;It&amp;rsquo;s now time for another rewrite. Primarily, this rewrite will replace the custom bytecode interpreter with a WASM compiler.&lt;/p&gt;
&lt;p&gt;The most recent Shimlang Rust implementation does not handle intermediate
heap-allocated values well. Recently I was creating an sdf font using the existing Rust implementation of Shimlang. For convenience I was doing this
all on a single frame at startup. Because I was using tuples (which need to
allocate) this ended up busting the 2^27 (134MB) available. I had 64
128x128 images with a 2-tuple (16 bytes) for each pixel. There were at
least 8 sdf operations per pixel. Thats &lt;code&gt;2^(6+7+7+4+3) = 2^27&lt;/code&gt;. Even with
no other operations, this hits the limit.&lt;/p&gt;
&lt;p&gt;The implementation doesn&amp;rsquo;t support running GC mid-way through executing a
frame. To do that, it would need to track every temporary value. Despite
the limitations we can see with this approach, avoiding the runtime
complexity of tracking these values is more important.&lt;/p&gt;
&lt;h2 id=&#34;escape-analysis&#34; class=&#34;text-2xl font-bold&#34;&gt;
  Escape Analysis
&lt;/h2&gt;
&lt;p&gt;Another approach is to do some form of &amp;ldquo;escape analysis&amp;rdquo;. This would mean
tracking which allocations can be freed statically. The bytecode compiler
could track per-function which non-value arguments are assigned to globals
or other input arguments or captured in returned closures. From there it
would be able to free heap-allocated data as part of the generated
bytecode.&lt;/p&gt;
&lt;p&gt;That approach would give much more headroom to the sorts of value-heavy
code that is likely to bust the memory limit.&lt;/p&gt;
&lt;h2 id=&#34;stack-allocate-value-types&#34; class=&#34;text-2xl font-bold&#34;&gt;
  Stack Allocate Value Types
&lt;/h2&gt;
&lt;p&gt;The other approach is to avoid heap allocations. In particular, tuples
are only heap allocated since the runtime can only handle 8-byte values
outside of the heap. Changing that approach requires a complete rewrite of
the bytecode compiler and runtime.&lt;/p&gt;
&lt;h2 id=&#34;solutions&#34; class=&#34;text-2xl font-bold&#34;&gt;
  Solutions
&lt;/h2&gt;
&lt;p&gt;So we&amp;rsquo;re left with some options:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Do the complex work of updating the runtime to support mid-frame GC&lt;/li&gt;
&lt;li&gt;Do escape analysis to free memory mid-frame&lt;/li&gt;
&lt;li&gt;Stack allocate value types&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Each of those requires a fair amount of work. But there&amp;rsquo;s one last thing,
we don&amp;rsquo;t even want to use the current runtime in production. Shimlang
&lt;em&gt;needs&lt;/em&gt; to support WASM to have any hope of reasonable web performance.&lt;/p&gt;
&lt;p&gt;So we need to change the compiler and we need to change the runtime.
So much needs to change that it would be most-effective to start from
scratch. As with previous rewrites, the corpus of tests will be carried
forward.&lt;/p&gt;
&lt;h2 id=&#34;odin&#34; class=&#34;text-2xl font-bold&#34;&gt;
  Odin
&lt;/h2&gt;
&lt;p&gt;Creating a language that&amp;rsquo;s meant for use in a game engine essentially
requires using a systems programming language. The actual game engine
part of it needs to be fast and we need to integrate with existing
C/C++ libraries for physics, graphics, audio, and input.&lt;/p&gt;
&lt;p&gt;To me, it comes down to these languages:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;C&lt;/li&gt;
&lt;li&gt;C++&lt;/li&gt;
&lt;li&gt;Rust&lt;/li&gt;
&lt;li&gt;Zig&lt;/li&gt;
&lt;li&gt;Odin&lt;/li&gt;
&lt;li&gt;D&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://www.beeflang.org/&#34;&gt;Beef&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://strlen.com/lobster/&#34;&gt;Lobster&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Jai&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;To me, Zig/Odin are more attractive than C. Despite never writing Odin, I
still find it more readable than C and it comes with many features that
seem tailor-made for game development.&lt;/p&gt;
&lt;p&gt;I find that I don&amp;rsquo;t experience the joy of coding when I write in Zig.
I find that I don&amp;rsquo;t enjoy using the standard library. Part of that is the
allocator interface but another part of it is the hard-to-follow
documentation. Take a look at the documentation for &lt;a href=&#34;https://ziglang.org/documentation/master/std/#std.ArrayList&#34;&gt;ArrayList&lt;/a&gt;.
How do you create one? How do you push to one? How do you access a pushed
value? I think I want an (std.array_list.Aligned)[https://ziglang.org/documentation/master/std/#std.array_list.Aligned]?
Why does &lt;code&gt;.append&lt;/code&gt; take an allocator rather than the allocator being stored
in the list?&lt;/p&gt;
&lt;p&gt;The other main issue I have with Zig is the build system. It seems to
change with every release. It also feels very bad to write what should be a
script in a low level language. I get the academic appeal of having the
build scripting being in the same language, but it ends up being a pain.&lt;/p&gt;
&lt;p&gt;I can&amp;rsquo;t write C++, unless I use a very small subset which eliminates a lot
of the ergonomic benefits you would hope to get.&lt;/p&gt;
&lt;p&gt;Rust has worked fine, but fights you when you want to operate with raw
memory. So much of Rust is built around thread safety and making it hard to
write incorrect code. In this use-case that safety is getting in the way
more often then not. I also want to use globals. It&amp;rsquo;s a pain to have to
use locks when I know there&amp;rsquo;s only a single thread accessing some data.&lt;/p&gt;
&lt;p&gt;D seems fine. I have a coworker I greatly respect who is a D enjoyer. It
just doesn&amp;rsquo;t have the mindshare that I would have expected if it were good
for this niche.&lt;/p&gt;
&lt;p&gt;Beef/Lobster are their own runtime. Interesting, but I want to make the runtime.&lt;/p&gt;
&lt;p&gt;The creator of Jai doesn&amp;rsquo;t like people writing their own programming
language in Jai. He sees it as offensive.&lt;/p&gt;
&lt;p&gt;There are a few others, but Odin is the most-serious remaining contender.
Some might balk at using a language that&amp;rsquo;s largely dependent on a single
person. While not necessarily ideal in the abstract, it provides a focused
vision and implementation that&lt;/p&gt;
&lt;p&gt;So that&amp;rsquo;s the next step. I&amp;rsquo;ll prototype the next interation of Shimlang in Odin.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Personal Software Won&#39;t Replace Apps</title>
      <link>https://stephen.molyneaux.ca/blog/personal_software_wont_replace_apps/</link>
      <pubDate>Thu, 01 Oct 2026 09:00:00 -0500</pubDate>
      <guid>https://stephen.molyneaux.ca/blog/personal_software_wont_replace_apps/</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;It is extremely obvious at this point that the vast majority of apps will be
replaced by personalised, one-to-one programs that a user&amp;rsquo;s AI assistant will
simply build and maintain for them at will, exactly as they want, on the fly.&lt;/p&gt;
&lt;p&gt;The inversion from apps to intelligence is inevitable, because no one ever
wanted an app in the first place - they wanted their problem solved as
cheaply, quickly and effectively as possible.&lt;/p&gt;
&lt;p&gt;The SaaS apocalypse has barely begun. We are in the opening act.&lt;/p&gt;
&lt;p&gt;— &lt;a href=&#34;https://x.com/rationalaussie/status/2104216164931191118&#34;&gt;Rational Aussie (@rationalaussie)&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;This is not the way the world will work.&lt;/p&gt;
&lt;p&gt;Apps are curated to suit particular workflows and can teach &lt;em&gt;how&lt;/em&gt; to do
something through its interface that a user wouldn&amp;rsquo;t even know they needed.&lt;/p&gt;
&lt;p&gt;Apps provide a social/communication layer that personal software can&amp;rsquo;t provide.&lt;/p&gt;
&lt;p&gt;Apps provide a common platform for teaching skills built on top of the app. In
a new domain you can&amp;rsquo;t learn from any other users if you&amp;rsquo;re the only one.&lt;/p&gt;
&lt;p&gt;Personal software is &lt;em&gt;wonderful&lt;/em&gt;, but platforms, data, and social connections
will still remain entrenched for years to come. YouTube, Gmail, and Google Maps
won&amp;rsquo;t suddenly be replaced with personal software. WhatsApp, Facebook, and
Instagram won&amp;rsquo;t disappear. Netflix and Disney+ aren&amp;rsquo;t threatened. A budding
video editor won&amp;rsquo;t remake DaVinci Resolve before learning their craft. You&amp;rsquo;re
not going to play your own knock-off Minecraft when you could be playing with
friends.&lt;/p&gt;
&lt;p&gt;When &lt;em&gt;these&lt;/em&gt; are the majority of apps people spend their time with, it&amp;rsquo;s
unreasonable to claim that it&amp;rsquo;s &amp;ldquo;extremely obvious&amp;rdquo; that personal software will
take over. Personal software will grow alongside traditional software.&lt;/p&gt;
</description>
    </item>
    <item>
      <title>Shimlang Status June 2026</title>
      <link>https://stephen.molyneaux.ca/blog/shimlang_status_2026_06_10/</link>
      <pubDate>Wed, 10 Jun 2026 21:02:49 -0400</pubDate>
      <guid>https://stephen.molyneaux.ca/blog/shimlang_status_2026_06_10/</guid>
      <description>&lt;p&gt;&lt;a href=&#34;https://github.com/shmolyneaux/clion_game/tree/d682d70c3f8e8b487f823d3d4d07515bf6ef9ea3&#34;&gt;&lt;em&gt;Latest commit as of this post&lt;/em&gt;&lt;/a&gt;&lt;/p&gt;
</description>
    </item>
    <item>
      <title>AI Art Bad, Code Good</title>
      <link>https://stephen.molyneaux.ca/blog/ai_art_bad_code_good/</link>
      <pubDate>Sat, 31 Jan 2026 09:10:09 -0500</pubDate>
      <guid>https://stephen.molyneaux.ca/blog/ai_art_bad_code_good/</guid>
      <description>&lt;p&gt;If you were in an art community before generative AI, you almost certainly hate it.
Watching &lt;a href=&#34;https://www.youtube.com/watch?v=zhMp62XETj0&#34;&gt;this anti-ai video&lt;/a&gt; from
a YouTube channel I like inspired this thought:&lt;/p&gt;
&lt;p&gt;Why hasn&amp;rsquo;t the programming community pushed back as hard as the art community?&lt;/p&gt;
&lt;p&gt;These are my unfiltered thoughts that&amp;rsquo;ll I&amp;rsquo;ll refine over time.&lt;/p&gt;
&lt;h1 id=&#34;skill-issue&#34; class=&#34;text-3xl font-bold&#34;&gt;
  Skill Issue
&lt;/h1&gt;
&lt;p&gt;The unfortunately reality for some folks in the software industry is that they
struggle to code. They scrape by with Stack Overflow, leaning on others on their
team, and bashing against the problem until it&amp;rsquo;s solved. Sometimes they code
they work on is very narrowly focused, or programming isn&amp;rsquo;t their primary duty.
These are the people who don&amp;rsquo;t know what code quality is and the code is &amp;ldquo;done&amp;rdquo;
the first time they get it to work.&lt;/p&gt;
&lt;p&gt;If you&amp;rsquo;re not a skilled developer, coding agents are a godsend. They write
better code faster. What&amp;rsquo;s not to love?&lt;/p&gt;
&lt;h1 id=&#34;code-quality-is-the-wrong-metric&#34; class=&#34;text-3xl font-bold&#34;&gt;
  Code Quality is the Wrong Metric
&lt;/h1&gt;
&lt;p&gt;As developers, many of us care a great deal about &amp;ldquo;code quality&amp;rdquo;. This is a
nebulous quality with a constantly-churning definition. For the most part,
sales and &amp;ldquo;product&amp;rdquo; folks do not care about &amp;ldquo;code quality&amp;rdquo;. If the features are
there without bugs, the &amp;ldquo;quality&amp;rdquo; of the code doesn&amp;rsquo;t matter. The marketplace
only cares about the end result. Maybe &amp;ldquo;code quality&amp;rdquo; was only ever about
satisfying programmers?&lt;/p&gt;
&lt;p&gt;Code is &amp;ldquo;good&amp;rdquo; if it does the job well. Code is &amp;ldquo;bad&amp;rdquo; if it doesn&amp;rsquo;t do everything
it needs to.&lt;/p&gt;
&lt;p&gt;For programmers, code can be beautiful, or elegant, or clever, or simple, or
maintainable. However, that&amp;rsquo;s not how code is judged outside of the few who
read and write it. The idea of &amp;ldquo;maintainable&amp;rdquo; code is beginning to lose its
meaning as LLMs are becoming more proficient.&lt;/p&gt;
&lt;p&gt;For some, &amp;ldquo;code quality&amp;rdquo; has little meaning anymore. It seems like more and more
developers are adopting the idea that it&amp;rsquo;s the end result that really matters.
LLMs claim to get you to that success criteria faster.&lt;/p&gt;
&lt;h1 id=&#34;time-investment&#34; class=&#34;text-3xl font-bold&#34;&gt;
  Time Investment
&lt;/h1&gt;
&lt;ul&gt;
&lt;li&gt;Pinnacle projects take years of investment that typically raises the bar quite
high for a project to be worth investing in. It can take a long time before the
projects bear fruit. More &amp;ldquo;bad&amp;rdquo; ideas can be tried now, potentially revealing
untapped potential.&lt;/li&gt;
&lt;/ul&gt;
&lt;h1 id=&#34;breadth-of-application&#34; class=&#34;text-3xl font-bold&#34;&gt;
  Breadth of Application
&lt;/h1&gt;
&lt;ul&gt;
&lt;li&gt;Programmers require many many different skills. There are some convergent skills,
but there&amp;rsquo;s a fair amount of specialization. In art, a good artist can quickly
adapt between mediums. In programming, it can take a master of one area weeks
or more to ramp up in a different area. For &amp;ldquo;small&amp;rdquo; changes this isn&amp;rsquo;t worth
it. But with AI, there&amp;rsquo;s little ramp-up time. A hardcore low-level person can
quickly whip up a servicable website. A front-end person can easily dip down
into native code.&lt;/li&gt;
&lt;li&gt;AI output can be refined by hand or iterated by follow-up promps&lt;/li&gt;
&lt;/ul&gt;
&lt;h1 id=&#34;code-is-not-a-competition-code-is-not-content&#34; class=&#34;text-3xl font-bold&#34;&gt;
  Code is not a Competition, Code is not Content
&lt;/h1&gt;
&lt;ul&gt;
&lt;li&gt;Software is not competing for eyeballs. Historically there&amp;rsquo;s been less
external validation or teaching.&lt;/li&gt;
&lt;li&gt;Non-artists are taking up &amp;ldquo;space&amp;rdquo; where &amp;ldquo;true&amp;rdquo; art should be. Programmers share
ideas and tools. Even poorly made tools can inspire programmers.&lt;/li&gt;
&lt;li&gt;Code is not &amp;ldquo;content&amp;rdquo; in the same way art is. Most programmers already monetize
their skill at a job. Programming outside of work (most often) is for fun. That
instrinsic motivation is unaffected by AI. Where that programming is done for
the &lt;em&gt;output&lt;/em&gt; (either to start a business or personal desire for a tool), AI is
helpful. If the problem is already well-solved you don&amp;rsquo;t need the output. If
you&amp;rsquo;re doing it for fun, the it doesn&amp;rsquo;t matter than others are using AI.&lt;/li&gt;
&lt;li&gt;There&amp;rsquo;s a lot of scut-work and boilerplate and configuration in programming
that AI helps address&lt;/li&gt;
&lt;/ul&gt;
&lt;h1 id=&#34;ai-is-tech-native&#34; class=&#34;text-3xl font-bold&#34;&gt;
  AI is Tech-Native
&lt;/h1&gt;
&lt;ul&gt;
&lt;li&gt;AI is &amp;ldquo;from&amp;rdquo; the programming sphere, it&amp;rsquo;s not an incursion.&lt;/li&gt;
&lt;/ul&gt;
&lt;h1 id=&#34;ai-slow-boil&#34; class=&#34;text-3xl font-bold&#34;&gt;
  AI Slow Boil
&lt;/h1&gt;
&lt;ul&gt;
&lt;li&gt;There&amp;rsquo;s a on-ramp to using AI for programmers. First as a better search engine,
then writing a few simple functions or explaining a snippet of code, then
explaining a complex error, writing a test, running the test, automatically
fixing the code as a result of a failed test, then taking care of higher-level
workflows.&lt;/li&gt;
&lt;/ul&gt;
&lt;h1 id=&#34;extension-of-programmer-behavior&#34; class=&#34;text-3xl font-bold&#34;&gt;
  Extension of Programmer Behavior
&lt;/h1&gt;
&lt;ul&gt;
&lt;li&gt;Programming was already all about abstracting behavior&lt;/li&gt;
&lt;li&gt;People were already pulling code from stackoverflow&lt;/li&gt;
&lt;/ul&gt;
&lt;h1 id=&#34;code-is-discovered&#34; class=&#34;text-3xl font-bold&#34;&gt;
  Code is Discovered
&lt;/h1&gt;
&lt;p&gt;Re: &lt;a href=&#34;https://open.spotify.com/episode/7hDXaW1oAKoWxunxT9uWP0?si=Bqq-DoBWRhii74Jx3c8gSA&amp;amp;pi=CGCkUGvySJaN8&amp;amp;t=3452&#34;&gt;https://open.spotify.com/episode/7hDXaW1oAKoWxunxT9uWP0?si=Bqq-DoBWRhii74Jx3c8gSA&amp;amp;pi=CGCkUGvySJaN8&amp;amp;t=3452&lt;/a&gt;&lt;/p&gt;
&lt;h1 id=&#34;exceptions&#34; class=&#34;text-3xl font-bold&#34;&gt;
  Exceptions
&lt;/h1&gt;
&lt;p&gt;On the other hand&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Frontier software development requires deep insight into how things are
constructed at a low level. New and out-of-model ideas requires understanding
concepts that can often only come from writing it by hand. This is well-known
from before AI as the &lt;a href=&#34;https://en.wikipedia.org/wiki/Ironies_of_Automation&#34;&gt;&amp;ldquo;Ironies of Automation&amp;rdquo;&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Human authored code implicitly brings in much more context that allows for
improved correctness/verifiability/security. Humans have a sense for where to
generalize or make things more concrete that&amp;rsquo;s often only implicit. Humans
get this wrong all the time, but there is &lt;em&gt;reason&lt;/em&gt; based on their
&lt;em&gt;understanding&lt;/em&gt; of the problem.&lt;/li&gt;
&lt;/ul&gt;</description>
    </item>
    <item>
      <title>Shimlang Status January 2026</title>
      <link>https://stephen.molyneaux.ca/blog/shimlang_status/</link>
      <pubDate>Mon, 26 Jan 2026 08:24:11 -0500</pubDate>
      <guid>https://stephen.molyneaux.ca/blog/shimlang_status/</guid>
      <description>&lt;p&gt;Shimlang has gone through many iterations since it was first conceived. Originally it was meant to be an interpreter that was small enough to include directly include in a project repository for multiple platforms, and to be deployable as single file executables like Love2D.&lt;/p&gt;
&lt;p&gt;While that was a neat concept to play around with, that motivation was fairly thin. I know that I&amp;rsquo;ve had issues with other projects relying on Ruby or Node or Perl for some tasks, especially if they required newer versions of those languages that weren&amp;rsquo;t readily available.&lt;/p&gt;
&lt;p&gt;Conversely, most Linux distros will already have Python and I can easily write Python that doesn&amp;rsquo;t depend on third party libraries (eliminating venv issues for others) or newer features (Python 3.6).&lt;/p&gt;
&lt;p&gt;That left my primary use-case for a custom language — gamedev.&lt;/p&gt;
&lt;p&gt;The biggest inspiration for me is &lt;a href=&#34;https://www.youtube.com/watch?v=72y2EC5fkcE&#34;&gt;Tomorrow Corporation&amp;rsquo;s tech demo&lt;/a&gt; where they show off very impressive tooling for development, debug, and collaboration. In particular, time-travelling debugging, bug reproducibility, hot reloading, and visual debugging were huge draws for me. They wrote a compiler for a custom C-like language that allows them to build for whatever platform they want to target. However, during development they have an incredible amount of tooling around an interpreter for this language.&lt;/p&gt;
&lt;h2 id=&#34;aside&#34; class=&#34;text-2xl font-bold&#34;&gt;
  Aside
&lt;/h2&gt;
&lt;p&gt;One of the most impressive things about this demo is how cohesive the system is. There&amp;rsquo;s no barrier between scripting and native code. All code is in the same custom language. I don&amp;rsquo;t &lt;em&gt;want&lt;/em&gt; to use a low level language for gameplay programming, so I know this solution isn&amp;rsquo;t for me.&lt;/p&gt;
&lt;h1 id=&#34;status&#34; class=&#34;text-3xl font-bold&#34;&gt;
  Status
&lt;/h1&gt;
&lt;p&gt;Shimlang is a game scripting language with a strong focus on debuggability, determinism, modern syntax, and stable performance. All memory for the interpreter is stored in a contiguous chunk of memory that can be indexed by 24-bit addresses, 134 MB in total. The interpreter natively operates on 64-bit values. With NaN-boxing and a 4-bit tag, these 64-bit values can store two 24-bit addresses. Since all of these values store &lt;code&gt;u24&lt;/code&gt; addresses (rather than pointers), serialization and determinism become easier to implement.&lt;/p&gt;
&lt;p&gt;Garbage collection is handled by a completely separate thread. All memory writes set a dirty bit for their block of memory. The GC thread keeps a copy of the entire interpreter memory, and updates its copy and clears these bits as it goes along. GC happens on this copy, and runs concurrently with interpreter execution. There are no frame-hitches from stop-the-world garbage collection. While it might be possible to implement compaction, it&amp;rsquo;s not clear how to do that without pausing the interpreter. There&amp;rsquo;s also the option of writing an incremental GC, but that complicates the write barrier and seems like it would involve a lot of synchronization between the mutator and GC threads.&lt;/p&gt;
&lt;h1 id=&#34;next-steps&#34; class=&#34;text-3xl font-bold&#34;&gt;
  Next Steps
&lt;/h1&gt;
&lt;ul&gt;
&lt;li&gt;Implement NaN-boxing (currently using f32&amp;rsquo;s for now)&lt;/li&gt;
&lt;li&gt;Eliminate heap usage from interpreter linear memory&lt;/li&gt;
&lt;li&gt;Expand the functionality of built-in data types&lt;/li&gt;
&lt;li&gt;Connect to my game engine&lt;/li&gt;
&lt;li&gt;Implement debug tooling&lt;/li&gt;
&lt;/ul&gt;</description>
    </item>
    <item>
      <title>Blog CSS Optimization via LLM</title>
      <link>https://stephen.molyneaux.ca/blog/llm_optimization/</link>
      <pubDate>Sun, 18 Jan 2026 17:46:54 -0500</pubDate>
      <guid>https://stephen.molyneaux.ca/blog/llm_optimization/</guid>
      <description>&lt;p&gt;For the longest time this blog was using tailwind v1 in all it&amp;rsquo;s bloated glory.
Compressed on the wire, this CSS took 304.74 kB and a whopping 2.93 MB on disk!
Since Tailwind v2, it&amp;rsquo;s typical configure it to only output the classes that are
used, but that would drastically increase the complexity of generating the site
which otherwise only depends on python and hugo.&lt;/p&gt;
&lt;p&gt;What were my options?&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Keep the massive CSS file&lt;/li&gt;
&lt;li&gt;Move to a newer version of tailwind and complicate the site
generation (hugo extended, node, npm, postcss, autoprefixer, tailwind config, postcss config)&lt;/li&gt;
&lt;li&gt;Manually extract the necessary classes&lt;/li&gt;
&lt;li&gt;Redesign the site&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;No need for that, LLM&amp;rsquo;s to the rescue!&lt;/p&gt;
&lt;p&gt;I prompted Gemini Pro (2026-01-18) to generate the equivalent CSS to the tailwind
classes I was using. With a few back-and-forths I ended up with CSS that made
the site &lt;em&gt;identical&lt;/em&gt; to the original tailwind CSS at 0.4% of the on-the-wire size!&lt;/p&gt;
&lt;p&gt;From there I was able to update hugo to directly embed the minified CSS into
every page to remove any CSS pop-in. My setup is just as simple as before, but
now with much much less wasted bandwidth. The whole process took less that 15 minutes,
including figuring out how to get hugo to embed the stylesheet. This was a very long
time coming, and I know it will personally help me when I&amp;rsquo;m on limited cell data looking at
personal recipes.&lt;/p&gt;
&lt;p&gt;While it was always possible to do without LLMs, I can honestly say that I wouldn&amp;rsquo;t
have been able to find the time. When there&amp;rsquo;s a trade-off between engineering
rigor and development effort, it&amp;rsquo;s definitely the case that better software is
being created with LLMs.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Rust Flexible Memory</title>
      <link>https://stephen.molyneaux.ca/blog/rust_flexible_memory/</link>
      <pubDate>Sat, 17 Jan 2026 17:41:26 -0500</pubDate>
      <guid>https://stephen.molyneaux.ca/blog/rust_flexible_memory/</guid>
      <description>&lt;p&gt;Rust allows you to jump from high-level algorithms and data handling to low-level
byte manipulations and optimizations. I&amp;rsquo;ve found it incredibly helpful to be
able to shift between the two. You can start out with heap allocated &lt;code&gt;Vec&lt;/code&gt; and
&lt;code&gt;HashMap&lt;/code&gt; and slowly migrated to more specialized and byte-optimized structures.&lt;/p&gt;
&lt;p&gt;This flexibility is what made it practical to implement my scripting language in
Rust.&lt;/p&gt;
&lt;p&gt;Since &lt;a href=&#34;https://craftinginterpreters.com/&#34;&gt;Crafting Interpreter&lt;/a&gt; was released I&amp;rsquo;ve
worked on several interations of my scripting language, Shimlang. It was written
as a tree-walking interpreter in Python, then Zig, then Rust. It originally went
from Zig to Rust since I found it much easier to handle memory via RAII. It also
felt oddly bloated to have the allocator as a property on many objects.&lt;/p&gt;
&lt;p&gt;I got fairly far with that Rust implementation, even going as far as making a
little game that I compiled as WASM for the web. However, it relied on a custom
allocator that was fairly tedious to pass around, and required writing many
custom collections to work with. For some reason I felt the need to support
collections with fallible allocations. That was &lt;em&gt;probably&lt;/em&gt; influenced by Zig.
Garbage collection was implemented as reference counts with cycle detection.&lt;/p&gt;
&lt;p&gt;Development on that was sidetracked when I had the desire to implement a game
asset manager. Coming back to the project a couple years later I felt like the
implementation didn&amp;rsquo;t fit the new vision I had for the language. I was inspired
by &lt;a href=&#34;https://www.youtube.com/watch?v=72y2EC5fkcE&#34;&gt;this Tomorrow Corporation Tech Demo&lt;/a&gt;.
In that demo they showed a time-travelling debugger, live editing code, graphical
debugging, and way more. I wanted my language to be a scripting language for
games, and I knew that the pointer soup I implemented for the initial Rust
implementation would be very hard to translate into something that could support
those sorts of features. I thought Rust would make it hard to do the sorts of
low-level memory manipulations I wanted to make it work, so I went back to Zig
with a fresh start.&lt;/p&gt;
&lt;p&gt;With some more experience I was able to be more productive with Zig than I had
originally. I still had problems though. The build system (at the time) was still
unstable and changing (seemingly) every major release. While some people may like
the fact the build system is also in Zig, I think that implementing a build
&lt;em&gt;script&lt;/em&gt; in a language that has you manually managing memory is a bad idea.
Further, the docs for Zig are not robust enough to make using it enjoyable and
the language is changing often enough for LLMs to not be that big of a help.&lt;/p&gt;
&lt;p&gt;The thing that finally made me stop was the lack of good sum types and the
inflexible error handling. Defining the tag separate from the union is
unergonomic, and needing to pass error information through some object or global
doesn&amp;rsquo;t feel great to use.&lt;/p&gt;
&lt;p&gt;On top of that, it&amp;rsquo;s really really annoying to constantly get an &lt;em&gt;error&lt;/em&gt; message
from the compiler that a variable is unused. When rapidly iterating on code this
is highly unnecessary and is a huge break from every other language.&lt;/p&gt;
&lt;p&gt;Again, I implemented Shimlang in Rust. This is a completely separate implementation
from any of the others. The biggest departure from the other implementations is
creating a dedicated block of memory for the interpreter to use. Any values that
can&amp;rsquo;t fit into 64-bits use this memory. Further, since I know how much space
values in this block need, &lt;em&gt;freeing&lt;/em&gt; memory also requires passing in how much to
free (in contrast to C&amp;rsquo;s &lt;code&gt;free&lt;/code&gt; implementation). This saves the allocator from
needing to store metadata about allocations for subsequent freeing.&lt;/p&gt;
&lt;p&gt;To take this approach, I needed to free myself from the idea of writing idiomatic
Rust code. Taking this approach requires using unsafe &lt;em&gt;everywhere&lt;/em&gt;. It&amp;rsquo;s still
much safer than C/Zig, but it&amp;rsquo;s a bug departure from typical Rust programming.
Now I&amp;rsquo;m willing to write &amp;ldquo;hacky&amp;rdquo; code and I&amp;rsquo;m more willing to write things myself
It&amp;rsquo;s much more satisfying than learning yet-another-library.&lt;/p&gt;
&lt;p&gt;The single other thing that enabled this is LLMs. Bluntly, using unsafe in the
pre-LLMs days was frustrating. It was hard to know if you&amp;rsquo;d unexpectly call a
&lt;code&gt;drop&lt;/code&gt; to be called or how to get the proper reference given a pointer or to
get some pointer, or how to write to the pointer. Things that are very very easy
in C became headaches in Rust. This changed post-LLMs. Now I can ask how to turn
a u64 representing a pointer to a &lt;code&gt;&amp;amp;SomeValue&lt;/code&gt;. And that when initializing the
pointer I should use &lt;code&gt;.write&lt;/code&gt;. It&amp;rsquo;s much easier to learn now that there are
chat bots that can patiently explain how to do these things. I&amp;rsquo;m sure I&amp;rsquo;m making
mistakes, but I&amp;rsquo;m getting things done in a way I wasn&amp;rsquo;t able to before. Beyond
unsafe, I&amp;rsquo;m writing better Rust code since I can always ask how to do something
better.&lt;/p&gt;
&lt;p&gt;Working on this, I found that it easy to use a combination of my memory block
alongside &lt;code&gt;Vec&lt;/code&gt;/&lt;code&gt;Box&lt;/code&gt;/&lt;code&gt;HashMap&lt;/code&gt;. I had the struct data for boxes/hashmaps/vecs in
my block of memory which pointed out to memory on the heap. Rather than needing
to manually manage the memory from the get-go, I found that I could do a
combination of both manual and automatic memory management. Rather than being
delayed by not having my own hashmap, I was able to use the &lt;code&gt;std&lt;/code&gt; HashMap and
continue making good progress.&lt;/p&gt;
&lt;p&gt;I expect this feeling isn&amp;rsquo;t unique to Rust, and folks using C++ or D could relate
to this. However, I don&amp;rsquo;t think most folks using Rust can really relate. The
community shuns uses of unsafe. That probably makes sense for networked and
security-minded code, but not everything. For my little language unsafe makes
it so that I can even consider the sorts of tooling and debugging that I
desperately want for my language.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Game Script Implementation Notes (Draft)</title>
      <link>https://stephen.molyneaux.ca/blog/shimlang_game_script/</link>
      <pubDate>Tue, 11 Feb 2025 18:30:13 -0500</pubDate>
      <guid>https://stephen.molyneaux.ca/blog/shimlang_game_script/</guid>
      <description>&lt;p&gt;I&amp;rsquo;ve previously blogged about the &amp;ldquo;Shimlang&amp;rdquo; language. This is not a continuation
of that design. Instead, this page solidifies some of the internal implementation
details of the programming language.&lt;/p&gt;
&lt;p&gt;A large amount of virtual memory (4 GB) will be dedicated for the interpreter. All
memory operations are done relative to the base address of this memory chunk. A
dump of this memory should be sufficient to &lt;em&gt;completely&lt;/em&gt; restore the state of a
game written in the language. This includes loading state from some point in the
past of a gameplay session to be able to easily reproduce errors and tweak
behaviour.&lt;/p&gt;
&lt;p&gt;This memory is divided into 2^24 64-bit addresses.&lt;/p&gt;
&lt;p&gt;A &lt;code&gt;ShimValue&lt;/code&gt; is one of:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Unit &lt;code&gt;()&lt;/code&gt; - return value of functions that don&amp;rsquo;t return&lt;/li&gt;
&lt;li&gt;Null - Empty of an optional&lt;/li&gt;
&lt;li&gt;32-bit integer&lt;/li&gt;
&lt;li&gt;32-bit float&lt;/li&gt;
&lt;li&gt;Boolean&lt;/li&gt;
&lt;li&gt;Set&lt;/li&gt;
&lt;li&gt;Dict&lt;/li&gt;
&lt;li&gt;List&lt;/li&gt;
&lt;li&gt;Range&lt;/li&gt;
&lt;li&gt;
&lt;h2 id=&#34;string-multiple-internal-representations&#34; class=&#34;text-2xl font-bold&#34;&gt;
  String (multiple internal representations?)
&lt;/h2&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&#34;why-not-have-variable-length-data&#34; class=&#34;text-2xl font-bold&#34;&gt;
  Why not have variable-length data?
&lt;/h2&gt;
&lt;p&gt;This complicates things like lists that have contiguous chunks of memory where
the fields need to be consistently-sized. This also applies to objects whose
fields are expected to have a particular number of slots.&lt;/p&gt;
&lt;p&gt;Maybe in the future if these things are typed they can be variably sized?&lt;/p&gt;
&lt;h2 id=&#34;shimid&#34; class=&#34;text-2xl font-bold&#34;&gt;
  ShimID
&lt;/h2&gt;
&lt;p&gt;A &lt;code&gt;ShimID&lt;/code&gt; is a u24 that points into the VM memory space. It can point to anything
whether that&amp;rsquo;s raw bytes (for lists/dicts/sets) types, bytecode, closures, etc.&lt;/p&gt;
&lt;p&gt;These ID&amp;rsquo;s absolutely cannot be used to write data to the VM memory space. We
don&amp;rsquo;t support reading the ID either (outside of debugging) since we may want to
support compaction, which requires updating ID&amp;rsquo;s.&lt;/p&gt;
&lt;h2 id=&#34;shimvalue&#34; class=&#34;text-2xl font-bold&#34;&gt;
  ShimValue
&lt;/h2&gt;
&lt;p&gt;These variants can fit where a &lt;code&gt;ShimValue&lt;/code&gt; is expected. All of these values can
be copied/moved without issue since nothing will point to the address of a
&lt;code&gt;ShimValue&lt;/code&gt;.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;Tombstone:
0000_0000 0000_0000 0000_0000 0000_0000  0000_0000 0000_0000 0000_0000 0000_0000
A value that should never be readable by a program
A null address is used by dicts/sets to more efficiently handle deletions.

ID:
0000_0000 XXXX_XXXX XXXX_XXXX XXXX_XXXX  XXXX_XXXX YYYY_YYYY YYYY_YYYY YYYY_YYYY
Data: Address of object

Null:
1111_1111 XXXX_XXXX XXXX_XXXX XXXX_XXXX  XXXX_XXXX XXXX_XXXX XXXX_XXXX XXXX_XXXX

Unit:
0000_0001 XXXX_XXXX XXXX_XXXX XXXX_XXXX  XXXX_XXXX XXXX_XXXX XXXX_XXXX XXXX_XXXX
Data: Reserved for future use?

Boolean:
0000_0010 XXXX_XXXX XXXX_XXXX XXXX_XXXX  XXXX_XXXX XXXX_XXXX XXXX_XXXX XXXX_XXXY
Data: Only one bit used

i32:
0000_0011 XXXX_XXXX XXXX_XXXX XXXX_XXXX  YYYY_YYYY YYYY_YYYY YYYY_YYYY YYYY_YYYY
Data: Only 32 bits used
Maybe every int could be a bigint if a high bit is set?

f32:
0000_0100 XXXX_XXXX XXXX_XXXX XXXX_XXXX  YYYY_YYYY YYYY_YYYY YYYY_YYYY YYYY_YYYY
Data: Only 32 bits used

set:
0000_0101 XXXX_XXXX XXXX_XXXX XXXX_XXXX  XXXX_XXXX XXXX_XXXX XXXX_XXXX XXXX_XXXX
Data: Address of set

dict:
0000_0110 XXXX_XXXX XXXX_XXXX XXXX_XXXX  XXXX_XXXX XXXX_XXXX XXXX_XXXX XXXX_XXXX
Data: Address of dict

list:
0000_0111 XXXX_XXXX XXXX_XXXX XXXX_XXXX  XXXX_XXXX XXXX_XXXX XXXX_XXXX XXXX_XXXX
Data: Address of list

range:
0000_1000 YYYY_YYYY YYYY_YYYY YYYY_YYYY  YYYY_ZZZZ ZZZZ_ZZZZ ZZZZ_ZZZZ ZZZZ_ZZZZ
Maybe flags could make this a 0..n or 1..n or address range?
Extents are limited to i26 since that&#39;s the number of bits available. If for
some reason more is needed then it needs to be handled without the convenience
of a range.

string:
0000_1001 XXXX_XXXX XXXX_XXXX XXXX_XXXX  XXXX_XXXX YYYY_YYYY YYYY_YYYY YYYY_YYYY
Data: Address of string
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Here&amp;rsquo;s how those data types are defined:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;string: A 32-bit string containing the length followed by that number of bytes
TODO: String interning, more efficient slices

range: Two 32-bit integers

dict: Uses order dict described here: https://morepypy.blogspot.com/2015/01/faster-more-memory-efficient-and-more.html
&lt;/code&gt;&lt;/pre&gt;</description>
    </item>
    <item>
      <title>Shimlang Stage 1: Vertical Slice</title>
      <link>https://stephen.molyneaux.ca/blog/shimlang_stage_1/</link>
      <pubDate>Sat, 18 Sep 2021 11:20:11 -0400</pubDate>
      <guid>https://stephen.molyneaux.ca/blog/shimlang_stage_1/</guid>
      <description>&lt;p&gt;To start working towards the &lt;a href=&#34;https://stephen.molyneaux.ca/blog/shimlang_design_goals/&#34;&gt;design goals of Shimlang&lt;/a&gt;, the first goal is to create a &amp;ldquo;vertical slice&amp;rdquo; of a
many of the interfaces that Shimlang will provide.&lt;/p&gt;
&lt;p&gt;In particular, this includes:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Binaries for Windows, Linux, and Mac&lt;/li&gt;
&lt;li&gt;A working interpreter in the browser&lt;/li&gt;
&lt;li&gt;Published, but mostly failing test cases&lt;/li&gt;
&lt;li&gt;A Python project that calls into Shimlang via &lt;code&gt;cffi&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Support for printing and basic arithmetic operators &lt;code&gt;+&lt;/code&gt; &lt;code&gt;-&lt;/code&gt; &lt;code&gt;*&lt;/code&gt; &lt;code&gt;/&lt;/code&gt; &lt;code&gt;()&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;</description>
    </item>
    <item>
      <title>Shimlang Design Goals</title>
      <link>https://stephen.molyneaux.ca/blog/shimlang_design_goals/</link>
      <pubDate>Sat, 18 Sep 2021 10:17:00 -0400</pubDate>
      <guid>https://stephen.molyneaux.ca/blog/shimlang_design_goals/</guid>
      <description>&lt;p&gt;Shimlang is a new scripting language and interpreter that&amp;rsquo;s intended to be
modern, lightweight, and easily distributed. But what does that mean, exactly?&lt;/p&gt;
&lt;h2 id=&#34;modern&#34; class=&#34;text-2xl font-bold&#34;&gt;
  Modern
&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;The syntax is largely dervied from modern languages like Swift and Rust&lt;/li&gt;
&lt;li&gt;The language and standard library are expression-oriented&lt;/li&gt;
&lt;li&gt;Type annotations are first-class (in contrast to Mypy for Python, Sorbet for Ruby, and TypeScript)&lt;/li&gt;
&lt;li&gt;Solid standard library, without bringing in the entire world&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&#34;lightweight&#34; class=&#34;text-2xl font-bold&#34;&gt;
  Lightweight
&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;The interpreter and standard library should be less than 300 kB (about the size of &lt;a href=&#34;https://www.gutenberg.org/ebooks/64317&#34;&gt;&lt;em&gt;The Great Gatsby&lt;/em&gt;&lt;/a&gt;)&lt;/li&gt;
&lt;li&gt;A smaller release should be available with just a &amp;ldquo;core&amp;rdquo; set of libraries&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&#34;easily-distributed&#34; class=&#34;text-2xl font-bold&#34;&gt;
  Easily Distributed
&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;The interpreter should be a single-file executable&lt;/li&gt;
&lt;li&gt;No dependencies, including glibc&lt;/li&gt;
&lt;li&gt;In general, the interpreter should be small enough that folks should be &lt;em&gt;just barely&lt;/em&gt; okay with including copies of the resulting binary (for multiple platforms!) in their git repository&lt;/li&gt;
&lt;li&gt;A packaged interpreter should be easy to extend with additional modules&lt;/li&gt;
&lt;li&gt;Scripts developed with Shimlang should be easily packaged into single file binaries along with the interpreter&lt;/li&gt;
&lt;li&gt;Should be easy to embed into other applications, whether that&amp;rsquo;s C, C++, Rust, Zig, or WASM&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&#34;why&#34; class=&#34;text-2xl font-bold&#34;&gt;
  Why?
&lt;/h2&gt;
&lt;p&gt;Various languages over the years have been popular &amp;ldquo;glue&amp;rdquo; for adding a sprinkle
of automation. Bash, Perl, Python, and Ruby have are still popular choices for
this. Although these are popular, you cannot assume that they&amp;rsquo;ll be present on
every machine you&amp;rsquo;d want to run them on. Additionally, if your glue script
relies on third-party packages, then the environment management required to get
started with your project &lt;em&gt;will&lt;/em&gt; drive people away.&lt;/p&gt;
&lt;p&gt;Lua is close to meeting these needs, but the syntax and semantics of the
language are unorthodox.&lt;/p&gt;
&lt;h2 id=&#34;where-should-you-_not_-use-shimlang&#34; class=&#34;text-2xl font-bold&#34;&gt;
  Where should you &lt;em&gt;not&lt;/em&gt; use Shimlang?
&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;Don&amp;rsquo;t use Shimlang if performance matters. That&amp;rsquo;s not a goal.&lt;/li&gt;
&lt;li&gt;Don&amp;rsquo;t use Shimlang if you&amp;rsquo;re building an application. Other languages have ecosystems that suit that better.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&#34;where-should-you-use-shimlang&#34; class=&#34;text-2xl font-bold&#34;&gt;
  Where should you use Shimlang?
&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;Use Shimlang if there&amp;rsquo;s a script you want to share with someone. You don&amp;rsquo;t need to worry about their environment causing havoc.&lt;/li&gt;
&lt;li&gt;Use Shimlang if you need to generate files from some source in your code repository&lt;/li&gt;
&lt;li&gt;Use Shimlang for scripting in games&lt;/li&gt;
&lt;li&gt;Extend applications with Shimlang&lt;/li&gt;
&lt;/ul&gt;</description>
    </item>
    <item>
      <title>Shimlang Embeddable Scripting Language</title>
      <link>https://stephen.molyneaux.ca/blog/shimlang_embeddable_scripting_language/</link>
      <pubDate>Sun, 08 Aug 2021 16:37:17 -0400</pubDate>
      <guid>https://stephen.molyneaux.ca/blog/shimlang_embeddable_scripting_language/</guid>
      <description>&lt;p&gt;There&amp;rsquo;s a niche of programming languages that I&amp;rsquo;m looking to fill. This is the
first part of what will (hopefully) be a series of the journey of the
development of my little scripting language called &lt;code&gt;shimlang&lt;/code&gt;.&lt;/p&gt;
&lt;h2 id=&#34;the-niche&#34; class=&#34;text-2xl font-bold&#34;&gt;
  The Niche
&lt;/h2&gt;
&lt;p&gt;I want a language with:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;The syntax of Rust&lt;/li&gt;
&lt;li&gt;The semantics of Python&lt;/li&gt;
&lt;li&gt;The embeddability of Lua&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;There&amp;rsquo;s more to this design, of course, and I&amp;rsquo;ll expand on this in future posts.
The design has changed a decent amount since the first draft of this post, but
I&amp;rsquo;ll leave this post intact to serve as a quaint relic of the past.&lt;/p&gt;
&lt;h2 id=&#34;rust-like-syntax&#34; class=&#34;text-2xl font-bold&#34;&gt;
  Rust-Like Syntax
&lt;/h2&gt;
&lt;p&gt;&amp;ldquo;Rust-like syntax&amp;rdquo; is a wide and not very specific statement, especially when
considering the monumental differences between a dynamic language like Shim
and a compiled language with a great amount of static analysis like Rust. I&amp;rsquo;ll
write out a few key things to start to form a picture of what it&amp;rsquo;s like:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4&#34;&gt;&lt;code class=&#34;language-rust&#34; data-lang=&#34;rust&#34;&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;fn&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;print_fizzbuzz&lt;/span&gt;(n: &lt;span style=&#34;color:#a6e22e&#34;&gt;int&lt;/span&gt;) {
    &lt;span style=&#34;color:#66d9ef&#34;&gt;for&lt;/span&gt; i &lt;span style=&#34;color:#66d9ef&#34;&gt;in&lt;/span&gt; &lt;span style=&#34;color:#ae81ff&#34;&gt;1&lt;/span&gt;..n {
        &lt;span style=&#34;color:#66d9ef&#34;&gt;let&lt;/span&gt; out &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;if&lt;/span&gt; i &lt;span style=&#34;color:#f92672&#34;&gt;%&lt;/span&gt; &lt;span style=&#34;color:#ae81ff&#34;&gt;15&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;==&lt;/span&gt; &lt;span style=&#34;color:#ae81ff&#34;&gt;0&lt;/span&gt; {
            &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;fizzbuzz&amp;#34;&lt;/span&gt;
        } &lt;span style=&#34;color:#66d9ef&#34;&gt;else&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;if&lt;/span&gt; i &lt;span style=&#34;color:#f92672&#34;&gt;%&lt;/span&gt; &lt;span style=&#34;color:#ae81ff&#34;&gt;3&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;==&lt;/span&gt; &lt;span style=&#34;color:#ae81ff&#34;&gt;0&lt;/span&gt; {
            &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;fizz&amp;#34;&lt;/span&gt;
        } &lt;span style=&#34;color:#66d9ef&#34;&gt;else&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;if&lt;/span&gt; i &lt;span style=&#34;color:#f92672&#34;&gt;%&lt;/span&gt; &lt;span style=&#34;color:#ae81ff&#34;&gt;5&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;==&lt;/span&gt; &lt;span style=&#34;color:#ae81ff&#34;&gt;0&lt;/span&gt; {
            &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;buzz&amp;#34;&lt;/span&gt;
        } &lt;span style=&#34;color:#66d9ef&#34;&gt;else&lt;/span&gt; {
            i
        };

        print(out);
    }
}

print_fizzbuzz(&lt;span style=&#34;color:#ae81ff&#34;&gt;100&lt;/span&gt;);
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;More explicitly:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;C-style blocks defined with curly braces&lt;/li&gt;
&lt;li&gt;(Optional) type of a variable appears after the variable name &lt;code&gt;n: u32&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;let&lt;/code&gt; keyword used to define new variables within a scope
&lt;ul&gt;
&lt;li&gt;TODO: maybe we want Python-style scoping?&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Statements are separated by &lt;code&gt;;&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;No parens for if and for statements&lt;/li&gt;
&lt;li&gt;If-else chains can be used as expressions&lt;/li&gt;
&lt;li&gt;The last expression of a block evaluates to the value of the expression (with an empty expression evaluating to the unit &lt;code&gt;()&lt;/code&gt; type).&lt;/li&gt;
&lt;li&gt;Integer, string, and range literals&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&#34;python-semantics&#34; class=&#34;text-2xl font-bold&#34;&gt;
  Python Semantics
&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;Floating point numbers are 64-bit wide, and are a different type than ints
&lt;ul&gt;
&lt;li&gt;This is in contrast to JavaScipt and Lua (prior to Lua 5.2)&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;List/Dict/Set literals, along with their interfaces
&lt;ul&gt;
&lt;li&gt;Dict literals are &lt;code&gt;{:}&lt;/code&gt; to distinguish them from an empty block/set
&lt;ul&gt;
&lt;li&gt;This is a bit inspired by Groovy&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Set literals are &lt;code&gt;{,}&lt;/code&gt; to distinguish them from an empty block/dict&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Positional / Keyword arguments&lt;/li&gt;
&lt;li&gt;Iterator interface&lt;/li&gt;
&lt;li&gt;Objects can provide their own implementation of operators&lt;/li&gt;
&lt;li&gt;Standard library based on key packages in the Python Standard Library
&lt;ul&gt;
&lt;li&gt;subprocess&lt;/li&gt;
&lt;li&gt;pathlib&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Context managers?
&lt;ul&gt;
&lt;li&gt;Otherwise you basically need destructors, which should be fine if we use
traditional C-style scoping rather than Python scoping.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Tuples&lt;/li&gt;
&lt;li&gt;Explicit &lt;code&gt;this&lt;/code&gt; or &lt;code&gt;self&lt;/code&gt; in method calls&lt;/li&gt;
&lt;li&gt;No inheritance for now&amp;hellip;&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&#34;embeddability&#34; class=&#34;text-2xl font-bold&#34;&gt;
  Embeddability
&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;Small binary when standalone (target is less than 350 kB)&lt;/li&gt;
&lt;li&gt;Small footprint when embedded in another application&lt;/li&gt;
&lt;li&gt;Modular standard library for strong sandboxing&lt;/li&gt;
&lt;li&gt;C-API for embedding&lt;/li&gt;
&lt;li&gt;All integers are 64-bit signed ints
&lt;ul&gt;
&lt;li&gt;This makes it easier to embed than using bignums (like Python)&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&#34;why-not-use-language-x&#34; class=&#34;text-2xl font-bold&#34;&gt;
  Why not use language X?
&lt;/h2&gt;
&lt;p&gt;There many languages that inspire Shim. Facets of those languages inspire the
features that Shim provides.&lt;/p&gt;
&lt;h3 id=&#34;groovy&#34; class=&#34;header_3&#34;&gt;
  Groovy
&lt;/h3&gt;
&lt;p&gt;A JVM-based scripting language. It&amp;rsquo;s a decent language, but the influence of
Java and the heavyweight JVM make it unreasonable to package Groovy scripts.
It&amp;rsquo;s my own personal hangups that make me avoid the JVM. I can&amp;rsquo;t stand seeing
the JVM gobble up &lt;em&gt;gigs&lt;/em&gt; when it should be using far less, and the OOP-only
approach to development is a huge turn-off for most of the sorts of things I
write.&lt;/p&gt;
&lt;h3 id=&#34;rust&#34; class=&#34;header_3&#34;&gt;
  Rust
&lt;/h3&gt;
&lt;p&gt;Rust is great and has an obvious influence on the synatax of the language. It&amp;rsquo;s
flaw is that it&amp;rsquo;s compiled, and won&amp;rsquo;t work where scripts are needed instead.&lt;/p&gt;
&lt;h3 id=&#34;mun&#34; class=&#34;header_3&#34;&gt;
  Mun
&lt;/h3&gt;
&lt;p&gt;&lt;a href=&#34;https://mun-lang.org/&#34;&gt;Mun&lt;/a&gt;: the scripting language that looks like Rust. It&amp;rsquo;s
neat, and it&amp;rsquo;s meant to be embedded, but it enforces static typing and the size
of standalone binaries is too high since it depends on llvm. My ideal scripting
language is gradually typed. That let&amp;rsquo;s me write quick scripts that need to be
robust without sacrificing the ability to be robust when needed.&lt;/p&gt;
&lt;h3 id=&#34;swift&#34; class=&#34;header_3&#34;&gt;
  Swift
&lt;/h3&gt;
&lt;p&gt;While I&amp;rsquo;ve never used Swift, I often reference it for design inspiration. Code
written in Swift looks &lt;em&gt;nice&lt;/em&gt;.&lt;/p&gt;
&lt;h3 id=&#34;python&#34; class=&#34;header_3&#34;&gt;
  Python
&lt;/h3&gt;
&lt;p&gt;Python is easy to read and write, and has many well-designed standard library
packages. However, it&amp;rsquo;s difficult to embed, it&amp;rsquo;s &lt;em&gt;not&lt;/em&gt; small, it&amp;rsquo;s oriented
around statements, and you&amp;rsquo;re at this whims of the users&#39; environment as to
whether your script will work or not. I&amp;rsquo;ve also had trouble packaging Python
as a standalone executable.&lt;/p&gt;
&lt;h3 id=&#34;lua&#34; class=&#34;header_3&#34;&gt;
  Lua
&lt;/h3&gt;
&lt;p&gt;Lua is small, portable, and easily embedded in other systems. However, the
syntax and semantics of the language are atypical. It uses base-1 indexing,
arrays are sparse, it uses prototypical inheritance, and blocks are denoted
with words (&lt;code&gt;if&lt;/code&gt;, &lt;code&gt;then&lt;/code&gt;, &lt;code&gt;for&lt;/code&gt;, &lt;code&gt;do&lt;/code&gt;, &lt;code&gt;end&lt;/code&gt;, etc.). Prototypical inheritance
isn&amp;rsquo;t bad &lt;em&gt;per se&lt;/em&gt;, but always requires some sort of library to wrap it, which
yields many separate OOP libraries. The proliferation of libraries to learn
isn&amp;rsquo;t great for picking up a language.&lt;/p&gt;
&lt;h3 id=&#34;various-lisp-dialects&#34; class=&#34;header_3&#34;&gt;
  Various Lisp Dialects
&lt;/h3&gt;
&lt;p&gt;The Lisp way of thinking is neat. Code is data, data is code, things are
expression-oriented. You can essentially build the language you want to use to
solve your problem within lisp itself. However, I don&amp;rsquo;t want to solve big
problems with a DSL. I want to solve little problems.&lt;/p&gt;
&lt;p&gt;The syntax of Lisp dialects are also a turn-off for some people. I&amp;rsquo;m not trying
to push a philosophy. I just want to have a language that&amp;rsquo;s acceptable for the
majority of people to read and write.&lt;/p&gt;
&lt;h2 id=&#34;the-name&#34; class=&#34;text-2xl font-bold&#34;&gt;
  The Name
&lt;/h2&gt;
&lt;p&gt;The name &lt;code&gt;shimlang&lt;/code&gt; comes from my own name: Stephen H. Molyneaux &amp;gt; &lt;code&gt;SHM&lt;/code&gt; &amp;gt; &lt;code&gt;shim&lt;/code&gt;. It&amp;rsquo;s also
a reflection of how I want to use the language. I see it as a way to fill
a gap and to create a interface to a larger work.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Divesting from Software Orthodoxy</title>
      <link>https://stephen.molyneaux.ca/blog/divesting_from_software_orthodoxy/</link>
      <pubDate>Wed, 28 Jul 2021 18:01:45 -0700</pubDate>
      <guid>https://stephen.molyneaux.ca/blog/divesting_from_software_orthodoxy/</guid>
      <description>&lt;p&gt;The software development community widely accepts that software should be
modular and reusable. You should use libraries rather than reinventing things
yourself. There&amp;rsquo;s OOP, DRY, SOLID, abstraction, encapsulation, agile, continuous
delivery, and SOLID. You have frameworks and testing and code reviews and Kanban.&lt;/p&gt;
&lt;p&gt;I lump all of these together under the umbrella of &amp;ldquo;Software Orthodoxy&amp;rdquo;. Good
and proper developers follow these mantras and encourage others to do the same.
Ramshackle software houses regretfully wish they hadn&amp;rsquo;t fallen off &amp;ldquo;good&amp;rdquo; path
of software orthodoxy. They are caught in a prison of technical debt. Development
procedes at a glacial pace and every release is a potential nightmare of
instability.&lt;/p&gt;
&lt;p&gt;Or maybe that&amp;rsquo;s just what the followers of software orthodoxy have been led to believe.
If everyone is following the same set of guidelines, how will we know that we&amp;rsquo;re
following the best approach? I would argue that we should encourage a huge
variety of approaches to development. This would prevent the software development
industry from sticking to a local maximum. Rather than continually investing
in the same patterns again and again, the software development community should
embrace those who are fighting against the norms.&lt;/p&gt;
&lt;p&gt;The &amp;ldquo;handmade&amp;rdquo; software community is a seed bank. The enclaves of
functional programming seem to occupy their own niche as well.&lt;/p&gt;
</description>
    </item>
    <item>
      <title>Recipes</title>
      <link>https://stephen.molyneaux.ca/blog/recipes/</link>
      <pubDate>Tue, 06 Jul 2021 20:38:02 -0700</pubDate>
      <guid>https://stephen.molyneaux.ca/blog/recipes/</guid>
      <description>&lt;p&gt;Here is a collection of recipes I&amp;rsquo;ve transcribed/tweaked since 2020. It follows
the &amp;ldquo;Modernist Cuisine&amp;rdquo; recipe template I worked on mid-2021. The template
ought to have it&amp;rsquo;s own blog post, but for now an outdated version of the script
and template can be found in &lt;a href=&#34;https://gist.github.com/WimbledonLabs/24baf2796235ff48dae4e8361bccf586&#34;&gt;this GitHub Gist&lt;/a&gt;.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;https://stephen.molyneaux.ca/recipes/shrimp_couscous.html&#34;&gt;Pearl Couscous Salad With Shrimp and Feta&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://stephen.molyneaux.ca/recipes/pappardelle_bolognese.html&#34;&gt;Pappardelle Bolognese with Lentils and Sausages (Transcription)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://stephen.molyneaux.ca/recipes/quinoa_salad.html&#34;&gt;Quinoa Salad&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://stephen.molyneaux.ca/recipes/anchovy_chicken.html&#34;&gt;ANCHOVY CHICKEN with Lemon and Capers&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://stephen.molyneaux.ca/recipes/chocolate_chip_cheesecake.html&#34;&gt;Chocolate Chip Cheesecake (Transcription)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://stephen.molyneaux.ca/recipes/chicken_bacon_lentil_stew.html&#34;&gt;Pressure Cooker Chicken, Lentil, and Bacon Stew (Transcription)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://stephen.molyneaux.ca/recipes/greek_rice.html&#34;&gt;Greek Rice&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://stephen.molyneaux.ca/recipes/bbq_pulled_pork.html&#34;&gt;Instant Pot BBQ Pulled Pork (Transcription)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://stephen.molyneaux.ca/recipes/instant_pot_butter_chicken.html&#34;&gt;Instant Pot Butter Chicken (Transcription)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://stephen.molyneaux.ca/recipes/chicken_tinga.html&#34;&gt;Instant Pot Chicken Tinga&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://stephen.molyneaux.ca/recipes/dilly_bean_stew.html&#34;&gt;Dilly Bean Stew with Cabbage and Frizzled Onions&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://stephen.molyneaux.ca/recipes/honey_miso_mayo.html&#34;&gt;Honey-miso Mayonnaise&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://stephen.molyneaux.ca/recipes/uunifetapasta.html&#34;&gt;TikTok Pasta&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://stephen.molyneaux.ca/recipes/chatgpt_pulled_pork.html&#34;&gt;Slow Cooker Pulled Pork&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://stephen.molyneaux.ca/recipes/easy_jambalaya.html&#34;&gt;Easy Jambalaya&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://stephen.molyneaux.ca/recipes/aloo_masala.html&#34;&gt;Aloo Masala&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://stephen.molyneaux.ca/recipes/tiramisu.html&#34;&gt;Tiramisu&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://stephen.molyneaux.ca/recipes/caramelized_carrot_soup.html&#34;&gt;Caramelized Carrot Soup (Transcription)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://stephen.molyneaux.ca/recipes/beef_and_barley_stew.html&#34;&gt;Instant Pot Beef and Barley Stew&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://stephen.molyneaux.ca/recipes/feta_palak.html&#34;&gt;Feta Palak&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://stephen.molyneaux.ca/recipes/craigs_kung_pao_chicken.html&#34;&gt;Kung Pao Chicken (Craig&amp;rsquo;s)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://stephen.molyneaux.ca/recipes/tempura_vegetables.html&#34;&gt;Tempura Vegetables or Shrimp&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://stephen.molyneaux.ca/recipes/cream_biscuits.html&#34;&gt;Cream Biscuits&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://stephen.molyneaux.ca/recipes/eggplant_stirfry.html&#34;&gt;Sichuan-style Fish-fragrant Eggplant (Transcription)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://stephen.molyneaux.ca/recipes/crispy_roast_potatoes.html&#34;&gt;The Best Crispy Roast Potatoes Ever (Transcription)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://stephen.molyneaux.ca/recipes/dal_tadka.html&#34;&gt;Instant Pot Chicken Dal Tadka&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://stephen.molyneaux.ca/recipes/chorizo_pork_burgers.html&#34;&gt;Chorizo Pork Burgers with Grilled Honey Onions and Manchego (Transcription)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://stephen.molyneaux.ca/recipes/gochujang_brussels_sprouts.html&#34;&gt;Roasted Brussels Sprouts With Gochujang Brown Butter&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://stephen.molyneaux.ca/recipes/stew_2.html&#34;&gt;Spicy White Bean Stew With Broccoli Rabe&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://stephen.molyneaux.ca/recipes/vietnamese_ginger_chicken.html&#34;&gt;VIETNAMESE GINGER CHICKEN&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://stephen.molyneaux.ca/recipes/gnudi.html&#34;&gt;Spinach and Ricotta Gnudi with Tomato-Butter Sauce&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</description>
    </item>
    <item>
      <title>Rust Modules in LÖVE</title>
      <link>https://stephen.molyneaux.ca/blog/from_rust_with_love/</link>
      <pubDate>Sun, 18 Apr 2021 21:42:40 -0700</pubDate>
      <guid>https://stephen.molyneaux.ca/blog/from_rust_with_love/</guid>
      <description>&lt;p&gt;Calling Rust code in Lua is great for calling optimized routines, and leveraging
libraries from the Rust ecosystem. Packing Rust code for consumption in Lua
requires learning how to:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Generate Rust bindings from C headers&lt;/li&gt;
&lt;li&gt;Generate dynamic libraries in Rust&lt;/li&gt;
&lt;li&gt;Creating Rust ↔ Lua interop code&lt;/li&gt;
&lt;li&gt;Load dynamic libraries in Lua&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;This post covers all the steps needed to wrap the Rust &lt;code&gt;regex&lt;/code&gt; crate into a library
loadable by the Lua-based LÖVE game framework.&lt;/p&gt;
&lt;p&gt;To help us understand the details of how the process works, this will be a
from-scratch implementation &amp;ndash; no lua-specific Rust modules will be used.
This process will be demonstrated by wrapping up
&lt;a href=&#34;https://crates.io/crates/regex&#34;&gt;BurntSushi&amp;rsquo;s &lt;code&gt;regex&lt;/code&gt; library&lt;/a&gt; into a Lua
module. This article assumes the reader is familiar with the basics of Rust
(up to the &lt;a href=&#34;https://doc.rust-lang.org/stable/book/second-edition/ch08-00-common-collections.html&#34;&gt;8th chapter of the Rust book&lt;/a&gt;
should be fine). I&amp;rsquo;ll also assume that you are willing for me to gloss over some
of the aspects of using &lt;code&gt;unsafe&lt;/code&gt; in Rust.&lt;/p&gt;
&lt;p&gt;By the end of this article you should know how to:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Generate Rust bindings from C headers using bindgen&lt;/li&gt;
&lt;li&gt;Add missing C macro definitions as new functions&lt;/li&gt;
&lt;li&gt;Register Rust functions as callable functions from Lua&lt;/li&gt;
&lt;li&gt;Generate a dynamically-loadable library in Rust&lt;/li&gt;
&lt;li&gt;Load dynamic libraries in Lua&lt;/li&gt;
&lt;li&gt;Get parameters from the Lua stack in Rust&lt;/li&gt;
&lt;li&gt;Push results onto the Lua stack in Rust&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;If you&amp;rsquo;re looking to add Lua functionality to an existing Rust application you
should check out &lt;a href=&#34;https://crates.io/crates/rlua&#34;&gt;rlua on crates.io&lt;/a&gt; instead.&lt;/p&gt;
&lt;p&gt;Let&amp;rsquo;s get started!&lt;/p&gt;
&lt;h2 id=&#34;generating-bindings&#34; class=&#34;text-2xl font-bold&#34;&gt;
  Generating Bindings
&lt;/h2&gt;
&lt;p&gt;To load a module into Lua we need to match the interface it expects. This
interface is defined by &lt;code&gt;lua.h&lt;/code&gt; and &lt;code&gt;lauxlib.h&lt;/code&gt;. Strictly speaking, only
&lt;code&gt;lua.h&lt;/code&gt; is necessary, but the auxillary library provides many convenience
functions that make it easier to interact with Lua, and helps remove
boilerplate. This interface is defined in C code, but the Rust community has
created &lt;code&gt;bindgen&lt;/code&gt; to automatically convert existing C bindings into Rust!&lt;/p&gt;
&lt;p&gt;The most recent version of LÖVE (version 11.2) uses Lua 5.1.5. Technically,
LÖVE uses LuaJIT, which is an optimized version of Lua that&amp;rsquo;s ABI-compatible
with Lua 5.1.5.&lt;/p&gt;
&lt;p&gt;Before we generate the bindings, we first need to talk about how this project
will be organized. First, we will create a library &lt;code&gt;lua-51-sys&lt;/code&gt; which provides
the interface we use to call Lua functions from Rust. This library will be used
by our main project, which we&amp;rsquo;ll call &lt;code&gt;lregex&lt;/code&gt;.&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;cargo new --lib lregex
cd lregex/
cargo new --lib lua-51-sys
cd lua-51-sys/
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;We&amp;rsquo;ll add the following lines to the end of our &lt;code&gt;Cargo.toml&lt;/code&gt; file for the
&lt;code&gt;lua-51-sys&lt;/code&gt; library:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4&#34;&gt;&lt;code class=&#34;language-ini&#34; data-lang=&#34;ini&#34;&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;[build-dependencies]&lt;/span&gt;
&lt;span style=&#34;color:#a6e22e&#34;&gt;bindgen&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;0.37.4&amp;#34;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;This section, &lt;code&gt;[build-dependencies]&lt;/code&gt;, defines a set of crates that we use
at compile time. By defining a &lt;code&gt;build.rs&lt;/code&gt; file at the root of our project,
we can execute code that gives the Rust compiler additional steps to perform.
Let&amp;rsquo;s add a &lt;code&gt;build.rs&lt;/code&gt; file to &lt;code&gt;lua-51-sys/&lt;/code&gt;:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4&#34;&gt;&lt;code class=&#34;language-rust&#34; data-lang=&#34;rust&#34;&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;extern&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;crate&lt;/span&gt; bindgen;

&lt;span style=&#34;color:#66d9ef&#34;&gt;use&lt;/span&gt; std::env;
&lt;span style=&#34;color:#66d9ef&#34;&gt;use&lt;/span&gt; std::path::PathBuf;

&lt;span style=&#34;color:#66d9ef&#34;&gt;fn&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;main&lt;/span&gt;() {
    &lt;span style=&#34;color:#66d9ef&#34;&gt;let&lt;/span&gt; bindings &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; bindgen::Builder::default()
        .header(&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;wrapper.h&amp;#34;&lt;/span&gt;)
        .generate()
        .expect(&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;Unable to generate bindings&amp;#34;&lt;/span&gt;);

    &lt;span style=&#34;color:#75715e&#34;&gt;// Write the bindings to the $OUT_DIR/bindings.rs file.
&lt;/span&gt;&lt;span style=&#34;color:#75715e&#34;&gt;&lt;/span&gt;    &lt;span style=&#34;color:#66d9ef&#34;&gt;let&lt;/span&gt; out_path &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; PathBuf::from(env::var(&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;OUT_DIR&amp;#34;&lt;/span&gt;).unwrap());
    bindings
        .write_to_file(out_path.join(&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;bindings.rs&amp;#34;&lt;/span&gt;))
        .expect(&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;Couldn&amp;#39;t write bindings!&amp;#34;&lt;/span&gt;);
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;This code (at compile time) generates bindings from a file we call
&lt;code&gt;wrapper.h&lt;/code&gt;, and produces a file &lt;code&gt;bindings.rs&lt;/code&gt; which contains our Rust
bindings. Let&amp;rsquo;s add &lt;code&gt;wrapper.h&lt;/code&gt; now:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4&#34;&gt;&lt;code class=&#34;language-c&#34; data-lang=&#34;c&#34;&gt;&lt;span style=&#34;color:#75715e&#34;&gt;#include&lt;/span&gt; &lt;span style=&#34;color:#75715e&#34;&gt;&amp;#34;lua.h&amp;#34;&lt;/span&gt;&lt;span style=&#34;color:#75715e&#34;&gt;
&lt;/span&gt;&lt;span style=&#34;color:#75715e&#34;&gt;#include&lt;/span&gt; &lt;span style=&#34;color:#75715e&#34;&gt;&amp;#34;lauxlib.h&amp;#34;&lt;/span&gt;&lt;span style=&#34;color:#75715e&#34;&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;These files, &lt;code&gt;lua.h&lt;/code&gt; and &lt;code&gt;lauxlib.h&lt;/code&gt; define the interface we need to use to
talk to Lua. &lt;a href=&#34;https://www.lua.org/source/5.1/&#34;&gt;You can grab them here.&lt;/a&gt;
Put &lt;code&gt;lua.h&lt;/code&gt; and &lt;code&gt;lauxlib.h&lt;/code&gt; into &lt;code&gt;lua-51-sys/&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Lastly, replace &lt;code&gt;lua-51-sys/src/lib.rs&lt;/code&gt; with the following:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4&#34;&gt;&lt;code class=&#34;language-rust&#34; data-lang=&#34;rust&#34;&gt;&lt;span style=&#34;color:#75715e&#34;&gt;#![allow(non_upper_case_globals)]&lt;/span&gt;
&lt;span style=&#34;color:#75715e&#34;&gt;#![allow(non_camel_case_types)]&lt;/span&gt;
&lt;span style=&#34;color:#75715e&#34;&gt;#![allow(non_snake_case)]&lt;/span&gt;

include&lt;span style=&#34;color:#f92672&#34;&gt;!&lt;/span&gt;(concat&lt;span style=&#34;color:#f92672&#34;&gt;!&lt;/span&gt;(env&lt;span style=&#34;color:#f92672&#34;&gt;!&lt;/span&gt;(&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;OUT_DIR&amp;#34;&lt;/span&gt;), &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;/bindings.rs&amp;#34;&lt;/span&gt;));
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;At this point, you can run &lt;code&gt;cargo build&lt;/code&gt; to verify that everything is working.&lt;/p&gt;
&lt;p&gt;&lt;em&gt;BONUS&lt;/em&gt;: Run &lt;code&gt;cargo doc&lt;/code&gt; to generate documentation that you can view in your
browser. The output will be in &lt;code&gt;lua-51-sys/target/doc/lua_51_sys/index.html&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Unfortunately, we&amp;rsquo;re going to have to do something a &lt;em&gt;little&lt;/em&gt; bit messy here.
First, the Lua ↔ C Interface relies on C-style strings. Since Rust uses it&amp;rsquo;s
own form of strings, it would be nice to be able to easily define constant
C-style strings. There are crates with macros to do this on crates.io,
but since it&amp;rsquo;s small I&amp;rsquo;ve included my own version here.&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4&#34;&gt;&lt;code class=&#34;language-rust&#34; data-lang=&#34;rust&#34;&gt;&lt;span style=&#34;color:#75715e&#34;&gt;#[macro_export]&lt;/span&gt;
macro_rules&lt;span style=&#34;color:#f92672&#34;&gt;!&lt;/span&gt; cstr {
    (&lt;span style=&#34;color:#75715e&#34;&gt;$s&lt;/span&gt;:&lt;span style=&#34;color:#a6e22e&#34;&gt;expr&lt;/span&gt;) &lt;span style=&#34;color:#f92672&#34;&gt;=&amp;gt;&lt;/span&gt; {
        concat&lt;span style=&#34;color:#f92672&#34;&gt;!&lt;/span&gt;(&lt;span style=&#34;color:#75715e&#34;&gt;$s&lt;/span&gt;, &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;\0&amp;#34;&lt;/span&gt;) &lt;span style=&#34;color:#66d9ef&#34;&gt;as&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;*&lt;/span&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;const&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;str&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;as&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;*&lt;/span&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;const&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;u8&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;as&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;*&lt;/span&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;const&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;i8&lt;/span&gt;
    };
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Second, &lt;code&gt;bindgen&lt;/code&gt; can&amp;rsquo;t determine that the C macro &lt;code&gt;lua_pop&lt;/code&gt; can be called like
a function (like a compiler would be able to do in C). This means that any
macros that we want to access from Rust will need to be reimplemented. We&amp;rsquo;ll add
&lt;code&gt;lua_pop&lt;/code&gt; to &lt;code&gt;lib.rs&lt;/code&gt;:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4&#34;&gt;&lt;code class=&#34;language-rust&#34; data-lang=&#34;rust&#34;&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;/// Redefine lua_pop macro from lua.h
&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;/// Pops n elements from the stack
&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;&lt;/span&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;pub&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;unsafe&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;fn&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;lua_pop&lt;/span&gt;(L: &lt;span style=&#34;color:#f92672&#34;&gt;*&lt;/span&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;mut&lt;/span&gt; lua_State, n: &lt;span style=&#34;color:#66d9ef&#34;&gt;i32&lt;/span&gt;) {
    lua_settop(L, &lt;span style=&#34;color:#f92672&#34;&gt;-&lt;/span&gt;(n)&lt;span style=&#34;color:#f92672&#34;&gt;-&lt;/span&gt;&lt;span style=&#34;color:#ae81ff&#34;&gt;1&lt;/span&gt;);
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Lastly, Lua 5.1 turns out to be a fairly old version of Lua. Lua 5.2 includes
standard functions for making it easy to create and load new modules into
Lua. In an effort to not repeat work that has already been done, we&amp;rsquo;ll
port a few of these functions over to &lt;code&gt;lib.rs&lt;/code&gt;: &lt;code&gt;luaL_setfuncs&lt;/code&gt;, &lt;code&gt;luaL_newlib&lt;/code&gt;,
and &lt;code&gt;luaL_newlibtable&lt;/code&gt;.&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4&#34;&gt;&lt;code class=&#34;language-rust&#34; data-lang=&#34;rust&#34;&gt;&lt;span style=&#34;color:#75715e&#34;&gt;// Ported from Lua 5.2
&lt;/span&gt;&lt;span style=&#34;color:#75715e&#34;&gt;&lt;/span&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;unsafe&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;fn&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;luaL_newlibtable&lt;/span&gt;(L: &lt;span style=&#34;color:#f92672&#34;&gt;*&lt;/span&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;mut&lt;/span&gt; lua_State, l: &lt;span style=&#34;color:#66d9ef&#34;&gt;&amp;amp;&lt;/span&gt;[luaL_Reg]) {
    lua_createtable(L, &lt;span style=&#34;color:#ae81ff&#34;&gt;0&lt;/span&gt;, l.len() &lt;span style=&#34;color:#66d9ef&#34;&gt;as&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;i32&lt;/span&gt;);
}

&lt;span style=&#34;color:#75715e&#34;&gt;// Ported from Lua 5.2
&lt;/span&gt;&lt;span style=&#34;color:#75715e&#34;&gt;// For the original function see:
&lt;/span&gt;&lt;span style=&#34;color:#75715e&#34;&gt;// https://www.lua.org/source/5.2/lauxlib.c.html#luaL_setfuncs
&lt;/span&gt;&lt;span style=&#34;color:#75715e&#34;&gt;&lt;/span&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;unsafe&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;fn&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;luaL_setfuncs&lt;/span&gt;(L: &lt;span style=&#34;color:#f92672&#34;&gt;*&lt;/span&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;mut&lt;/span&gt; lua_State, l: &lt;span style=&#34;color:#66d9ef&#34;&gt;&amp;amp;&lt;/span&gt;[luaL_Reg], nup: &lt;span style=&#34;color:#66d9ef&#34;&gt;i32&lt;/span&gt;) {
    luaL_checkstack(L, nup, cstr&lt;span style=&#34;color:#f92672&#34;&gt;!&lt;/span&gt;(&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;too many upvalues&amp;#34;&lt;/span&gt;));
    &lt;span style=&#34;color:#66d9ef&#34;&gt;for&lt;/span&gt; reg &lt;span style=&#34;color:#66d9ef&#34;&gt;in&lt;/span&gt; l {
        &lt;span style=&#34;color:#66d9ef&#34;&gt;for&lt;/span&gt; _ &lt;span style=&#34;color:#66d9ef&#34;&gt;in&lt;/span&gt; &lt;span style=&#34;color:#ae81ff&#34;&gt;0&lt;/span&gt;..nup {
            lua_pushvalue(L, &lt;span style=&#34;color:#f92672&#34;&gt;-&lt;/span&gt;nup);
        }
        lua_pushcclosure(L, reg.func, nup);
        lua_setfield(L, &lt;span style=&#34;color:#f92672&#34;&gt;-&lt;/span&gt;(nup &lt;span style=&#34;color:#f92672&#34;&gt;+&lt;/span&gt; &lt;span style=&#34;color:#ae81ff&#34;&gt;2&lt;/span&gt;), reg.name);
    }
    lua_pop(L, nup);
}

&lt;span style=&#34;color:#75715e&#34;&gt;// Ported from Lua 5.2
&lt;/span&gt;&lt;span style=&#34;color:#75715e&#34;&gt;// Creates a new table and registers there the functions in list l
&lt;/span&gt;&lt;span style=&#34;color:#75715e&#34;&gt;&lt;/span&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;pub&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;unsafe&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;fn&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;luaL_newlib&lt;/span&gt;(L: &lt;span style=&#34;color:#f92672&#34;&gt;*&lt;/span&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;mut&lt;/span&gt; lua_State, l: &lt;span style=&#34;color:#66d9ef&#34;&gt;&amp;amp;&lt;/span&gt;[luaL_Reg]) {
    luaL_newlibtable(L, l);
    luaL_setfuncs(L,l,&lt;span style=&#34;color:#ae81ff&#34;&gt;0&lt;/span&gt;);
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Optional: When you run &lt;code&gt;cargo test&lt;/code&gt; on &lt;code&gt;lua-51-sys&lt;/code&gt;, you&amp;rsquo;ll run into a failing
test, &lt;code&gt;bindgen_test_layout_max_align_t&lt;/code&gt;. If you want, you can remove this type
completely (without issue) by modifying &lt;code&gt;build.rs&lt;/code&gt; and blacklisting the type:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4&#34;&gt;&lt;code class=&#34;language-rust&#34; data-lang=&#34;rust&#34;&gt;    &lt;span style=&#34;color:#66d9ef&#34;&gt;let&lt;/span&gt; bindings &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; bindgen::Builder::default()
        .header(&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;wrapper.h&amp;#34;&lt;/span&gt;)
        .blacklist_type(&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;max_align_t&amp;#34;&lt;/span&gt;)
        .generate()
        .expect(&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;Unable to generate bindings&amp;#34;&lt;/span&gt;);
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id=&#34;creating-a-basic-lua-module&#34; class=&#34;text-2xl font-bold&#34;&gt;
  Creating a Basic Lua Module
&lt;/h2&gt;
&lt;p&gt;Let&amp;rsquo;s go back to the base project &lt;code&gt;lregex&lt;/code&gt;, and modify its &lt;code&gt;Cargo.toml&lt;/code&gt; file.
Replace the &lt;code&gt;[dependencies]&lt;/code&gt; section with the following:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4&#34;&gt;&lt;code class=&#34;language-ini&#34; data-lang=&#34;ini&#34;&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;[lib]&lt;/span&gt;
&lt;span style=&#34;color:#a6e22e&#34;&gt;crate-type&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;[&amp;#34;dylib&amp;#34;]&lt;/span&gt;

&lt;span style=&#34;color:#66d9ef&#34;&gt;[dependencies]&lt;/span&gt;
&lt;span style=&#34;color:#a6e22e&#34;&gt;lua-51-sys&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;{ path = &amp;#34;lua-51-sys&amp;#34; }&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Now, let&amp;rsquo;s modify &lt;code&gt;src/lib.rs&lt;/code&gt;. First, clear it of any test code, then add the
following:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4&#34;&gt;&lt;code class=&#34;language-rust&#34; data-lang=&#34;rust&#34;&gt;&lt;span style=&#34;color:#75715e&#34;&gt;#[macro_use]&lt;/span&gt;
&lt;span style=&#34;color:#66d9ef&#34;&gt;extern&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;crate&lt;/span&gt; lua_51_sys;
&lt;span style=&#34;color:#66d9ef&#34;&gt;use&lt;/span&gt; lua_51_sys::&lt;span style=&#34;color:#f92672&#34;&gt;*&lt;/span&gt;;

&lt;span style=&#34;color:#75715e&#34;&gt;#[no_mangle]&lt;/span&gt;
&lt;span style=&#34;color:#66d9ef&#34;&gt;pub&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;unsafe&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;extern&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;C&amp;#34;&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;fn&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;foo&lt;/span&gt;(state: &lt;span style=&#34;color:#f92672&#34;&gt;*&lt;/span&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;mut&lt;/span&gt; lua_State) -&amp;gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;i32&lt;/span&gt; {
    &lt;span style=&#34;color:#66d9ef&#34;&gt;let&lt;/span&gt; d &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; lua_tonumber(state, &lt;span style=&#34;color:#ae81ff&#34;&gt;1&lt;/span&gt;);
    lua_pushnumber(state, d &lt;span style=&#34;color:#f92672&#34;&gt;+&lt;/span&gt; &lt;span style=&#34;color:#ae81ff&#34;&gt;42.&lt;/span&gt;);
    &lt;span style=&#34;color:#ae81ff&#34;&gt;1&lt;/span&gt;
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Then add this:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4&#34;&gt;&lt;code class=&#34;language-rust&#34; data-lang=&#34;rust&#34;&gt;&lt;span style=&#34;color:#75715e&#34;&gt;#[no_mangle]&lt;/span&gt;
&lt;span style=&#34;color:#66d9ef&#34;&gt;pub&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;unsafe&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;extern&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;C&amp;#34;&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;fn&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;luaopen_liblregex&lt;/span&gt;(state: &lt;span style=&#34;color:#f92672&#34;&gt;*&lt;/span&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;mut&lt;/span&gt; lua_State) -&amp;gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;i32&lt;/span&gt; {
    luaL_newlib(
        state,
        &lt;span style=&#34;color:#f92672&#34;&gt;&amp;amp;&lt;/span&gt;[
            luaL_Reg { name: &lt;span style=&#34;color:#a6e22e&#34;&gt;cstr&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;!&lt;/span&gt;(&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;foo&amp;#34;&lt;/span&gt;), func: Some(foo), }
        ],
    );
    &lt;span style=&#34;color:#ae81ff&#34;&gt;1&lt;/span&gt;
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Then run &lt;code&gt;cargo build&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Then put the following in &lt;code&gt;main.lua&lt;/code&gt;:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4&#34;&gt;&lt;code class=&#34;language-lua&#34; data-lang=&#34;lua&#34;&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;local&lt;/span&gt; regex &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; require &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;liblregex&amp;#39;&lt;/span&gt;

&lt;span style=&#34;color:#66d9ef&#34;&gt;function&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;love&lt;/span&gt;.&lt;span style=&#34;color:#a6e22e&#34;&gt;draw&lt;/span&gt;()
    love.graphics.print(&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;Foo is: &amp;#34;&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;..&lt;/span&gt; regex.foo(&lt;span style=&#34;color:#ae81ff&#34;&gt;12&lt;/span&gt;), &lt;span style=&#34;color:#ae81ff&#34;&gt;400&lt;/span&gt;, &lt;span style=&#34;color:#ae81ff&#34;&gt;300&lt;/span&gt;)
&lt;span style=&#34;color:#66d9ef&#34;&gt;end&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Then link the library &lt;code&gt;ln -s target/debug/liblregex.so&lt;/code&gt; (different on Windows).&lt;/p&gt;
&lt;p&gt;Run &lt;code&gt;love .&lt;/code&gt;&lt;/p&gt;
&lt;h2 id=&#34;wrapping-the-regex-crate&#34; class=&#34;text-2xl font-bold&#34;&gt;
  Wrapping the Regex Crate
&lt;/h2&gt;
&lt;p&gt;Now that we have a framework set up for creating and loading Lua modules, let&amp;rsquo;s
get our Lua module to do some real work! Let&amp;rsquo;s expose &lt;code&gt;regex::Regex::find&lt;/code&gt; to
Lua. First we&amp;rsquo;ll add the &lt;code&gt;regex&lt;/code&gt; crate to our toml file:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4&#34;&gt;&lt;code class=&#34;language-ini&#34; data-lang=&#34;ini&#34;&gt;&lt;span style=&#34;color:#a6e22e&#34;&gt;regex&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;1.0.2&amp;#34;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Then, we&amp;rsquo;ll create our new function:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4&#34;&gt;&lt;code class=&#34;language-rust&#34; data-lang=&#34;rust&#34;&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;use&lt;/span&gt; regex::Regex;

&lt;span style=&#34;color:#75715e&#34;&gt;#[no_mangle]&lt;/span&gt;
&lt;span style=&#34;color:#66d9ef&#34;&gt;pub&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;unsafe&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;extern&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;C&amp;#34;&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;fn&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;find&lt;/span&gt;(state: &lt;span style=&#34;color:#f92672&#34;&gt;*&lt;/span&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;mut&lt;/span&gt; lua_State) -&amp;gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;i32&lt;/span&gt; {
    &lt;span style=&#34;color:#66d9ef&#34;&gt;let&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;mut&lt;/span&gt; pattern_len &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#ae81ff&#34;&gt;0&lt;/span&gt;;
    &lt;span style=&#34;color:#66d9ef&#34;&gt;let&lt;/span&gt; pattern_ptr &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; lua_tolstring(state, &lt;span style=&#34;color:#ae81ff&#34;&gt;1&lt;/span&gt;, &lt;span style=&#34;color:#f92672&#34;&gt;&amp;amp;&lt;/span&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;mut&lt;/span&gt; pattern_len) &lt;span style=&#34;color:#66d9ef&#34;&gt;as&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;*&lt;/span&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;mut&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;u8&lt;/span&gt;;
    &lt;span style=&#34;color:#66d9ef&#34;&gt;let&lt;/span&gt; pattern &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; std::&lt;span style=&#34;color:#66d9ef&#34;&gt;str&lt;/span&gt;::from_utf8_unchecked(
        std::slice::from_raw_parts(pattern_ptr, pattern_len)
    );

    &lt;span style=&#34;color:#66d9ef&#34;&gt;let&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;mut&lt;/span&gt; text_len &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#ae81ff&#34;&gt;0&lt;/span&gt;;
    &lt;span style=&#34;color:#66d9ef&#34;&gt;let&lt;/span&gt; text_ptr &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; lua_tolstring(state, &lt;span style=&#34;color:#ae81ff&#34;&gt;2&lt;/span&gt;, &lt;span style=&#34;color:#f92672&#34;&gt;&amp;amp;&lt;/span&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;mut&lt;/span&gt; text_len) &lt;span style=&#34;color:#66d9ef&#34;&gt;as&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;*&lt;/span&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;mut&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;u8&lt;/span&gt;;
    &lt;span style=&#34;color:#66d9ef&#34;&gt;let&lt;/span&gt; text &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; std::&lt;span style=&#34;color:#66d9ef&#34;&gt;str&lt;/span&gt;::from_utf8_unchecked(
        std::slice::from_raw_parts(text_ptr, text_len)
    );

    &lt;span style=&#34;color:#75715e&#34;&gt;// Error flag
&lt;/span&gt;&lt;span style=&#34;color:#75715e&#34;&gt;&lt;/span&gt;    &lt;span style=&#34;color:#66d9ef&#34;&gt;let&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;mut&lt;/span&gt; error &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;false&lt;/span&gt;;

    &lt;span style=&#34;color:#75715e&#34;&gt;// We only want to return in _one_ place to make sure we don&amp;#39;t forget to
&lt;/span&gt;&lt;span style=&#34;color:#75715e&#34;&gt;&lt;/span&gt;    &lt;span style=&#34;color:#75715e&#34;&gt;// free memory
&lt;/span&gt;&lt;span style=&#34;color:#75715e&#34;&gt;&lt;/span&gt;    &lt;span style=&#34;color:#66d9ef&#34;&gt;let&lt;/span&gt; return_stack_size &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;match&lt;/span&gt; Regex::new(&lt;span style=&#34;color:#f92672&#34;&gt;&amp;amp;&lt;/span&gt;pattern) {
        Ok(re) &lt;span style=&#34;color:#f92672&#34;&gt;=&amp;gt;&lt;/span&gt; {
            &lt;span style=&#34;color:#66d9ef&#34;&gt;if&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;let&lt;/span&gt; Some(match_bytes) &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; re.find(&lt;span style=&#34;color:#f92672&#34;&gt;&amp;amp;&lt;/span&gt;text) {
                &lt;span style=&#34;color:#66d9ef&#34;&gt;let&lt;/span&gt; (start, end) &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; (match_bytes.start(), match_bytes.end());
                lua_pushnumber(state, start &lt;span style=&#34;color:#66d9ef&#34;&gt;as&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;f64&lt;/span&gt;);
                lua_pushnumber(state, end &lt;span style=&#34;color:#66d9ef&#34;&gt;as&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;f64&lt;/span&gt;);
                &lt;span style=&#34;color:#ae81ff&#34;&gt;2&lt;/span&gt;
            } &lt;span style=&#34;color:#66d9ef&#34;&gt;else&lt;/span&gt; {
                lua_pushnil(state);
                &lt;span style=&#34;color:#ae81ff&#34;&gt;1&lt;/span&gt;
            }
        }
        Err(e) &lt;span style=&#34;color:#f92672&#34;&gt;=&amp;gt;&lt;/span&gt; {
            &lt;span style=&#34;color:#66d9ef&#34;&gt;match&lt;/span&gt; e {
                regex::Error::Syntax(_) &lt;span style=&#34;color:#f92672&#34;&gt;=&amp;gt;&lt;/span&gt; {
                    lua_pushstring(state, cstr&lt;span style=&#34;color:#f92672&#34;&gt;!&lt;/span&gt;(&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;Syntax error :(&amp;#34;&lt;/span&gt;));
                    error &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;true&lt;/span&gt;;
                }
                _ &lt;span style=&#34;color:#f92672&#34;&gt;=&amp;gt;&lt;/span&gt; {
                    lua_pushstring(state, cstr&lt;span style=&#34;color:#f92672&#34;&gt;!&lt;/span&gt;(&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;Regex internal error :(&amp;#34;&lt;/span&gt;));
                    error &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;true&lt;/span&gt;;
                }
            }
            &lt;span style=&#34;color:#ae81ff&#34;&gt;1&lt;/span&gt;
        }
    };

    &lt;span style=&#34;color:#66d9ef&#34;&gt;if&lt;/span&gt; error {
        &lt;span style=&#34;color:#75715e&#34;&gt;// This never returns
&lt;/span&gt;&lt;span style=&#34;color:#75715e&#34;&gt;&lt;/span&gt;        lua_error(state);
    }

    return_stack_size
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Don&amp;rsquo;t forget to modify &lt;code&gt;luaopen_liblregex&lt;/code&gt; with the new function.&lt;/p&gt;
&lt;p&gt;Now let&amp;rsquo;s modify our &lt;code&gt;main.lua&lt;/code&gt; to test this:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4&#34;&gt;&lt;code class=&#34;language-lua&#34; data-lang=&#34;lua&#34;&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;local&lt;/span&gt; regex &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; require &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;liblregex&amp;#39;&lt;/span&gt;

&lt;span style=&#34;color:#66d9ef&#34;&gt;function&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;love&lt;/span&gt;.&lt;span style=&#34;color:#a6e22e&#34;&gt;draw&lt;/span&gt;()
    &lt;span style=&#34;color:#66d9ef&#34;&gt;local&lt;/span&gt; pattern &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;([abc])*d&amp;#39;&lt;/span&gt;
    &lt;span style=&#34;color:#66d9ef&#34;&gt;local&lt;/span&gt; text &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;abbbcd&amp;#39;&lt;/span&gt;

    head, tail &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; regex.find(pattern, text)

    &lt;span style=&#34;color:#66d9ef&#34;&gt;if&lt;/span&gt; head &lt;span style=&#34;color:#66d9ef&#34;&gt;then&lt;/span&gt;
        love.graphics.print(&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;Start: &amp;#34;&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;..&lt;/span&gt; head &lt;span style=&#34;color:#f92672&#34;&gt;..&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34; End: &amp;#34;&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;..&lt;/span&gt; tail , &lt;span style=&#34;color:#ae81ff&#34;&gt;400&lt;/span&gt;, &lt;span style=&#34;color:#ae81ff&#34;&gt;300&lt;/span&gt;)
    &lt;span style=&#34;color:#66d9ef&#34;&gt;else&lt;/span&gt;
        love.graphics.print(&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;No match for pattern &amp;#39;&amp;#34;&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;..&lt;/span&gt; pattern &lt;span style=&#34;color:#f92672&#34;&gt;..&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;&amp;#39;&amp;#34;&lt;/span&gt;, &lt;span style=&#34;color:#ae81ff&#34;&gt;100&lt;/span&gt;, &lt;span style=&#34;color:#ae81ff&#34;&gt;300&lt;/span&gt;)
        love.graphics.print(&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;in text &amp;#39;&amp;#34;&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;..&lt;/span&gt; text &lt;span style=&#34;color:#f92672&#34;&gt;..&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;&amp;#39;&amp;#34;&lt;/span&gt;, &lt;span style=&#34;color:#ae81ff&#34;&gt;100&lt;/span&gt;, &lt;span style=&#34;color:#ae81ff&#34;&gt;320&lt;/span&gt;)
    &lt;span style=&#34;color:#66d9ef&#34;&gt;end&lt;/span&gt;
&lt;span style=&#34;color:#66d9ef&#34;&gt;end&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;And you should see &lt;code&gt;Start: 0 End: 6&lt;/code&gt; on the screen!&lt;/p&gt;
&lt;h2 id=&#34;conclusion&#34; class=&#34;text-2xl font-bold&#34;&gt;
  Conclusion
&lt;/h2&gt;
&lt;p&gt;At this point you should have learned a few things:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;How to generate Rust bindings from C code&lt;/li&gt;
&lt;li&gt;How to create a dynamic library in Rust&lt;/li&gt;
&lt;li&gt;How to register new functions in Lua from a Rust module&lt;/li&gt;
&lt;li&gt;How to get parameters from the Lua stack in Rust&lt;/li&gt;
&lt;li&gt;How to return multiple results on the Lua stack&lt;/li&gt;
&lt;li&gt;How to create Lua errors&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Try wrapping different libraries, and send me a tweet &lt;a href=&#34;https://twitter.com/SHMolyneaux&#34;&gt;@shmolyneaux&lt;/a&gt;
with your results!&lt;/p&gt;</description>
    </item>
    <item>
      <title>Hugo Knowledge Checklist</title>
      <link>https://stephen.molyneaux.ca/blog/hugo-knowledge-checklist/</link>
      <pubDate>Sat, 17 Apr 2021 20:48:02 -0700</pubDate>
      <guid>https://stephen.molyneaux.ca/blog/hugo-knowledge-checklist/</guid>
      <description>&lt;p&gt;&lt;a href=&#34;https://gohugo.io&#34;&gt;Hugo&lt;/a&gt; is a flexible way to generate static sites. Many people
reach for premade themes/templates, but some people (like me!) want to create
their own. There&amp;rsquo;s a lot to learn about Hugo and it can be daunting to take it all in at once.&lt;/p&gt;
&lt;p&gt;This post is a beginner&amp;rsquo;s checklist for learning Hugo. This picks up right after
you&amp;rsquo;ve completed the &lt;a href=&#34;https://gohugo.io/getting-started/quick-start/&#34;&gt;Hugo Quick Start Guide&lt;/a&gt;.&lt;/p&gt;
&lt;h2 id=&#34;checklist&#34; class=&#34;text-2xl font-bold&#34;&gt;
  Checklist
&lt;/h2&gt;
&lt;p&gt;By learning just these concepts, you should be able to create a website with a
home page, a blog, and other specialized content without having to rummage
through all the docs. The rest of the docs will come into play once you&amp;rsquo;re looking
to create more advanced content.&lt;/p&gt;
&lt;p&gt;To get you started, I&amp;rsquo;ve provided working examples of each type of file.&lt;/p&gt;
&lt;h3 id=&#34;base-templates&#34; class=&#34;header_3&#34;&gt;
  Base Templates
&lt;/h3&gt;
&lt;p&gt;&lt;a href=&#34;https://gohugo.io/templates/base&#34;&gt;Documentation&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;With few exceptions, you should be extending a base template for all the
templates you create. A base template usually defines the outermost layer of
each page. The &lt;code&gt;&amp;lt;html&amp;gt;&lt;/code&gt;, &lt;code&gt;&amp;lt;head&amp;gt;&lt;/code&gt;, and &lt;code&gt;&amp;lt;body&amp;gt;&lt;/code&gt; tags are in this file.&lt;/p&gt;
&lt;p&gt;The base template defines a number of sections. When templates extend a base
template, they provide the content to fill these sections. Sections start with
&lt;code&gt;{{ block &amp;quot;my-block-name&amp;quot; . }}&lt;/code&gt; and end with &lt;code&gt;{{ end }}&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;You should create a base template in &lt;code&gt;layouts/_default/baseof.html&lt;/code&gt; that&amp;rsquo;s used
by all your other templates. To start, you&amp;rsquo;ll want to have a &lt;code&gt;main&lt;/code&gt; section where
the primary content of the page lives. You&amp;rsquo;ll also want to have a &lt;code&gt;title&lt;/code&gt; section
so that individual pages can set the title of the page.&lt;/p&gt;
&lt;p&gt;The base template could look like this (&lt;code&gt;layouts/_default/baseof.html&lt;/code&gt;):&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4&#34;&gt;&lt;code class=&#34;language-html&#34; data-lang=&#34;html&#34;&gt;&amp;lt;&lt;span style=&#34;color:#f92672&#34;&gt;html&lt;/span&gt;&amp;gt;
  &amp;lt;&lt;span style=&#34;color:#f92672&#34;&gt;head&lt;/span&gt;&amp;gt;
    &amp;lt;&lt;span style=&#34;color:#f92672&#34;&gt;title&lt;/span&gt;&amp;gt;
        &lt;span style=&#34;color:#75715e&#34;&gt;&amp;lt;!-- Default to the name of the site if a title isn&amp;#39;t provided --&amp;gt;&lt;/span&gt;
        {{ block &amp;#34;title&amp;#34; . }}
            {{ .Site.Title }}
        {{ end }}
    &amp;lt;/&lt;span style=&#34;color:#f92672&#34;&gt;title&lt;/span&gt;&amp;gt;
  &amp;lt;/&lt;span style=&#34;color:#f92672&#34;&gt;head&lt;/span&gt;&amp;gt;
  &amp;lt;&lt;span style=&#34;color:#f92672&#34;&gt;body&lt;/span&gt;&amp;gt;
    {{ block &amp;#34;main&amp;#34; . }}
        &lt;span style=&#34;color:#75715e&#34;&gt;&amp;lt;!-- Templates will fill this content --&amp;gt;&lt;/span&gt;
    {{ end }}
  &amp;lt;/&lt;span style=&#34;color:#f92672&#34;&gt;body&lt;/span&gt;&amp;gt;
&amp;lt;/&lt;span style=&#34;color:#f92672&#34;&gt;html&lt;/span&gt;&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;We&amp;rsquo;ll use this base template when creating &amp;ldquo;list&amp;rdquo; and &amp;ldquo;page&amp;rdquo; templates in this checklist.&lt;/p&gt;
&lt;h3 id=&#34;list-page-templates&#34; class=&#34;header_3&#34;&gt;
  List Page Templates
&lt;/h3&gt;
&lt;p&gt;&lt;a href=&#34;https://gohugo.io/templates/lists&#34;&gt;Documentation&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;List pages typically give an overview of a particular type of content. For example,
going to the &amp;ldquo;news&amp;rdquo; section of a website might show you snippets of text for
each news post on the site.&lt;/p&gt;
&lt;p&gt;This can get fairly elaborate. For example, you could have a list of courses, and
each course could be a list of lessons.&lt;/p&gt;
&lt;p&gt;Here&amp;rsquo;s a basic list page template that uses the base template from above (&lt;code&gt;layouts/_default/list.html&lt;/code&gt;):&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4&#34;&gt;&lt;code class=&#34;language-html&#34; data-lang=&#34;html&#34;&gt;{{ define &amp;#34;title&amp;#34; }}
    {{ .Page.Title }}
{{ end }}

{{ define &amp;#34;main&amp;#34; }}
    &amp;lt;&lt;span style=&#34;color:#f92672&#34;&gt;h1&lt;/span&gt;&amp;gt;{{ .Page.Title }}&amp;lt;/&lt;span style=&#34;color:#f92672&#34;&gt;h1&lt;/span&gt;&amp;gt;
    {{ .Content }}
    &amp;lt;&lt;span style=&#34;color:#f92672&#34;&gt;ul&lt;/span&gt;&amp;gt;
    {{ range .Pages }}
        &amp;lt;&lt;span style=&#34;color:#f92672&#34;&gt;li&lt;/span&gt;&amp;gt;
            &amp;lt;&lt;span style=&#34;color:#f92672&#34;&gt;a&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;href&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;{{ .Permalink }}&amp;#34;&lt;/span&gt;&amp;gt;
                {{ .Title }}
            &amp;lt;/&lt;span style=&#34;color:#f92672&#34;&gt;a&lt;/span&gt;&amp;gt;
        &amp;lt;/&lt;span style=&#34;color:#f92672&#34;&gt;li&lt;/span&gt;&amp;gt;
    {{ end }}
    &amp;lt;/&lt;span style=&#34;color:#f92672&#34;&gt;ul&lt;/span&gt;&amp;gt;
{{ end }}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;You can see we use &lt;code&gt;range&lt;/code&gt; to iterate over each piece of content, and we&amp;rsquo;re
grabbing the name and url of the content. To get a short summary of the content
of the page, you can use the &lt;code&gt;{{ .Summary }}&lt;/code&gt; property. This is autogenerated,
but can be specified manually in &lt;a href=&#34;https://gohugo.io/content-management/summaries&#34;&gt;various ways&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;For content in &lt;code&gt;content/posts&lt;/code&gt;, you can see the list page for that content at
&lt;code&gt;https://yoursite.com/posts&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;To customize this page, you can create a &lt;code&gt;_index.md&lt;/code&gt; page at &lt;code&gt;content/posts/_index.md&lt;/code&gt;.
The rendered text from that markdown file is available to the list page template
as &lt;code&gt;.Content&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;If you want to create a new template specifically for your posts (rather than
using the default), you can create a new template at &lt;code&gt;layouts/posts/list.html&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Your homepage is also a list template and will use the default template if you
don&amp;rsquo;t provide one. Alternatively, you can specify one explicitly in &lt;code&gt;layouts/list.html&lt;/code&gt;.&lt;/p&gt;
&lt;h3 id=&#34;single-page-templates&#34; class=&#34;header_3&#34;&gt;
  Single Page Templates
&lt;/h3&gt;
&lt;p&gt;&lt;a href=&#34;https://gohugo.io/templates/single-page-templates&#34;&gt;Documentation Link&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Single pages are your pieces of content, whether that&amp;rsquo;s a blog post, tutorial,
or article. Hugo allows you to attach YAML data to content. This lets you
associate things like videos or a hero image with your content. Those bits of data
are accessible to the single page template. Hugo capitalizes the property name,
so &lt;code&gt;prop&lt;/code&gt; becomes &lt;code&gt;Prop&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;At it&amp;rsquo;s most basic, a single page should probably show the title of the content
and the text from the content.&lt;/p&gt;
&lt;p&gt;Here&amp;rsquo;s a basic one you could use as a default (&lt;code&gt;layouts/_default/single.html&lt;/code&gt;):&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4&#34;&gt;&lt;code class=&#34;language-html&#34; data-lang=&#34;html&#34;&gt;{{ define &amp;#34;title&amp;#34; }}
    {{ .Page.Title }}
{{ end }}

{{ define &amp;#34;main&amp;#34; }}
    &amp;lt;&lt;span style=&#34;color:#f92672&#34;&gt;div&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;class&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;prose&amp;#34;&lt;/span&gt;&amp;gt;
        &amp;lt;&lt;span style=&#34;color:#f92672&#34;&gt;h1&lt;/span&gt;&amp;gt;{{ .Page.Title }}&amp;lt;/&lt;span style=&#34;color:#f92672&#34;&gt;h1&lt;/span&gt;&amp;gt;
        {{ .Content }}
    &amp;lt;/&lt;span style=&#34;color:#f92672&#34;&gt;div&lt;/span&gt;&amp;gt;
{{ end }}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;You&amp;rsquo;ll see that I wrapped the contents in a div with class &lt;code&gt;prose&lt;/code&gt;. This makes
it easy to create CSS that just targets the contents of the page, but doesn&amp;rsquo;t
affect the templates. The HTML tags that Hugo generates don&amp;rsquo;t have any classes
you can hook on to, so you need to provide something to select on in your CSS.&lt;/p&gt;
&lt;p&gt;If you want to create a template specifically for your posts, you can create a
new template at &lt;code&gt;layouts/posts/single.html&lt;/code&gt;. This allows you to display your
posts differently than tutorials, news items, etc.&lt;/p&gt;
&lt;h3 id=&#34;static-files&#34; class=&#34;header_3&#34;&gt;
  Static Files
&lt;/h3&gt;
&lt;p&gt;For site-wide static files (images, css, js), put them in the &lt;code&gt;static&lt;/code&gt; directory.
Now those files are accessible at the base of your site (E.g.&lt;code&gt;https://yoursite.com/yourfile.foo&lt;/code&gt;).
From there you could to link your CSS it in your base template (&lt;code&gt;layout/_default/baseof.html&lt;/code&gt;)
with &lt;code&gt;&amp;lt;link href=&amp;quot;/yourstyle.css&amp;quot; rel=&amp;quot;stylesheet&amp;quot;&amp;gt;&lt;/code&gt;.&lt;/p&gt;
&lt;h3 id=&#34;template-lookup-order&#34; class=&#34;header_3&#34;&gt;
  Template Lookup Order
&lt;/h3&gt;
&lt;p&gt;&lt;a href=&#34;https://gohugo.io/templates/lookup-order&#34;&gt;Documentation&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;It&amp;rsquo;s helpful to know in detail where templates can go, and how to find out
which template is being used for which bit of content. This page will break that
down (and where the home page template goes!).&lt;/p&gt;
&lt;h2 id=&#34;closing-thoughts&#34; class=&#34;text-2xl font-bold&#34;&gt;
  Closing Thoughts
&lt;/h2&gt;
&lt;p&gt;Understanding how to create content and templates is the backbone of Hugo. Once
you understand these basics, you can start to branch out. Hugo has a bunch
of special features for common things for websites.&lt;/p&gt;
&lt;p&gt;If you want a &lt;code&gt;robots.txt&lt;/code&gt; and a sitemap for SEO, Hugo has you covered. Search
bar? Yup!  Tags on your blog post? Sure. Hugo also has a bunch of functions you
can call from your templates.&lt;/p&gt;
&lt;p&gt;Remember to check out the &lt;a href=&#34;https://gohugo.io/showcase&#34;&gt;Hugo Showcase&lt;/a&gt; to see the
awesome sites folks have made!&lt;/p&gt;</description>
    </item>
  </channel>
</rss>
