Daslang Documentation

repository·master·Indexed 22 days ago

https://github.com/gaijinentertainment/dascript

A high-performance, statically typed programming language designed for games and real-time applications. Daslang features a data layout matching C++ to eliminate interop overhead and supports multiple execution tiers, including Interpreter, AOT (to C++), and JIT (via LLVM). The repository includes a tree-sitter-daslang grammar (v0.1.0) and performance benchmarks for core subsystems such as hash maps and job queue dispatching.

Tokens
367.2K
Snippets
922
Records
1.5K
Agent score
78%

What's inside Daslang

  1. Overview of detect-dupe

    master

    The detect-dupe utility is a cross-file similar-function detector for .das files. It walks a directory tree, normalizes user functions into an alpha-renamed token stream (collapsing identifiers, types, and literals), and identifies two types of duplicates:

    1. Exact-clone clusters: Functions that hash to the same canonical text (pure structural duplicates).
    2. Fuzzy near-duplicates: Pairs scored using a MinHash signature and a Jaccard similarity estimate, subject to a length ratio threshold to prevent false positives from periodic boilerplate.

    It is useful for finding test-suite boilerplate, near-clones that have drifted, or copy-pasted helpers.

  2. Overview of daslang MCP Server

    master
    The daslang MCP (Model Context Protocol) server provides AI coding assistants (like Claude Code) with a suite of tools to interact with the daslang compiler and C++ source code. It enables tasks such as compilation diagnostics, program introspection, AOT (Ahead-of-Time) code generation, C++ source intelligence, and live-reload control for running daslang programs.
  3. Overview of Performance Lint Rules

    master

    The perf_lint module (located in daslib/perf_lint.das) is a compile-time tool that detects common performance anti-patterns in daslang code. It operates as a [lint_macro] AST pass that walks the compiled program. When a slow pattern is detected, it reports a warning using error code 31208 (CompilationError::runtime_macro_performance).

    Key components:

    • Module: daslib/perf_lint.das (module perf_lint shared private)
    • Entry point: [lint_macro] class PerfLintMacro : AstPassMacro
    • Visitor: class PerfLintVisitor : AstVisitor (tracks loop depth and variable scopes)
    • Unified Linting: utils/lint/main.das provides a single interface to run paranoid, performance, and style linting passes.
  4. Overview of {fmt} library motivation and alternatives

    master

    The {fmt} library is a modern C++ formatting library designed to address the limitations of existing formatting methods. It aims to provide a solution that is faster than Boost Format, safer and more concise than iostreams (avoiding "chevron hell"), and more feature-complete than FastFormat (supporting leading zeros, octal/hexadecimal encoding, and runtime width/alignment specification).

    Key comparisons:

    • printf: Fast and available, but lacks support for user-defined types and has safety concerns.
    • iostreams: Supports user-defined types and is safe, but suffers from verbose syntax and lacks positional arguments.
    • Boost Format: Powerful and supports positional arguments, but suffers from poor performance, high build times, and code bloat.
    • FastFormat: Fast and safe, but lacks leading zeros, octal/hexadecimal encoding, and runtime width/alignment specification.
  5. Overview of Daslang Benchmarks

    master
    The benchmarks/ directory contains a comprehensive suite of .das benchmark files used to measure the performance of various Daslang subsystems. These benchmarks are categorized by functional area, such as core data structures (hash maps, arrays, tables), runtime components (GC, job queues), and specialized modules (audio, math, fusion). They are designed to compare performance across different execution modes, including the Interpreter and the JIT (Just-In-Time) compiler.
  6. What is Daslang?

    master

    Daslang is a high-performance, strongly and statically typed scripting language designed for real-time applications like games. It is intended to be used as an embeddable "host data processor," where the script transforms host (C++) data or implements scripted behaviors.

    Key characteristics include:

    • Performance: High-speed interpretation and extremely fast two-way interop with C++.
    • Memory Model: Designed to be pure functional in nature; persistent state is typically managed by the host application, leading to a simple and fast memory model within Daslang.
    • Compilation: Supports Ahead-of-Time (AoT) compilation to C++, providing performance similar to C++11.
  7. Overview of the vecmath SIMD HAL library

    master

    vecmath is a header-only Hardware Abstraction Layer (HAL) for SIMD intrinsics. It provides a unified interface for vector and matrix mathematics across different SIMD architectures.

    Supported Architectures:

    • SSE (x86)
    • NEON (ARM)

    Supported Platforms:

    • PC, Linux, MacOS, iOS, tvOS, Shield, NSwitch, PlayStation 4, Xbox One.

    Compiler Support:

    • GCC (various versions)
    • Clang 3.9+
    • Visual Studio 2015, 2017, 2019, 2022

    Requirements:

    • Requires C++11 or later (uses alignas for memory alignment).
    • Minimum instruction set requirement: SSE2.
  8. Overview of benchctl

    master

    benchctl is a command-line tool for storing, querying, and comparing daslang benchmark results across different commits or tags. It uses a local SQLite database to persist benchmark data and provides statistical comparisons between two sets of results (e.g., comparing an old algorithm against a new one).

    Key features include:

    • Inserting benchmark JSON output from dastest into a persistent database.
    • Querying results using commit hashes or custom tags.
    • Computing geometric mean deltas and statistical significance (using Welch's t-test) between result sets.
    • Integration with dastest via the --bench-format json flag.
  9. Overview of dasLLAMA harness tools

    master

    The dasLLAMA harness provides verification, evaluation test beds, and GGUF inspection tools. These tools are not shipped with the main module but are available for testing correctness and inspecting model files.

    Available Tools

    FilePurpose
    parity.dasPerforms the dasLLAMA side of the token-for-token oracle check. It takes prompt IDs and outputs greedy generated IDs (GEN_IDS: ...). It is architecture-agnostic via load_gguf and generate.
    parity.shA shell script that runs both the reference oracle and parity.das on the same prompt and compares the resulting ID streams.
    oracle/simple_ids.cppThe reference oracle. A trimmed version of llama.cpp's examples/simple that prints greedy token IDs (CPU, no EOG break) instead of text.
    quant_eval.das / quant_eval_q4.dasCalculates reconstruction-error statistics for Q8 or Q4 weights against fp32 weights.
    bpe_test.dasValidates the BPE tokenizer corpus against the ggml-vocab-llama-bpe fixtures.
    gguf_dump.dasDumps GGUF metadata and the tensor table.
    mem.dasMeasures the resident memory footprint of a loaded model, broken down by region.