| 1 | <!doctype html> |
| 2 | <html lang="en"> |
| 3 | <head> |
| 4 | <meta charset="utf-8"> |
| 5 | <meta name="viewport" content="width=device-width, initial-scale=1"> |
| 6 | <title>raz: a small systems language</title> |
| 7 | <meta name="description" content="raz: a small systems language in Wirth's tradition, for x86-64 Linux."> |
| 8 | <meta name="theme-color" content="#E07A5F"> |
| 9 | <meta property="og:title" content="raz: a small systems language"> |
| 10 | <meta property="og:description" content="A small systems language for x86-64 Linux. No run time, no GC, one report."> |
| 11 | <meta property="og:image" content="https://raz.lucela.org/social.png"> |
| 12 | <meta name="twitter:card" content="summary_large_image"> |
| 13 | <link rel="icon" href="favicon.svg" type="image/svg+xml"> |
| 14 | <link rel="icon" href="favicon-32.png" type="image/png" sizes="32x32"> |
| 15 | <link rel="apple-touch-icon" href="apple-touch-icon.png"> |
| 16 | <link rel="stylesheet" href="style.css"> |
| 17 | </head> |
| 18 | <body> |
| 19 | <header><nav><a class="mark" href="index.html"><img src="logo.svg" width="26" height="26" alt="">raz</a><a href="tour/index.html">Raz, Set, Go</a><a href="advanced/index.html">More Raz</a><a href="spec.html">Report</a><a href="source/index.html">Source</a><a href="index.html#download">Download</a></nav></header> |
| 20 | <main> |
| 21 | <section class="hero"> |
| 22 | <h1>raz</h1> |
| 23 | <p class="tag">A small systems language in Wirth’s tradition, for x86-64 Linux. |
| 24 | <em>Raz</em> is Polish for <em>one</em>, as in counting.</p> |
| 25 | <div class="cta"> |
| 26 | <a class="btn primary" href="tour/index.html">Take the tour: Raz, Set, Go</a> |
| 27 | <a class="btn" href="advanced/index.html">More Raz</a> |
| 28 | <a class="btn" href="#download">Download</a> |
| 29 | <a class="btn" href="spec.html">Read the report</a> |
| 30 | <a class="btn" href="source/index.html">Browse the source</a> |
| 31 | </div> |
| 32 | </section> |
| 33 | |
| 34 | <p>A raz program can lay a record over a device’s registers, read and |
| 35 | write memory exactly as written, take part in lock-free algorithms, make |
| 36 | system calls and call C libraries. It has no garbage collector and no hidden |
| 37 | run time: what the program does is what its text says.</p> |
| 38 | |
| 39 | <p>The compiler is written in raz, about 10,700 lines, and builds itself. It makes |
| 40 | x86-64 machine code and the ELF file itself, with no assembler or linker, in |
| 41 | one pass, at about 500,000 lines a second.</p> |
| 42 | |
| 43 | <div class="facts"> |
| 44 | <span><b>~10,700</b> lines of compiler</span> |
| 45 | <span><b>~500K</b> lines compiled a second</span> |
| 46 | <span><b>1</b> report, <b>36</b> pages</span> |
| 47 | <span><b>static</b> executables, no run time to install</span> |
| 48 | </div> |
| 49 | |
| 50 | <div class="cols"> |
| 51 | <div> |
| 52 | <h2>A taste</h2> |
| 53 | <div class="file"><span>Taste.raz</span></div> |
| 54 | <pre class="code"><code><span class="comment">(* Several results, slices, and checks that say what failed. *)</span> |
| 55 | <span class="kw">module</span> Taste; |
| 56 | <span class="kw">import</span> Out; |
| 57 | |
| 58 | <span class="kw">proc</span> divmod(a, b: <span class="ty">INT</span>): (<span class="ty">INT</span>, <span class="ty">INT</span>); |
| 59 | <span class="kw">begin</span> |
| 60 | <span class="kw">return</span> a <span class="kw">div</span> b, a <span class="kw">mod</span> b; |
| 61 | <span class="kw">end</span>; |
| 62 | |
| 63 | <span class="kw">proc</span> sum(s: []<span class="ty">INT</span>): <span class="ty">INT</span>; |
| 64 | <span class="kw">var</span> i, t: <span class="ty">INT</span>; |
| 65 | <span class="kw">begin</span> |
| 66 | <span class="kw">for</span> i := <span class="number">0</span> <span class="kw">to</span> <span class="ty">LEN</span>(s) - <span class="number">1</span> <span class="kw">do</span> t := t + s[i]; <span class="kw">end</span>; |
| 67 | <span class="kw">return</span> t; |
| 68 | <span class="kw">end</span>; |
| 69 | |
| 70 | <span class="kw">proc</span> main*; |
| 71 | <span class="kw">var</span> q, r: <span class="ty">INT</span>; a: [<span class="number">5</span>]<span class="ty">INT</span>; i: <span class="ty">INT</span>; |
| 72 | <span class="kw">begin</span> |
| 73 | <span class="kw">for</span> i := <span class="number">0</span> <span class="kw">to</span> <span class="number">4</span> <span class="kw">do</span> a[i] := i * i; <span class="kw">end</span>; |
| 74 | q, r := divmod(sum(a), <span class="number">7</span>); |
| 75 | Out.int(q); Out.str(<span class="string">" remainder "</span>); Out.int(r); Out.ln; |
| 76 | Out.int(sum(a[<span class="number">1</span>..<span class="number">3</span>])); Out.ln; |
| 77 | <span class="kw">end</span>; |
| 78 | |
| 79 | <span class="kw">end</span> Taste.</code></pre> |
| 80 | <pre class="output"><code>4 remainder 2 |
| 81 | 5</code></pre> |
| 82 | </div> |
| 83 | <div> |
| 84 | <h2>What it has</h2> |
| 85 | <ul class="features"> |
| 86 | <li>Integers of 8 to 64 bits, signed and unsigned, which wrap; <code>BOOL</code>, <code>F32</code>, <code>F64</code>. Nothing converts unless it is written.</li> |
| 87 | <li>Arrays, checked slices, pointers, records laid out as C lays them out, packed records, enumerations, sets, and variants with <code>match</code>.</li> |
| 88 | <li>Every index and slice is checked; a failure says where it was, with the values, and the calls under way.</li> |
| 89 | <li>Strings of UTF-8 bytes, raw strings over lines that keep the code's indent, and <code>match</code> on a string.</li> |
| 90 | <li>Every variable starts at zero. Behaviour is defined everywhere but through pointers.</li> |
| 91 | <li>No garbage collector: memory comes from an allocator the program chooses and passes.</li> |
| 92 | <li>Several results, <code>ERROR</code> values and <code>defer</code>, in place of exceptions.</li> |
| 93 | <li>Modules with bodies, and generic modules: <code>Map(K, V; hash, eq)</code>.</li> |
| 94 | <li><code>^VOLATILE T</code> and the atomics <code>CAS</code>, <code>XCHG</code>, <code>XADD</code>, <code>FENCE</code>, for devices and lock-free code.</li> |
| 95 | <li><code>extern</code> procedures and variables from C, code procedures in assembly, and <code>SYSCALL</code>.</li> |
| 96 | <li>Threads without C, a library of <code>Out</code>, <code>Str</code>, <code>Bytes</code>, <code>Fmt</code>, <code>Map</code>, <code>Sort</code> and more, and gdb that knows your lines.</li> |
| 97 | <li>A formatter, a documentation tool, and editor support for vim and emacs.</li> |
| 98 | </ul> |
| 99 | </div> |
| 100 | </div> |
| 101 | |
| 102 | <h2>Learn it</h2> |
| 103 | <p><a href="tour/index.html"><strong>Raz, Set, Go</strong></a> is a tour of the |
| 104 | language in 15 lessons, each with programs you can run. <a |
| 105 | href="advanced/index.html"><strong>More Raz</strong></a> is the second tour: |
| 106 | the library, programs with no run time, procedures in assembly, system calls, |
| 107 | volatile accesses, atomics and lock-free code, in 18 more.</p> |
| 108 | |
| 109 | <h2>The language, in writing</h2> |
| 110 | <p>The language is defined by <a href="spec.html">the report</a>, which is |
| 111 | short on purpose: whatever it doesn’t allow, raz doesn’t have. |
| 112 | Its second volume describes the library. Both are on one page, and each is |
| 113 | a PDF: <a href="raz.pdf">the language</a> (36 pages) and |
| 114 | <a href="raz-lib.pdf">the library</a>.</p> |
| 115 | |
| 116 | <h2 id="download">Download</h2> |
| 117 | <p>raz 0.25.3 is a tarball for x86-64 Linux with the compiler, <code>raz</code>, |
| 118 | its library, <code>lib/</code>, which it finds beside itself, the formatter |
| 119 | and the documentation tool as sources in <code>tools/</code>, and the manual |
| 120 | pages. It needs nothing else installed.</p> |
| 121 | <div class="cta"> |
| 122 | <a class="btn primary" href="download/raz-0.25.3-linux-x86_64.tar.gz">Download raz 0.25.3</a> |
| 123 | <a class="btn" href="download/raz-0.25.3-linux-x86_64.tar.gz.sha256">SHA-256</a> |
| 124 | </div> |
| 125 | <pre class="code"><code>$ tar xzf raz-0.25.3-linux-x86_64.tar.gz |
| 126 | $ ln -s $PWD/raz-0.25.3-linux-x86_64/raz ~/.local/bin/raz |
| 127 | $ raz run Hello.raz</code></pre> |
| 128 | <p>The link works since raz finds <code>lib/</code> beside its real path. The |
| 129 | manual pages are in <code>man/</code>: <code>man ./man/raz-tutorial.7</code>. |
| 130 | The address <code>download/latest</code> always leads to the newest release, |
| 131 | and <code>download/raz-0.25.3-linux-x86_64.tar.gz</code> to this one, for |
| 132 | good. Earlier releases: <a href="download/raz-0.25.2-linux-x86_64.tar.gz">0.25.2</a>, <a href="download/raz-0.25.1-linux-x86_64.tar.gz">0.25.1</a>, <a href="download/raz-0.25.0-linux-x86_64.tar.gz">0.25.0</a>, <a href="download/raz-0.24.0-linux-x86_64.tar.gz">0.24.0</a>, <a href="download/raz-0.23.0-linux-x86_64.tar.gz">0.23.0</a>, <a href="download/raz-0.22.0-linux-x86_64.tar.gz">0.22.0</a>, <a href="download/raz-0.21.0-linux-x86_64.tar.gz">0.21.0</a>, <a href="download/raz-0.20.0-linux-x86_64.tar.gz">0.20.0</a>, <a href="download/raz-0.19.0-linux-x86_64.tar.gz">0.19.0</a>, <a href="download/raz-0.18.1-linux-x86_64.tar.gz">0.18.1</a>, <a href="download/raz-0.18.0-linux-x86_64.tar.gz">0.18.0</a>, <a href="download/raz-0.17.2-linux-x86_64.tar.gz">0.17.2</a>, <a href="download/raz-0.17.1-linux-x86_64.tar.gz">0.17.1</a>, <a href="download/raz-0.17.0-linux-x86_64.tar.gz">0.17.0</a>, <a href="download/raz-0.16.0-linux-x86_64.tar.gz">0.16.0</a>, <a href="download/raz-0.15.0-linux-x86_64.tar.gz">0.15.0</a>, <a href="download/raz-0.14.0-linux-x86_64.tar.gz">0.14.0</a>, <a href="download/raz-0.13.0-linux-x86_64.tar.gz">0.13.0</a>, <a href="download/raz-0.12.0-linux-x86_64.tar.gz">0.12.0</a>, <a href="download/raz-0.11.1-linux-x86_64.tar.gz">0.11.1</a>, <a href="download/raz-0.11.0-linux-x86_64.tar.gz">0.11.0</a>, <a href="download/raz-0.10.1-linux-x86_64.tar.gz">0.10.1</a>, <a href="download/raz-0.10.0-linux-x86_64.tar.gz">0.10.0</a>, <a href="download/raz-0.9.1-linux-x86_64.tar.gz">0.9.1</a>, <a href="download/raz-0.9.0-linux-x86_64.tar.gz">0.9.0</a>, <a href="download/raz-0.8.0-linux-x86_64.tar.gz">0.8.0</a>, <a href="download/raz-0.7.1-linux-x86_64.tar.gz">0.7.1</a>; each has its SHA-256 beside it, with |
| 133 | <code>.sha256</code> added to its name.</p> |
| 134 | <p class="sha">SHA-256 <code>45fdafd83e889baff969b5923d48d5a6793ce1d0b337e087f00d47939c279101</code></p> |
| 135 | <p><a href="source/releases/index.html">Release pages</a> give each |
| 136 | version's commit, notes, compiler and source archives, with checksums. |
| 137 | Browse the <a href="source/index.html">source and history</a>, or clone: |
| 138 | <code>git clone https://raz.lucela.org/source/</code>.</p> |
| 139 | |
| 140 | </main> |
| 141 | <footer>raz is under the ISC license. <a href="source/index.html">Source</a></footer> |
| 142 | </body> |
| 143 | </html> |