PitchHut logo
Musubi
Beautiful diagnostics renderer for compiler errors and warnings.
Pitch

Musubi is a high-performance diagnostics renderer that transforms how compiler errors and warnings are displayed. With support for multiple languages, it provides color-coded messages, precise highlighting, and intelligent label clustering, enhancing the debugging experience and making it easier for developers to understand issues in their code.

Description

Musubi (結び, meaning "connection" in Japanese) is a high-performance diagnostics renderer crafted to enhance the presentation of compiler errors and warnings across multiple programming languages. Drawing inspiration from Rust's Ariadne library, Musubi elevates diagnostic messaging with beautiful color-coding, precise source location highlighting, multi-line spans, and intelligent label clustering.

Overview

Musubi stands out for its capability to produce aesthetically pleasing output while ensuring high performance:

  • C Library: Features a high-performance core complemented by Lua bindings (musubi.h, musubi.c).
  • Rust Crate: Offers a safe FFI wrapper with an ergonomic builder API (musubi-rs).

Both the C and Rust implementations provide identical rendering output and are complemented by extensive testing efforts, including 100% test coverage for robust reliability.

Key Features

  • Visually Appealing Output: Multi-line diagnostics with color-coded labels for easier interpretation, intelligent clustering of labels, and support for both Unicode and CJK characters.
  • Optimized Performance: Reduced rendering complexity from O(n²) to O(n) through techniques like pre-computed width caching for UTF-8 strings and efficient line windowing calculations.
  • Production-Ready Implementation: 100% test coverage with memory-safe implementations across Rust and C, comprehensive error handling measures, and compatibility with Lua 5.1, 5.4, and LuaJIT.

Example Usage

local mu = require "musubi"
local cg = mu.colorgen()

print(
    mu.report("Error", "Incompatible types")
    :code "3"
    :label(33, 33):message("This is of type Nat"):color(cg:next())
    :label(43, 45):message("This is of type Str"):color(cg:next())
    :label(12, 48):primary():message("These values are outputs of this match expression"):color(cg:next())
    :note "Outputs of match expressions must coerce to the same type"
    :source([[
def five = match () in {
	() => 5,
	() => "5",
}

def six = five + 1
]], "sample.tao")
    :render())

In this example, the renderer highlights the precise nature of the compiler diagnostics, providing clear visual cues that make debugging simpler and more efficient.

Conclusion

Musubi offers a compelling solution for developers seeking improved compiler diagnostics across programming languages. Through its elegant output styling and high-performance rendering capabilities, it facilitates a more intuitive debugging experience.

0 comments

No comments yet.

Sign in to be the first to comment.