HN
Today

Why Janet?

A passionate advocate makes a compelling case for Janet, a small Lisp dialect, highlighting its simplicity, embeddability, and powerful metaprogramming capabilities. This post resonates on Hacker News by reigniting classic debates about Lisp's controversial syntax, the merits of PEGs over regex, and the allure of compile-time code execution. It offers a refreshing dive into alternative language design principles, sparking discussion beyond mainstream programming paradigms.

78
Score
26
Comments
#1
Highest Rank
8h
on Front Page
First Seen
Jun 2, 10:00 AM
Last Seen
Jun 2, 5:00 PM
Rank Over Time
11111545

The Lowdown

The author, a confessed 'Janetor' and author of 'Janet for Mortals,' argues for giving the Janet programming language a try. Despite its Lisp-like parenthetical syntax, Janet is presented as a surprisingly modern and versatile tool, particularly well-suited for specific development niches.

Key features highlighted include:

  • Simplicity: A minimal core language with only eight instructions, easy to learn due to JavaScript-like runtime semantics, and a standard library that fits on one page.
  • Distributability: Janet programs compile into small, self-contained native executables (under 1MB) that include the full runtime and garbage collector, making distribution straightforward.
  • Superior Parsing: It leverages Parsing Expression Grammars (PEGs) for text wrangling, described as simpler, more powerful, and more predictable than regular expressions for parsing various structured and binary formats.
  • Shell Scripting DSL: A third-party sh library provides an elegant DSL for subprocess management, making Janet a viable alternative to Bash or Perl for scripting tasks.
  • Embeddability: Designed as a small C library, Janet is exceptionally easy to embed into other applications, offering a powerful scripting interface comparable to, and arguably surpassing, Lua in certain contexts.
  • Flexible Collections: It offers both mutable and immutable collection types, providing choice in how data is managed.
  • Powerful Macros: Janet's non-hygienic macros, combined with literal function unquoting, enable sophisticated metaprogramming, allowing developers to write code that generates code.
  • Compile-time to Run-time Value Transfer: A unique feature allowing arbitrary Janet values to be serialized at compile-time and restored at runtime, facilitating asset embedding or advanced configuration.
  • Modern Syntax: While Lisp-based, Janet prioritizes comfort over tradition, adopting modern function names (first instead of CAR, fn instead of LAMBDA) and using [] for lists and {} for tables to enhance readability.

Ultimately, Janet is positioned not as a replacement for enterprise-scale languages, but as an excellent, fun, and powerful choice for exploratory programming, scripting, and side projects.

The Gossip

Parenthetical Ponderings

A significant portion of the discussion revolves around Janet's Lisp-like syntax, specifically the ubiquitous parentheses. While some commenters acknowledge its unambiguous nature and ease of parsing, many express strong aversion to its readability and editing experience, calling it 'horrible.' There's debate on whether its simplicity outweighs the perceived visual clutter, with comparisons made to traditional Lisp syntax and calls for alternative representations.

Parsing Paradigm Predicaments

The author's assertion that Parsing Expression Grammars (PEGs) are 'simpler, more powerful, and more predictable' than regular expressions for text wrangling drew immediate contention. Commenters disputed this, highlighting that PEGs' non-commutative alternatives can lead to frustrating debugging, suggesting the benefits over regex are 'overstated' and that PEGs are an 'evolutionary dead-end' compared to other grammar parsers.

Embedding Excellence

Janet's strong embeddability feature garners significant interest, with several users comparing its potential role to that of Lua. Commenters share positive experiences using Janet for creating small, fast executables for command-line tools, communicating with LLMs, and even embedding scripting into markup languages, underscoring its utility for lightweight and custom applications.

Mortal Musings on Learning

While the article praises Janet's ease of learning, some commenters found the accompanying 'Janet for Mortals' book to be less accessible than its title suggests, indicating a potential struggle for newcomers. This ties into broader observations about the abstract nature of Lisp concepts and the difficulty of explaining them to those unfamiliar with functional programming paradigms.

AI's Infiltration & Community Concerns

A tangential yet potent theme emerges concerning the impact of AI on online discussion platforms. One user expresses a desire for an AI-free community, harkening back to 'pre-AI discussions.' This sentiment is met with skepticism, as another commenter points to the challenges faced by platforms like Digg in attempting to thwart bot 'onslaughts,' highlighting the practical difficulties of excluding AI from online discourse.