whatisgithub

What is typed-sexp?

eternal-flame-ad/typed-sexp — explained in plain English

Analysis updated 2026-07-18 · repo last pushed 2024-09-16

3RustAudience · developerComplexity · 3/5StaleSetup · moderate

In one sentence

A Rust library for writing safe R language extensions by wrapping R's internal data objects in Rust's type system, catching errors before code runs without heavy frameworks or macros.

Mindmap

mindmap
  root((repo))
    What it does
      Wraps R SEXP objects
      Catches errors early
      Manages R garbage collection
    Key features
      Vector and matrix access
      Call R from Rust
      Embed R in Rust
    Use cases
      Vector addition demos
      Matrix multiplication
      Inline assembly for R
    Audience
      R internals developers
      Rust extension writers
    Design choices
      No heavy macros
      Minimal dependencies
      Close to R internals

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

What do people build with it?

USE CASE 1

Write high-performance R extensions in Rust with type safety against common memory and data-structure errors.

USE CASE 2

Embed the R statistical engine inside a Rust program to use R's analysis capabilities from Rust code.

USE CASE 3

Call R functions from Rust with properly typed arguments and safely handle R's garbage collection.

USE CASE 4

Build computational tools like vector and matrix operations that bridge R and Rust safely.

What is it built with?

RustR

How does it compare?

eternal-flame-ad/typed-sexpcodeitlikemiley/antigravity-sdk-rustdedsec-xu/needle
Stars333
LanguageRustRustRust
Last pushed2024-09-16
MaintenanceStale
Setup difficultymoderatehardmoderate
Complexity3/54/53/5
Audiencedeveloperdeveloperdeveloper

Figures from each repo's GitHub metadata at analysis time.

How do you get it running?

Difficulty · moderate Time to first run · 30min

Requires understanding of R's internal SEXP objects and a local R installation to build and link against.

So what is it?

Typed-SEXP is a Rust library that lets developers write extensions for the R programming language with better safety guarantees. R is popular for statistics and data analysis, and people often write extensions in faster languages like C++ or Rust to speed up calculations. The problem is that R's internal interface for doing this is notoriously confusing and error-prone. This library gives developers a safer way to interact with R's internal data structures without adding heavy dependencies or complex tooling. At its core, the library wraps R's internal objects, called SEXP objects, in Rust's type system so that mistakes get caught before the code runs. It handles things like safely accessing elements of vectors and matrices, managing memory so objects don't get prematurely cleaned up by R's garbage collector, and calling R functions from Rust with properly typed arguments. It also works the other direction: you can embed R inside a Rust program and use R's capabilities from pure Rust code. The library deliberately stays close to R's actual internals rather than offering a polished, high-level wrapper. The intended user is someone who already understands how R works under the hood and wants to write R extensions in Rust without pulling in large macro-based frameworks. The author specifically avoids macros because they can be hard to debug and can confuse code analysis tools. Existing alternatives like Rcpp and extendr provide more abstraction, but this project takes a minimalist approach: enough type safety to prevent common mistakes, without hiding what's really happening. The project includes a few demos showing practical use cases: vector addition, matrix multiplication, calling closures passed from R, and embedding R in a Rust program. There's also a tongue-in-cheek project called "rasm" that implements inline assembly for R, which doubles as a stress test for the library's stability. The README notes that dynamically creating R functions from Rust is a planned feature but not yet implemented.

Copy-paste prompts

Prompt 1
Help me set up a Rust project using the typed-sexp library to write an R extension that performs vector addition. Include the Cargo.toml configuration and basic function signature.
Prompt 2
Show me how to use typed-sexp to embed R inside a Rust program and call an R statistical function, handling the returned SEXP object safely.
Prompt 3
I want to write an R extension in Rust using typed-sexp that accepts an R closure, calls it from Rust, and returns the result. How do I handle the typed arguments?
Prompt 4
Compare typed-sexp's minimalist approach to extendr and Rcpp. When would I choose typed-sexp over these macro-based alternatives for my R extension?

Frequently asked questions

What is typed-sexp?

A Rust library for writing safe R language extensions by wrapping R's internal data objects in Rust's type system, catching errors before code runs without heavy frameworks or macros.

What language is typed-sexp written in?

Mainly Rust. The stack also includes Rust, R.

Is typed-sexp actively maintained?

Stale — no commits in 1-2 years (last push 2024-09-16).

How hard is typed-sexp to set up?

Setup difficulty is rated moderate, with roughly 30min to a first successful run.

Who is typed-sexp for?

Mainly developer.

Open on GitHub → Ask about another repo

This repo across BitVibe Labs

Verify against the repo before relying on details.