abhinavsarkar.net
atom
Programming Posts & Notes on abhinavsarkar.net
abhinavsarkar.net · abhinavsarkar.net · English
Personal website and blog of Abhinav Sarkar.
atomfediverseindieweb
https://abhinavsarkar.net/feed.atom
- Last post
- Oct 31, 2026
- Posts in 24 h · 7 days · 30 days
- 0 · 1 · 2
- Our last check
- Answering
- Served from
- United States
- Site title
- Home
- Text score
- 49,384
- Format
- atom
- Community
- fediverse, indieweb
Posts
What our queue read from this feed. Open one to read it here, or go to the site that published it.
- An LC-3 Disassembler in Haskell
Oct 31, 2026 · original
LC-3 assembly is an educational programming language. It is simple enough that complex programs can be written directly in it without needing a compiler, and thus it is often used in teaching assembly. An LC-3 textual assembly program is compiled to a binary object file by an assembler, and then executed by a virtual machine . Writing a virtual machine for LC-3 is a fun little exercise. However, in this post, we implement a disassembler for compiled LC-3 binaries back to textual assembly programs. This post was originally published on abhinavsarkar.net . Contents Introduction to LC-3 Problem in Disassembling LC-3 Setting Up Decoding Instructions Basic Disassembly Fixed-Point Cleanup Postprocessing Pretty-Printing Reading the Binary Finishing Up Conclusion Introduction to LC-3 # LC-3 has a simple instruction set with only 18 instructions. It works with eight 16-bit registers (numbered fro - Extending BlogShake with Per-Tag Atom Feeds
Oct 25, 2026 · original
This is an external post of mine, originally published at Extending BlogShake with Per-Tag Atom Feeds . - Introducing Ahm
Aug 31, 2026 · original
This is an external post of mine, originally published at Introducing Ahm . - Fast Haskell Scripts on GitHub Actions
Aug 10, 2026 · original
Magix is a neat tool that lets us run Haskell programs as scripts 1 . We put a shebang on top mentioning Magix, list the Haskell packages we need, and ./script.hs just works. This post is about running such a script fast(er) on GitHub Actions . This post was originally published on abhinavsarkar.net . Contents The Setup The Problem The Idea The Bundle The GitHub Actions Workflow The Payoff The Conclusion The Setup # As our example, we’ll take the static site generator (SSG) I wrote some time ago: BlogShake . It is written as a single Haskell file. It uses Shake to build the website, Pandoc to render posts, and Mustache for templates. The script starts with these Magix directives 2 : #!/usr/bin/env magix #!magix haskell #!haskellPackages mustache pandoc shake feed yaml #!ghcFlags -threaded -O2 Running the script is as simple as: ./blog.hs Magix compiles the script into an executable and r - The Making of This Website
Jun 26, 2026 · original
Almost nine years ago, I decided to write my own website generator. Static-site generators (SSGs) were sort of new back then, and somewhat fascinating to me. After failing to start a website/blog for a decade, I realized that I’ll never be satisfied by a ready-made solution, and I need to make something of my own. I started with Hakyll , a small SSG framework written in Haskell. Over years, I expanded my website by adding new sections and features. The website code has grown from 500 lines to over 17000 lines now. This note recalls the story of the same. The Hakyll Era # Some time in September 2017, I started with the 483 lines of example code Hakyll comes with. I liked Haskell and Hakyll was pretty easy to get started with because of ample examples and tutorials. It worked as expected for making a small blog-like website. All was good. Over the next couple of years, I started adding non - Nix for Haskell: Static Builds
Jun 18, 2026 · original
In the previous post , we learned how to get started with managing and building a Haskell project with Nix . In this post, we learn how to easily create statically-linked executables for Haskell projects with Nix. This post was originally published on abhinavsarkar.net . This post is a part of the series: Nix for Haskell . Getting Started Static Builds 👈 Contents Static Builds Enabling Static Builds in GHC Configuring the Application Rooting Static Build Dependencies Finale Bonus: Building a Docker Image Conclusion I recommend going through the previous post , because we are going to start off from where we left last time (ignoring the bonus sections). This is how our project’s directory tree looks at this point: . |— app | |— Main.hs |— ftr.cabal |— nix | |— nixpkgs.nix | |— sources.json | |— sources.nix |— package.nix |— shell.nix Main.hs is the default generated main file that prints - Running NixOS Micro VMs on MacOS
Apr 9, 2026 · original
microvm.nix is a framework to run NixOS based micro VMs on various platforms. In particular, it can use vfkit to run micro VMs on macOS that use the macOS virtualization framework to provide a more performant VM than QEMU . microvm.nix works well but the documentation is a bit lacking. I had to figure out some gotchas while setting this up on my MacBook Pro M4, so I decided to write this note. This tutorial requires Nix and Nix Darwin to be installed on the macOS machine. To build a micro VM, we need a NixOS builder machine running AArch64 Linux. Thankfully, it is really easy to set up one with Nix Darwin. Assuming we have Nix Darwin set up with a Nix flake like: { inputs = { nixpkgs . url = "github:nixos/nixpkgs/nixpkgs-25.11-darwin" ; nix-darwin = { url = "github:LnL7/nix-darwin" ; inputs . nixpkgs . follows = "nixpkgs" ; }; }; outputs = inputs@ { self , nixpkgs , nix-darwin , ... } : - Implementing Co, a Small Language With Coroutines #5: Adding Sleep
Jan 16, 2026 · original
In the previous post , we added channels to Co , the small language we are implementing in this series of posts. In this post, we add the sleep primitive to it, enabling time-based coroutine scheduling. We then use sleep to build a simulation of digital logic circuits. This post was originally published on abhinavsarkar.net . This post is a part of the series: Implementing Co, a Small Language With Coroutines . The Parser The Interpreter Adding Coroutines Adding Channels Adding Sleep 👈 Contents Introduction Adding Sleep Delayed Coroutines Queuing Coroutines Implementing Sleep Sleep in Action Sleep Sort JavaScript-like Timeouts and Intervals Bonus Round: Digital Circuit Simulation Conjuring Lists Wires Logic Gates Adders Ripple-carry Adder Conclusion Introduction # Sleep is a commonly used operation in concurrent programs. It pauses the execution of the current Thread of Computation (ToC - How I use Jujutsu
Jan 10, 2026 · original
About three months ago I started using Jujutsu (JJ), a new Version Control System , for my personal projects. It took me a while to get used to it after more than a decade of using Git , but now I’m quite comfortable with it. Working with Jujutsu requires a shift from the mental model of Git. However, it is not as daunting as it may seem on the first day. This post was originally published on abhinavsarkar.net . Looking back, I don’t actually use all the fancy things JJ provides, and you may not need to either. In this post I list my most used JJ commands and how I use them. It is not meant to be a tutorial, or even a comprehensive list, but it should be enough to get you started. This post assumes that the reader knows how to use Git. Contents Starting Up jj git init jj git clone jj config Creating Changes jj new jj describe jj commit jj status Modifying Changes jj edit jj squash jj spl - Polls I Ran on Mastodon in 2025
Dec 31, 2025 · original
In 2025, I ran ten polls on Mastodon exploring various topics, mostly to outsource my research to the hivemind. Here are the poll results organized by topic, with commentary. Contents General Programming JSON Pronunciation Compilers Compiler Backend Targets Haskell Parsing Libraries Compiler in Haskell with Lenses Blogging & Web Blog Post Length Preferences Blog Post Print Support Résumés on Personal Website “Writing a C Compiler” Blog Series Self-hosting Service Packaging Preferences Hetzner Backup Strategy General Programming # JSON Pronunciation # How do you pronounce JSON? January 15, 2025 See as table Option Votes Jay-Son, O as in Otter 66 Jay-Son, O as in Utter 27 Jay-Son, O as in Oh 5 something else, comment 5 Jay-Ess-On 1 Total 104 I’m in the “Jay-Son, O as in Otter” camp, which is the majority response. It seems like most Americans prefer the “Jay-Son, O as in Utter” option. Tha - Working on My Website in 2025
Dec 26, 2025 · original
Looking back at 2025, I spent a lot of time working on my website. I did nearly 500 commits focused on content diversification, feature expansion, and performance optimization. Let me walk through what I did chronologically by months. This post was originally published on abhinavsarkar.net . January–March # January started with adding MathJax support in blog posts and code syntax highlighting in the Microblog . I migrated the Changelog from Markdown to YAML, enabling easier updates. I also added a dedicated Changelog feed and support for pulling post likes from Discourse. In February I focused on tagging improvements: tag stemming and aggregation to reduce duplication in the Microblog, and updating the tag cloud algorithm to use logarithmic scaling for better visual hierarchy. In March I worked mostly on the frontend: enabling JS and CSS minification, removing unnecessary polyfills, clea - Solving Advent of Code 2025 in Janet: Days 5–8
Dec 13, 2025 · original
I’m solving the Advent of Code 2025 in Janet . After doing the last five years in Haskell, I wanted to learn a new language this year. I’ve been eyeing the “New Lisps” 1 for a while now, and I decided to learn Janet. Janet is a Clojure like Lisp that can be interpreted, embedded and compiled, and comes with a large standard library with concurrency, HTTP and PEG parser support. I want to replace Python with Janet as my scripting language. Here are my solutions for December 5–8. This post was originally published on abhinavsarkar.net . This post is a part of the series: Solving Advent of Code 2025 in Janet . Days 1–4 Days 5–8 👈 Contents Day 5 Day 6 Day 7 Day 8 Day 5 # Problem . Solution: ( def base-path (os/getenv "AOC_INPUT_PATH" )) ( def input-path (string base-path "/5.txt" )) ( def input-peg (peg/compile ~{ :main ( sequence :ranges " \n " :ids - 1 ) :ranges (group ( some :range )) :r - Solving Advent of Code 2025 in Janet: Days 1–4
Dec 5, 2025 · original
I’m solving the Advent of Code 2025 in Janet . After doing the last five years in Haskell, I wanted to learn a new language this year. I’ve been eyeing the “New Lisps” 1 for a while now, and I decided to learn Janet. Janet is a Clojure like Lisp that can be interpreted, embedded and compiled, and comes with a large standard library with concurrency, HTTP and PEG parser support. I want to replace Python with Janet as my scripting language. Here are my solutions for December 1–4. This post was originally published on abhinavsarkar.net . This post is a part of the series: Solving Advent of Code 2025 in Janet . Days 1–4 👈 Days 5–8 Contents Day 1 Day 2 Day 3 Day 4 Day 1 # Problem . Solution: ( def base-path (os/getenv "AOC_INPUT_PATH" )) ( def input-path (string base-path "/1.txt" )) ( def pattern-captured '( some ( sequence (capture (choice "L" "R" )) (number ( some :d )) (opt " \n " )))) ( - A Short Survey of Compiler Targets
Nov 5, 2025 · original
As an amateur compiler developer, one of the decisions I struggle with is choosing the right compiler target. Unlike the 80s when people had to target various machine architectures directly, now there are many mature options available. This is a short and very incomplete survey of some of the popular and interesting options 1 . Contents Machine Code / Assembly Intermediate Representations Other High-level Languages Virtual Machines / Bytecode WebAssembly Meta-tracing and Metacompilation Frameworks Unconventional Targets Conclusion Machine Code / Assembly # A compiler can always directly output machine code or assembly targeted for one or more architectures. A well-known example is the Tiny C Compiler . It’s known for its speed and small size, and it can compile and run C code on the fly. Another such example is Turbo Pascal . You could do this with your compiler too, but you’ll have to f - A Fast Bytecode VM for Arithmetic: The Virtual Machine
Oct 21, 2025 · original
In this series of posts, we write a fast bytecode compiler and a virtual machine for arithmetic in Haskell. We explore the following topics: Parsing arithmetic expressions to Abstract Syntax Trees (ASTs). Unit testing for our parser. Interpreting ASTs. Compiling ASTs to bytecode. Disassembling and decompiling bytecode. Unit testing for our compiler. Property-based testing for our compiler. Efficiently executing bytecode in a virtual machine (VM). Unit testing and property-based testing for our VM . Benchmarking our code to see how the different passes perform. All the while keeping an eye on performance. In this final post, we write the virtual machine that executes our bytecode, and benchmark it. This post was originally published on abhinavsarkar.net . This post is a part of the series: A Fast Bytecode VM for Arithmetic . The Parser The Compiler The Virtual Machine 👈 Contents Introduc - Customizing Miniflux: Sorting by Similarity
Sep 30, 2025 · original
As mentioned by in a previous note , I have customized Miniflux , my preferred feed reader, to add custom sorting for the articles. Recently, I added another sorting option: sorting by similarity. I kept finding myself wanting to read articles grouped by their topics, instead of hopping from topic to topic while going through my feed. So I build it. This post was originally published on abhinavsarkar.net . This post is a part of the series: Customizing Miniflux . Making a Two-Pane Reader Addding Custom Sorting Sorting by Similarity 👈 Sorting by Signal Screenshot of the Miniflux reader showing articles sorted by similarity The idea is to use the words in the article titles to find similar articles and group them together. Here is how the process works: I get article titles from the page using JavaScript DOM functions. I tokenize the article titles, remove stop words and stem the tokens ( - A Fast Bytecode VM for Arithmetic: The Compiler
Aug 24, 2025 · original
In this series of posts, we write a fast bytecode compiler and a virtual machine for arithmetic in Haskell. We explore the following topics: Parsing arithmetic expressions to Abstract Syntax Trees (ASTs). Unit testing for our parser. Interpreting ASTs. Compiling ASTs to bytecode. Disassembling and decompiling bytecode. Unit testing for our compiler. Property-based testing for our compiler. Efficiently executing bytecode in a virtual machine (VM). Unit testing and property-based testing for our VM . Benchmarking our code to see how the different passes perform. All the while keeping an eye on performance. In this post, we write the compiler for our AST to bytecode, and a decompiler for the bytecode. This post was originally published on abhinavsarkar.net . This post is a part of the series: A Fast Bytecode VM for Arithmetic . The Parser The Compiler 👈 The Virtual Machine Contents Introdu - A Fast Bytecode VM for Arithmetic: The Parser
Aug 2, 2025 · original
In this series of posts, we write a fast bytecode compiler and a virtual machine for arithmetic in Haskell. We explore the following topics: Parsing arithmetic expressions to Abstract Syntax Trees (ASTs). Unit testing for our parser. Interpreting ASTs. Compiling ASTs to bytecode. Disassembling and decompiling bytecode. Unit testing for our compiler. Property-based testing for our compiler. Efficiently executing bytecode in a virtual machine (VM). Unit testing and property-based testing for our VM . Benchmarking our code to see how the different passes perform. All the while keeping an eye on performance. In this post, we write the parser for our expression language to an AST , and an AST interpreter. This post was originally published on abhinavsarkar.net . This post is a part of the series: A Fast Bytecode VM for Arithmetic . The Parser 👈 The Compiler The Virtual Machine Contents Intro - Reading Time Estimates for Pandoc Based Blog Generators
May 13, 2025 · original
If you, like me, are one of those who have written their own static-site generators based on Pandoc using Haskell, or use a framework made on top of it 1 , this post provides a little code snippet to compute the reading time estimate for your blog posts. You can stick this in your setup at the right place, and get pretty accurate estimates 2 . This post was originally published on abhinavsarkar.net . module Pandoc.ReadingTimeEstimate (readingTimeEstimateMinutes) where import Data.Char (isAlphaNum) import Data.Monoid ( Sum (..)) import Data.Text qualified as Text import Text.HTML.TagSoup (innerText, parseTags) import Text.Pandoc.Definition readingTimeEstimateMinutes :: Pandoc - Int readingTimeEstimateMinutes = round . ( / wpm) . fromIntegral . wordCount where wpm = 220 wordCount :: Pandoc - Int wordCount ( Pandoc _ blocks) = getSum $ foldMap blockWCount blocks where blockWCount = \ case P - Running a Goaccess Server on NixOS
Apr 20, 2025 · original
Goaccess is an open source real-time web log analyzer. We can use it to parse a server access log file, such as of Nginx , and see the analysis report in a terminal in real-time. However, Goaccess also comes with an HTTP server built into it that can serve the same real-time report over HTTP ( demo ). This post was originally published on abhinavsarkar.net . So I wrote a NixOS service module for Goaccess server. { config , lib , pkgs , ... } : let serviceName = "goaccess" ; cfg = config . services . " ${ serviceName } " ; nginxCfg = config . services . nginx ; userName = cfg . userName ; types = lib . types ; in { options . services . " ${ serviceName } " = { enable = lib . mkEnableOption " ${ serviceName } service" ; package = lib . mkOption { type = types . package ; default = pkgs . goaccess ; description = "The Goaccess package." ; }; userName = lib . mkOption { type = types . nonEmp
Found by rss-feed-index, which checks each feed once a month at most.
Same record as JSON: https://api.agentalog.com/api/feeds/fd_abhinavsarkar_net_4c5b5ec6df15b23e. More from this site: abhinavsarkar.net in the Feeds tab.