<!doctype html>
<html lang="en" data-theme="auto">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>slang — slang</title>
<meta name="description" content="A statically typed language built primarily for server-side and network programming. Compiles to C.">
<meta name="author" content="Dolphlabs (Dolph Tech Limited)">
<link rel="author" href="https://dolphlabs.com">
<meta property="og:site_name" content="slang — by Dolphlabs">
<meta property="og:title" content="slang">
<meta property="og:description" content="A statically typed language built primarily for server-side and network programming. Compiles to C.">
<meta property="og:type" content="website">
<!-- Agents: every page here has a Markdown twin at the same path, and
     the whole site is one document at /llms-full.txt -->
<link rel="alternate" type="text/markdown" href="./index.md" title="Markdown">
<link rel="alternate" type="text/plain" href="./llms-full.txt"
      title="Entire site as plain text">
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Archivo:wght@600;700;800&family=IBM+Plex+Mono:ital,wght@0,400;0,600;1,400&family=IBM+Plex+Sans:wght@400;500;600&display=swap">
<link rel="stylesheet" href="./style.css">
<link rel="icon" href="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 64 64'><text y='52' font-size='52'>◆</text></svg>">

</head>
<body>
<a class="skip" href="#main">Skip to content</a>

<header class="topbar">
  <a class="brand" href="./index.html">
    <span class="mark" aria-hidden="true"></span> slang
  </a>
  <nav class="mainnav"><a class="active" href="./index.html">Home</a><a href="./guide/index.html">Guide</a><a href="./guide/data.html">Data types</a><a href="./guide/errors.html">Errors</a><a href="./guide/functions.html">Functions</a><a href="./concurrency/index.html">Concurrency</a><a href="./packages/index.html">Packages</a><a href="./interop/index.html">C interop</a><a href="./internals/index.html">Internals</a><a href="./limitations/index.html">Limitations</a></nav>
  <div class="tools">
    <input id="search" type="search" placeholder="Search docs…"
           autocomplete="off" aria-label="Search documentation">
    <button id="theme" type="button" aria-label="Toggle theme">◐</button>
  </div>
</header>
<div id="results" class="results" hidden></div>

<main id="main">

<div class="hero">
  <div class="hero-copy">
    <p class="eyebrow">A <a href="https://dolphlabs.com"
       rel="noopener">Dolphlabs</a> project</p>
    <h1>slang</h1>
    <p class="lede">A statically typed language built <strong>primarily
      for server-side and network programming</strong> &mdash; that is
      where it is aimed, not where it stops. It compiles to C, schedules
      <strong>M:N green threads</strong>, collects with a precise
      mark-sweep GC, and ships its standard library inside the
      compiler.</p>
    <div class="cta">
      <a class="btn primary" href="./guide/">Read the guide</a>
      <a class="btn" href="./packages/">Browse packages</a>
      <a class="btn ghost" href="./llms.txt">llms.txt</a>
    </div>
  </div>
  <div class="hero-demo">
    <div class="demo-head">
      <span class="dot r"></span><span class="dot y"></span>
      <span class="dot g"></span>
      <span class="demo-title">six 300ms requests, one connection</span>
    </div>
    <div class="lanes" id="lanes"></div>
    <div class="demo-foot">
      <button class="btn small" id="run-demo" type="button">Run</button>
      <span class="readout" id="readout">idle</span>
    </div>
  </div>
</div>

<div class="page">
  <article class="content">
    <header class="page-head">
      <h1>slang</h1>
      <p class="tagline">A statically typed language built primarily for server-side and network programming. Compiles to C.</p>
      <p class="agentline">
        <a href="./index.md">Markdown version</a> ·
        <a href="./llms.txt">llms.txt</a> ·
        <a href="./api.json">api.json</a>
      </p>
    </header>

<section class="features">
  <article>
    <h3>Concurrency that is actually concurrent</h3>
    <p><code>spawn</code> submits a green task onto striped, work-stealing
      run queues. Channels, <code>select</code> and <code>mutex</code> park
      the <em>task</em>, never the OS thread, so a blocked handler costs a
      queue slot rather than one of the pool's threads.</p>
  </article>
  <article>
    <h3>Errors you cannot quietly drop</h3>
    <p><code>opt[T]</code> for absent data, <code>result[T, E]</code> for
      bad data, <code>fault</code> for a bad world. <code>guard let x = r
      else let e = err_of(r)</code> binds the error so it can be logged
      rather than thrown away.</p>
  </article>
  <article>
    <h3>C is the runtime, not a foreign country</h3>
    <p>slang emits C and shells out to <code>cc</code>. Calling a C library
      is <code>extern fn</code> plus a linker flag &mdash; no bindings
      generator, no FFI marshalling layer, no second build system.</p>
  </article>
  <article>
    <h3>Built for agents to read</h3>
    <p>Every page here has a Markdown twin at the same URL, the whole site
      is one file at <code>/llms-full.txt</code>, and every package and
      function is indexed in <code>/api.json</code>.</p>
  </article>
</section>

<h2 id="quick-start">Quick start</h2>
<div class="code"><button class="copy" type="button" aria-label="Copy code">Copy</button><pre><code>make                 # build the slangc compiler
make test            # compile &amp; run the example programs</code></pre></div>
<p>Compile a slang program:</p>
<div class="code"><button class="copy" type="button" aria-label="Copy code">Copy</button><pre><code>./slangc examples/hello/main.sl     # produces ./main
./main                              # run it</code></pre></div>
<p>Useful flags:</p>
<div class="tablewrap"><table><thead><tr><th>Flag</th><th>Effect</th></tr></thead><tbody><tr><td><code>-o &lt;name&gt;</code></td><td>Choose the output binary name</td></tr><tr><td><code>--emit-c</code></td><td>Only write the generated C file (no compilation)</td></tr><tr><td><code>--keep-c</code></td><td>Keep the generated C file after compiling</td></tr><tr><td><code>--run</code></td><td>Compile, then immediately execute the result</td></tr><tr><td><code>get</code></td><td>Fetch <code>slang.project</code> pins and write <code>slang.lock</code></td></tr></tbody></table></div>
<p>Want to see everything at once instead of one feature at a time? See <strong><a href="demo/"><code>demo/</code></a></strong> — a full server (dice game, guestbook wall, live dashboard) exercising every tier: <code>http</code>/<code>link</code>, <code>net.tls_*</code>, <code>json</code>, <code>spawn</code>/<code>chan[T]</code>, <code>proc</code> graceful shutdown, local package imports, and C interop, with a real HTML/CSS/JS frontend. <code>cd demo &amp;&amp; ./run.sh</code>.</p>
  </article>
  <aside class="toc">
    <p class="toc-title">On this page</p>
    <nav id="toc"></nav>
  </aside>
</div>
</main>

<footer class="foot">
  <div class="foot-main">
    <p class="foot-by">
      Built and maintained by
      <a class="org" href="https://dolphlabs.com" rel="noopener">Dolphlabs</a>
    </p>
    <p class="foot-entity">
      Dolph Tech Limited &middot;
      <a href="https://dolphlabs.com" rel="noopener">dolphlabs.com</a>
    </p>
  </div>
  <p class="foot-note">Generated from the repository by
     <code>www/build.py</code> — the guide comes from
     <code>README.md</code>, the API from the compiler's own signature
     tables and the <code>pub</code> declarations in
     <code>stdlib/</code>. Nothing here is written twice.</p>
</footer>

<script src="./app.js" defer></script>
</body>
</html>
