Squiggle Programming Language
repository·main·Indexed 42 days ago
https://github.com/quantified-uncertainty/squiggleA JavaScript-based programming language designed for probabilistic estimation, featuring tools for parsing expressions, describing distributions, and visualizing results through React components. The ecosystem includes Squiggle Hub for workflow management, a dedicated website, and utilities for probabilistic modeling and evaluation.
What's inside Squiggle
- Squiggle provides a library of React components designed to integrate Squiggle functionality into any application. These components allow you to embed code editors, playgrounds, charts, and viewers for Squiggle code and its resulting values.
Overview of the Squiggle AI frontend app
mainThe frontend application located inapps/hub/src/app/aiis designed to manage and interact with@quri/squiggle-aiworkflows. It provides a user interface for triggering and monitoring AI-driven processes within the Squiggle ecosystem.Overview of @quri/content package
mainThe
@quri/contentpackage is an internal utility used for maintaining Content Collections. It serves as a centralized hub for managing structured content used across the Squiggle ecosystem, including documentation for the website and raw data for AI system prompts.This package re-exports all generated content collections and provides helper functions for interacting with them.
Explore Squiggle models and writeups
mainYou can find Squiggle models and related analytical writeups in several locations across the ecosystem:
- Squiggle Hub: The primary application for hosting and interacting with models (squigglehub.org).
- Effective Altruism Forum: Search for the
Squiggletag to find models and discussions. - Squiggle Models Repository: A dedicated list of QURI Squiggle models can be found in the squiggle-models repository.
⚠️ Project shut down: Metaforecast status
mainMetaforecast was discontinued on July 9, 2026. The website and the public GraphQL API are no longer available. A full archive of the database was preserved; contact QURI if you need access to the data.Understand the structure of the hub/src/lib directory
mainThe
apps/hub/src/libdirectory contains shared logic for the Squiggle Hub application. It is organized by the intended runtime environment and usage pattern:lib/server: Contains code that must only run on the server (e.g., database access, sensitive logic).lib/hooks: Contains common React hooks intended for use in client-side components.- Other files: General shared logic that can be used in both server and client contexts.
Current limitations and stability of Squiggle
mainSquiggle is currently in an early stage of development and is considered suitable for small projects. Users should be aware that there are likely to be mathematical bugs and performance issues. The project's primary goal is to reach version 1.0 stability.Use the Plot module to create distribution and function plots
mainThe
Plotmodule provides functions for visualizing distributions and mathematical functions.There are two ways to generate plots:
- Direct Plotting: Using raw functions and distributions, which are plotted using default parameters.
- Plot Objects: Using specific functions from this module that return plot objects. These objects provide granular control over chart parameters and allow for the creation of more complex chart types.
Experimental Danger modules overview
mainThe
Dangerlibrary provides experimental modules that are less stable than the core Squiggle library. These modules are intended for testing new ideas rather than production environments. The available modules include:- Javascript: Provides near 1-to-1 matches of Javascript functions.
- Math: Mathematical functions.
- Combinatorics: Combinatorial functions.
- Distributions: Statistical distribution functions.
- Integration: Integration functions.
- Optimization: Optimization functions.
- JSON: JSON-like object serialization (
Danger.jsonandDanger.jsonString).
Metaforecast GraphQL Tech Stack and Code Layout
mainThe Metaforecast website uses a specific stack for GraphQL implementation:
- Backend: Pothos for the GraphQL server.
- Frontend: urql for client-side queries.
- Code Generation: GraphQL Code Generator for schema and query generation.
Key Files:
schema.graphql: The generated GraphQL schema.codegen.yml: Configuration forgraphql-code-generator.graphql.config.yaml: GraphQL Config for VS Code integration (enables type-checking in.graphqlfiles).src/pages/api/graphql.ts: The GraphQL HTTP endpoint and playground.src/web/urql.ts: Helper functions forurql.src/graphql/: Contains the GraphQL server implementation.src/web/**/*.graphql: Contains fragments, queries, and mutations used on the frontend.
What is Squiggle?
mainSquiggle is a minimalist programming language designed for intuitively-driven quantitative estimation. It allows users to perform math with probability distributions and encode functions as forecasts.
Key Characteristics:
- Purpose: Intuitively-driven estimation rather than data analysis or data-driven statistical techniques.
- Embeddability: It is an embeddable language that can be integrated into JavaScript applications.
- Not a Probabilistic Programming Language: Unlike standard probabilistic programming languages, Squiggle does not support Bayesian inference (backwards inference).
- Not for Data Analysis: It is not intended to replace tools like Python or Julia for substantial data analysis, nor is it a replacement for enterprise Risk Analysis tools (e.g., Crystal Ball, @Risk).
Handle 'a to b' expressions in @quri/squiggle-lang
mainStarting with
@quri/squiggle-langv0.8.0, the expressiona to balways evaluates to a lognormal distribution. Note that the arguments must be positive-only. Previous versions allowed these to fall back to normal distributions for values zero or less, but this behavior has changed.// Evaluates to a lognormal distribution 5 to 10