What Programming Languages Are Used in Automattic/Harper? A Polyglot Codebase Breakdown
Automattic/Harper uses Rust as its core engine, TypeScript/JavaScript for web front-ends and extensions, plus Python, Swift, C, C++, and Go for bindings and test fixtures.
Harper is an open-source grammar checker built as a language-server-powered linting engine. Understanding what programming languages are used in Automattic/Harper helps contributors navigate its monorepo structure and developers integrate it into their own tools.
Rust: The Core Grammar Engine
Rust powers Harper's heart: the grammar-checking engine, language server protocol (LSP) implementation, WebAssembly bindings, desktop backend, and CLI utilities.
The core library lives in harper-core/src/lib.rs. Here, the Linter struct provides the main API for analyzing text:
use harper_core::{Linter, LintConfig};
fn main() {
let config = LintConfig::new_curated();
let linter = Linter::new(config);
let text = "Their are many errors.";
let results = linter.lint(text);
for lint in results {
println!("{}: {}", lint.message, lint.range);
}
}
Key Rust components span multiple crates:
harper-core– grammar engine and rule definitionsharper-cli– command-line interfaceharper-ls– LSP server for editor integrationharper-wasm– browser-compatible WASM buildharper-python– pyo3-based Python bindings
The workspace configuration in Cargo.toml declares all crates:
[workspace]
members = [
"harper-core",
"harper-cli",
"harper-ls",
"harper-wasm",
"harper-python",
# ...
]
TypeScript and JavaScript: The Front-End Ecosystem
TypeScript dominates Harper's user-facing layers: web extensions, desktop UIs, and the official web demo. JavaScript appears in build scripts, test harnesses, and legacy modules.
The LocalLinter class in packages/harper.js/src/main.ts wraps the WASM core for browser use:
import { LocalLinter } from '@harper-linter/harper.js';
async function lintDemo() {
const linter = await LocalLinter.create(); // loads the WASM binary
const text = document.querySelector('textarea')!.value;
const diagnostics = await linter.lint(text);
console.log(diagnostics);
}
lintDemo();
TypeScript surfaces include:
- VS Code extension (
packages/vscode-plugin/src/extension.ts) - Obsidian plugin
- Chrome extension
- WordPress plugin (uses TSX for UI components)
- Web demo (
packages/web/src/routes/editor/+page.ts)
Configuration files like package.json and tailwind.config.js anchor the JavaScript tooling.
Python Bindings
Python support exists via a thin wrapper exposing Harper functionality through pyo3. The binding implementation resides in harper-python/src/lib.rs—Rust code that uses the pyo3 crate to generate Python-compatible modules.
This lets Python developers import and use Harper's linting capabilities natively:
# After installing the harper-python package
from harper import Linter
linter = Linter()
results = linter.lint("This sentence have errors.")
Test Fixture Languages
Harper includes additional programming languages used in Automattic/Harper strictly for testing comment-parsing accuracy across editors. These appear as fixture files rather than production code:
- Swift –
packages/vscode-plugin/src/tests/fixtures/languages/swift.swift - C –
harper-comments/tests/language_support_sources/ignore_comments.c - C++ –
harper-comments/tests/language_support_sources/multiline_comments.cpp - Go –
packages/vscode-plugin/src/tests/fixtures/languages/go.go
These fixtures ensure Harper correctly extracts and lints prose embedded in source code comments regardless of the host language.
Markup and Templating
UI components in the WordPress plugin and web packages use HTML, JSX, and TSX for component structure. Example: packages/wordpress-plugin/src/harper/index.tsx defines the WordPress admin interface in TypeScript with React-style JSX.
Summary
Harper's polyglot architecture separates concerns by language strength:
- Rust delivers performance-critical parsing and cross-platform compilation (native + WASM)
- TypeScript/JavaScript enables rapid UI development and deep editor ecosystem integration
- Python extends reach to data science and automation workflows
- C, C++, Swift, Go fixtures validate multi-language comment parsing
Key files to explore:
Cargo.toml– Rust workspace structurepackage.json– npm package graphharper-core/src/lib.rs– core engine entry pointpackages/vscode-plugin/src/extension.ts– TypeScript/Rust bridge example
Frequently Asked Questions
Is Harper written entirely in Rust?
No. While the grammar engine and performance-critical components are Rust, Harper uses TypeScript for all web extensions and UIs, JavaScript for build tooling, and Python for language bindings. Test fixtures include C, C++, Swift, and Go code.
Can I use Harper as a Python library?
Yes. The harper-python crate exposes Harper's Linter through pyo3. Install the built wheel, then import from harper import Linter in your Python scripts.
Why does Harper include Swift, C, and Go files?
These are test fixtures in packages/vscode-plugin/src/tests/fixtures/ and harper-comments/tests/. They verify that Harper's comment parser correctly handles documentation strings and inline comments across many source languages.
What is the relationship between the Rust core and TypeScript extensions?
The Rust core compiles to WebAssembly for browser contexts and native binaries for desktop. TypeScript extensions load this WASM module or communicate via the language server protocol, providing UI layers without duplicating grammar logic.
Have a question about this repo?
These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:
curl -s "https://instagit.com/install.md" Maintain an open-source project? Get it listed too →