Ian Henry advocates for Janet as streamlined alternative to Perl and Bash
Ian Henry’s latest article, 'Why Janet?', promotes the language for command-line applications, citing native static executables and parsing expression grammatures as key differentiators from established scripting tools.
Ian Henry has published an article titled 'Why Janet?' on his personal website, advocating for the Janet programming language as a practical tool for side projects and command-line applications. Henry, who previously released a free book on the subject titled 'Janet for Mortals', describes Janet as a small Lisp dialect designed to offer a simpler, more efficient alternative to languages such as Perl, Bash, and Lua.
The article details Janet’s compilation process, noting that the language compiles to bytecode which is then embedded into a C file and compiled using the system’s C compiler to create static executables. This approach allows developers to distribute programs without requiring users to install the Janet runtime or additional dependencies. Henry cites a specific example where a "hello world" program compiled on aarch64 macOS using Janet version 1.27.0 resulted in a binary size of 784KB, which includes the full runtime, garbage collector, and bytecode compiler.
Henry positions Janet’s text wrangling capabilities as a significant advantage over traditional regular expressions. The language utilises Parsing Expression Grammars (PEGs), which he describes as simpler, more powerful, and more predictable. Unlike line-oriented regular expressions, these grammars can parse multi-line text, HTML, JSON, and binary formats, including files with arbitrary null bytes.
To enhance its utility for shell scripting, Henry highlights a third-party library called 'sh', which provides a domain-specific language allowing pipes and redirects to be expressed directly in Janet. He argues that this feature elevates Janet from a reasonable alternative to Perl to a viable option for Bash, particularly for a wide range of programmatic tasks.
The article also outlines Janet’s implicit state serialization, a feature where top-level instructions are executed at compile time and the program’s state is saved to disk. This allows for pre-computing assets, autogenerating database bindings, and performing arbitrary side effects during the build process. Henry notes that while Janet’s macros are not hygienic, the language permits referentially transparent macros by allowing the unquoting of literal functions.
Henry concludes by addressing the language’s syntax, which uses pervasive parentheses but breaks them up with brackets and braces for lists and tables. He points out that Janet eschews many ancient Lisp customs, such as using CAR for the first element or FORMAT for string formatting, instead opting for first-class booleans and a fixed syntax that does not support reader macros.


