Sula: A Deep Dive into the Gemini Protocol Server Written in Scryer Prolog

Sula combines Gemini protocol minimalism with Scryer Prolog's logic programming to build a unique network server.
Sula is an open source Gemini protocol server written in Scryer Prolog that combines two niche technologies in a fascinating engineering experiment. The article explores Gemini's minimalist design philosophy as an alternative to the bloated modern web, Scryer Prolog's Rust-based WAM implementation and ISO compliance, and how DCG grammars make protocol parsing elegantly declarative. The project proves logic programming can handle real-world network I/O and TLS.
Sula: A Maverick Open Source Project
In an era where mainstream web development frameworks are dominated by JavaScript, Go, and Rust, an open source project called Sula has chosen a radically different technical path — it's a Gemini protocol server written in Scryer Prolog. While the project didn't generate enormous buzz on Hacker News (14 points), the technical philosophy and engineering practices it represents are well worth savoring for any developer interested in niche protocols and logic programming.
What makes Sula unique is that it bets on two "non-mainstream" technologies simultaneously: Gemini as the transport protocol, and Scryer Prolog as the implementation language. Together, they form a fascinating experiment in "simplicity" and "declarative programming."

What Is the Gemini Protocol: A Response to the Bloated Web
Gemini is a lightweight network protocol that sits between Gopher and HTTP, born from a growing dissatisfaction with the modern web's bloat. It was initiated in 2019 by a developer using the pseudonym Solderpunk, with initial discussions taking place on a Gopher mailing list. The Gopher protocol was created at the University of Minnesota in 1991 — predating the widespread adoption of the World Wide Web — and organized information as plain-text menus, serving as one of the primary means of internet information retrieval in the early 1990s. Gemini's designers believed that Gopher was too spartan (no encryption, limited formatting), while modern HTTP had swung to the other extreme — excessive complexity. Gemini attempts to find the "just right" balance between the two.
Today's HTTP/HTTPS ecosystem carries enormous historical baggage: complex cookie tracking, ubiquitous JavaScript, deeply nested CSS, and various advertising and privacy-invasion mechanisms. The specification documents for HTTP/2 and HTTP/3 run to hundreds of pages each, and a complete implementation must handle dozens of header fields, multiple authentication mechanisms, content negotiation, cache control, and other complex logic.
Gemini takes the opposite approach, advocating radical simplicity:
- Mandatory TLS encryption: All connections use TLS by default (running on default port 1965 — the year of humanity's first spacewalk), ensuring transport security. Gemini also supports TOFU (Trust On First Use), a trust model similar to SSH key authentication, where users can use client certificates instead of traditional username/password authentication.
- Minimalist request-response model: The client sends a URL (no more than 1024 bytes), and the server returns a two-digit status code, a META field, and the content body — no complex header fields. The entire protocol specification is under 4,000 words; you can read it in an afternoon and start implementing.
- Gemtext markup language: A text format even more restrained than Markdown, supporting only three levels of headings (
#,##,###), links (lines beginning with=>), unordered lists (lines beginning with*), quotes (lines beginning with>), and preformatted text blocks (wrapped in triple backticks). It deliberately omits inline formatting (bold, italic) and inline links, ensuring that a document's logical structure is determined entirely by lines — making parsers extremely simple to implement.
This design philosophy has attracted a community of developers and content creators who value "small and beautiful" and want to return to a text-centric, tracking-free, distraction-free web space. The Gemini ecosystem now boasts dozens of server and client implementations: on the server side, there's Molly Brown (Go), Gemserv and Agate (Rust), Jetforce (Python), and more; on the client side, there's the cross-platform GUI client Lagrange (C, beautifully designed), terminal-based Amfora (Go), and Bombadillo, among others. According to community statistics, Geminispace already has thousands of active "capsules" (analogous to websites), covering personal blogs, technical documentation, literature, and more. Writing a server for Gemini is itself an endorsement of this philosophy.
Why Choose Scryer Prolog to Build a Server
If Gemini is a "non-mainstream protocol," then Scryer Prolog is a poster child for "non-mainstream languages." Prolog, as the classic language of logic programming, operates on a fundamentally different paradigm from imperative programming — rather than telling the computer "how to do" something, you describe "facts" and "rules" and let the inference engine find solutions automatically.
Prolog's history traces back to 1972, created by Alain Colmerauer and logician Philippe Roussel at the University of Marseille, with its theoretical foundations drawn from Robert Kowalski's research at the University of Edinburgh — using first-order predicate logic as a programming language. The name Prolog comes from the French "PROgrammation en LOGique" (logic programming). During AI's early golden age (1970s–1980s), Prolog was one of the most important programming languages in the field, widely used for expert systems, natural language processing, and theorem proving. In 1982, Japan's Ministry of International Trade and Industry launched the ambitious "Fifth Generation Computer" project, choosing Prolog as its core programming language with the goal of building intelligent computers capable of knowledge-based reasoning. Although the project didn't fully achieve its objectives, it greatly advanced logic programming research.
Prolog programs consist of three core elements: Facts (e.g., parent(tom, bob). stating that tom is bob's parent), Rules (e.g., grandparent(X, Z) :- parent(X, Y), parent(Y, Z). defining the grandparent relationship), and Queries (e.g., ?- grandparent(tom, Who). asking who tom's grandchildren are). Prolog's execution engine works through two core mechanisms: Unification — matching variables with concrete values through pattern matching; and Backtracking — automatically retreating to try other possibilities when a reasoning path fails. This mechanism makes Prolog naturally adept at search, constraint satisfaction, and parsing structured data.
Scryer Prolog's Modern Features
Scryer Prolog is a modern Prolog implementation written in Rust, primarily developed by Mark Thom. It strives to strictly comply with the ISO Prolog standard (ISO/IEC 13211-1:1995) while providing good performance and a modern toolchain.
Scryer's underlying implementation is based on the WAM (Warren Abstract Machine), an execution model for Prolog proposed by David H.D. Warren in 1983. Nearly all efficient Prolog implementations are built on WAM. The WAM defines a specialized set of registers, data areas, and instruction sets for efficiently executing unification, backtracking, and environment management. Scryer reimplements this abstract machine in Rust, gaining both Rust's memory safety guarantees and excellent runtime performance while maintaining strict adherence to the ISO standard.
Compared to the venerable SWI-Prolog (developed by Jan Wielemaker since 1987 and still the most popular Prolog implementation today), Scryer has a distinctly different design philosophy. SWI-Prolog takes a pragmatic approach, offering numerous non-standard extensions, a rich library ecosystem (including HTTP servers, Semantic Web tools, etc.), and a mature development environment, but its codebase is large (primarily written in C) and some behaviors deviate from the ISO standard. Scryer chose a "correctness first" approach: it rejects non-standard shortcuts and insists on strict ISO definitions for arithmetic, exception handling, and the module system. This means Scryer's library ecosystem is far less rich than SWI-Prolog's, but it provides a reliable foundation for developers who care about precise language semantics. In recent years, the Scryer community has been actively expanding its standard library, adding HTTP/TLS support, cryptographic primitives, and filesystem operations.
Writing a network server in Prolog might sound counterintuitive, since handling sockets, TLS handshakes, and byte stream parsing are typically considered strengths of imperative languages. However, Prolog's pattern matching and declarative rules can demonstrate unique expressiveness when processing "structured input" like protocol parsing. A protocol's syntactic rules can be elegantly described as a set of Prolog clauses.
Particularly noteworthy is Prolog's DCG (Definite Clause Grammars) mechanism. DCG is Prolog's built-in grammar analysis tool, allowing developers to describe data formats using declarative syntax close to BNF (Backus-Naur Form), which the Prolog compiler automatically transforms into efficient parsing code. For example, the Gemini request format gemini://host/path\r\n can be very naturally expressed as a series of grammar rules in DCG, with each rule corresponding to a component of the protocol format. By contrast, imperative languages typically require manually writing state machines or using regular expressions to accomplish the same parsing task — code that's often longer and harder to verify for correctness. DCG's declarative nature makes the correspondence between protocol specification and implementation code immediately apparent, greatly reducing the risk of introducing parsing errors.
A Proof of Engineering Feasibility
The value of a project like Sula lies not entirely in being "practical" — it's more about "proving it's possible." It demonstrates to the community that Scryer Prolog has matured enough to handle real-world network I/O, TLS encryption, and protocol implementation. This is a milestone for the logic programming community — for a long time, Prolog was considered suitable only for prototyping, academic research, and specific domains (such as compiler construction and constraint solving), but not for building system-level applications that need to interact with the operating system at a low level. Sula's existence directly refutes this stereotype.
For logic programming enthusiasts, it serves as a valuable reference implementation, demonstrating how to organize a complete server-side application in Prolog — how to manage concurrent connections, handle filesystem access, integrate TLS libraries, and elegantly combine these "impure" side-effecting operations with Prolog's core strength of pure logical reasoning.
The Technical Value of Combining a Niche Protocol with a Niche Language
One might ask: what's the point of a protocol almost nobody uses paired with a language almost nobody uses?
In fact, projects like this are precisely a sign of a healthy open source ecosystem. They don't chase commercial trends but are driven purely by technical curiosity and a spirit of exploration. This "non-utilitarian" practice often delivers value in several ways:
- Expanding a language's application boundaries: Proving that Scryer Prolog can do more than academic demonstrations — it can build real, running network services. Every such project accumulates practical experience for the Prolog community, discovers and fixes deficiencies in the runtime system, and drives the language implementation toward maturity.
- Enriching the Gemini ecosystem: Adding an entirely new server implementation option to this niche protocol enhances ecosystem diversity. Diverse implementations help reveal ambiguities and gaps in a protocol specification — when implementers working in different languages and different programming paradigms independently interpret the same specification, they often expose areas where the specification is unclear in edge cases, which in turn drives the protocol's refinement.
- Educational and inspirational value: Providing a real, complete code example for those who want to learn Prolog or understand declarative programming. Unlike the family relationship inference or eight queens problems typically found in textbooks, a network server involves I/O, error handling, configuration management, and other real-world complexities — making it a far more compelling teaching case.
- Cross-pollination effects: The intersection of different technology communities often produces unexpected innovation. Developers in the Gemini community might be introduced to logic programming thinking, while developers in the Prolog community might discover the beauty of minimalist protocol design. This cross-community knowledge flow is one of the most precious products of the open source movement.
Conclusion: Why Technical Diversity Matters
Sula may never become mainstream; its user base might always be limited to a small group of Gemini enthusiasts and Prolog geeks. But it's precisely these "non-mainstream" explorers who keep the software world intellectually diverse and innovative.
From biology, we know that species diversity is the foundation of ecosystem resilience. The evolution of software technology follows similar patterns — today's niche experiment may provide inspiration for tomorrow's mainstream paradigm. Erlang was once a niche language in the telecommunications industry; today its Actor model has influenced countless concurrent programming frameworks. Lisp's S-expressions and macro system continue to influence new language design decades after their creation. We cannot predict which "non-mainstream" idea will become crucial at some future moment.
In an era dominated by a handful of technology stacks, Sula reminds us that the choices available in programming languages and network protocols are far richer than we might imagine, and that "simplicity" and "declarative" — two values overlooked by the mainstream — still possess remarkable vitality. For developers willing to step outside their comfort zones and explore the boundaries of technology, projects like this are worth reading, studying, and even contributing to.
Related articles

EU AI Content Labeling Icons Explained: Unified Marking Scheme and Compliance Essentials
The European Commission has released unified AI-generated content labeling icons. This article explains the design philosophy, legal basis, and compliance implications under the EU AI Act.

Qwen3 Max Tops the Agentic Index Leaderboard: A Deep Dive into Agent Capability Evaluation
Qwen3 Max tops the Agentic Index leaderboard, excelling in tool use, multi-step reasoning, and code execution. A deep analysis of evaluation results and model selection in the agent era.

xAI Ignores Environmental Regulations: The Compliance Dilemma and Double Standards of an AI Giant
xAI faces controversy over alleged Clean Air Act violations at its Tennessee data center. An analysis of compliance issues, Hacker News debates, and AI governance challenges.