raz / commit c4ee39e3

commit
c4ee39e3b9b5384af4cef65671bd682a39d77c19
author
Luis <42945842+ldiaz94@users.noreply.github.com>
date
parent
72af0e47
site: the compiler is in raz, builds itself; report 2026-10.21

Home page: ~10,500 lines, ~500K lines/s (self-built); public/ rebuilt.

patch · log

6 files changed, +35 -28

site/content/home.html (history) modified +4 -4

@@ -15,13 +15,13 @@
1515 system calls and call C libraries. It has no garbage collector and no hidden
1616 run time: what the program does is what its text says.</p>
1717
18-<p>The compiler is one Free Pascal program of about 9,100 lines. It makes
18+<p>The compiler is written in raz, about 10,500 lines, and builds itself. It makes
1919 x86-64 machine code and the ELF file itself, with no assembler or linker, in
20-one pass, at about 900,000 lines a second.</p>
20+one pass, at about 500,000 lines a second.</p>
2121
2222 <div class="facts">
23- <span><b>~9,100</b> lines of compiler</span>
24- <span><b>~900K</b> lines compiled a second</span>
23+ <span><b>~10,500</b> lines of compiler</span>
24+ <span><b>~500K</b> lines compiled a second</span>
2525 <span><b>static</b> executables, no run time to install</span>
2626 <span><b>1</b> report, about <b>30</b> pages</span>
2727 </div>

site/public/advanced/listing.html (history) modified +12 -12

@@ -246,18 +246,18 @@
246246 <ul><li><code>gdb</code> finds procedures by name and lines by number, since the executable carries them: <code>break Dot.dot</code> and <code>list</code> work, and so does stepping a line at a time.</li><li><code>RAZ_PROFILE=1</code> samples the program every millisecond and says which procedures and lines took the time.</li><li><code>objdump -d</code> disassembles what is really in the file, if you want to see the bytes behind a listing.</li></ul>
247247 <pre class="output term"><code><span class="cmd">$ raz -o Dot Dot.raz</span>
248248 <span class="cmd">$ objdump -d -M intel --no-show-raw-insn Dot | sed -n &#x27;/&lt;Dot.dot&gt;:/,/ret/p&#x27; | head -12</span>
249-0000000000403ac0 &lt;Dot.dot&gt;:
250- 403ac0: push rbp
251- 403ac1: mov rbp,rsp
252- 403ac4: sub rsp,0x40
253- 403acb: mov QWORD PTR [rbp-0x30],rbx
254- 403acf: xor ebx,ebx
255- 403ad1: mov QWORD PTR [rbp-0x28],r12
256- 403ad5: xor r12d,r12d
257- 403ad8: mov QWORD PTR [rbp-0x20],rdx
258- 403adc: mov QWORD PTR [rbp-0x18],rcx
259- 403ae0: xor ebx,ebx
260- 403ae2: mov r8,rsi</code></pre>
249+0000000000403b40 &lt;Dot.dot&gt;:
250+ 403b40: push rbp
251+ 403b41: mov rbp,rsp
252+ 403b44: sub rsp,0x40
253+ 403b4b: mov QWORD PTR [rbp-0x30],rbx
254+ 403b4f: xor ebx,ebx
255+ 403b51: mov QWORD PTR [rbp-0x28],r12
256+ 403b55: xor r12d,r12d
257+ 403b58: mov QWORD PTR [rbp-0x20],rdx
258+ 403b5c: mov QWORD PTR [rbp-0x18],rcx
259+ 403b60: xor ebx,ebx
260+ 403b62: mov r8,rsi</code></pre>
261261 <p>The listing is what the encoder meant; <code>objdump</code> is what the processor will read. They tell the same story.</p><p class="tryit">Save a program under its module&rsquo;s name and run it with <code>raz run Name.raz</code>.</p><div class="pager"><a href="syscalls.html">&larr; System calls</a><a href="index.html">Contents</a><a class="next" href="volatile.html">Volatile &rarr;</a></div></article></div>
262262 </main>
263263 <footer>raz is under the ISC license.</footer>

site/public/advanced/static.html (history) modified +5 -5

@@ -65,7 +65,7 @@
6565 <span class="cmd">$ ldd Bare</span>
6666 not a dynamic executable
6767 <span class="cmd">$ ls -l Bare | awk &#x27;{print $5, &quot;bytes&quot;}&#x27;</span>
68-26184 bytes</code></pre>
68+26280 bytes</code></pre>
6969 <p>It is statically linked: no interpreter, no shared libraries, no <code>libc</code>. <code>ldd</code> says so.</p>
7070 <h2>What it does when it runs</h2>
7171 <p><code>strace</code> lists every system call a program makes. This is the whole of it:</p>
@@ -134,15 +134,15 @@
134134 <pre class="output term"><code><span class="cmd">$ raz Lean.raz</span>
135135 <span class="cmd">$ raz Heavy.raz</span>
136136 <span class="cmd">$ ls -l Lean Heavy | awk &#x27;{print $9, $5}&#x27;</span>
137-Heavy 28392
138-Lean 28384</code></pre>
137+Heavy 28496
138+Lean 28480</code></pre>
139139 <p>The sizes differ by a few bytes, not by the hundreds of kilobytes that the table and the procedure would take: they are not in the executable at all. You can link in a library module without worrying what else it offers.</p>
140140 <h2>Stripping</h2>
141141 <p><code>-s</code> leaves out what is there for finding faults: the symbols and line numbers, the places a failure is told by, and the profiler. It is for the final build of a size-conscious program; the default keeps them so that gdb and failure messages work.</p>
142142 <pre class="output term"><code><span class="cmd">$ raz -s -o Lean-stripped Lean.raz</span>
143143 <span class="cmd">$ ls -l Lean Lean-stripped | awk &#x27;{print $9, $5}&#x27;</span>
144-Lean 28384
145-Lean-stripped 6720
144+Lean 28480
145+Lean-stripped 6848
146146 <span class="cmd">$ ./Lean-stripped</span>
147147 same program</code></pre>
148148 <p><code>raz -S Lean.raz</code> is the other direction: it prints the machine code the compiler made, one source line at a time. The next two parts of the tour use it.</p><p class="tryit">Save a program under its module&rsquo;s name and run it with <code>raz run Name.raz</code>.</p><div class="pager"><a href="allocators.html">&larr; Writing an allocator</a><a href="index.html">Contents</a><a class="next" href="linkstatic.html">Threads without C, and keeping the two apart &rarr;</a></div></article></div>

site/public/index.html (history) modified +4 -4

@@ -35,13 +35,13 @@
3535 system calls and call C libraries. It has no garbage collector and no hidden
3636 run time: what the program does is what its text says.</p>
3737
38-<p>The compiler is one Free Pascal program of about 9,100 lines. It makes
38+<p>The compiler is written in raz, about 10,500 lines, and builds itself. It makes
3939 x86-64 machine code and the ELF file itself, with no assembler or linker, in
40-one pass, at about 900,000 lines a second.</p>
40+one pass, at about 500,000 lines a second.</p>
4141
4242 <div class="facts">
43- <span><b>~9,100</b> lines of compiler</span>
44- <span><b>~900K</b> lines compiled a second</span>
43+ <span><b>~10,500</b> lines of compiler</span>
44+ <span><b>~500K</b> lines compiled a second</span>
4545 <span><b>static</b> executables, no run time to install</span>
4646 <span><b>1</b> report, about <b>30</b> pages</span>
4747 </div>

site/public/spec.html (history) modified +9 -2

@@ -36,7 +36,7 @@
3636 </ul>
3737 <p>raz is a small systems language, first made for x86-64 Linux. A raz program can lay a record over a device’s registers, read and write a device’s memory exactly as written, take part in lock-free algorithms, make system calls and call C libraries. It has no garbage collector and no hidden run time: what the program does is what its text says.</p>
3838 <p>This report defines the language. It is short on purpose. Whatever it doesn’t allow, raz doesn’t have.</p>
39-<p>This is version 2026-10.20 of the report; section 12 says what each version changed. 2026-10.11 and 2026-10.12 are a thaw the owner chose, for a language anyone can build again. They break programs written for 2026-10.10 and before: for 2026-10.9, say, the report of compiler 0.5.0, the last release before them; and 2026-10.12 breaks code procedures written for 2026-10.11. 2026-10.20 is a third, for <code>try</code> (section 7.8); it breaks a program that has a name <code>try</code>.</p>
39+<p>This is version 2026-10.21 of the report; section 12 says what each version changed. 2026-10.11 and 2026-10.12 are a thaw the owner chose, for a language anyone can build again. They break programs written for 2026-10.10 and before: for 2026-10.9, say, the report of compiler 0.5.0, the last release before them; and 2026-10.12 breaks code procedures written for 2026-10.11. 2026-10.20 is a third, for <code>try</code> (section 7.8); it breaks a program that has a name <code>try</code>.</p>
4040 <p>The language is frozen, softly, from this version on: it changes only to mend a defect, and its library grows only by what breaks no program written for it. What anyone wishes it had waits on a list, for a later thaw.</p>
4141 <h1 id="a-first-look">1. A first look</h1>
4242 <pre><code>module Hello;
@@ -494,7 +494,13 @@
494494 | dot: area := 0.0;
495495 end;</code></pre>
496496 <p><code>match</code> runs the arm of the case <code>s</code> holds. An arm may name the case’s fields, in order, all of them; the names stand for those fields of <code>s</code> itself, so assigning to one changes <code>s</code>; if <code>s</code> isn’t a variable, they stand for the fields of a copy. An arm may also leave the fields unnamed. Every case must have an arm, and only one, unless there is an <code>| else:</code> arm, which must come last.</p>
497-<p><code>match</code> on an enumeration works the same way: each arm names one of the enumeration’s names.</p>
497+<p><code>match</code> on an enumeration works the same way: each arm names one of the enumeration’s names, or several, separated by commas, for the arm to run when the value is any of them:</p>
498+<pre><code>match op of
499+| sPlus, sMinus: kind := additive;
500+| sTimes: kind := multiplicative;
501+| else:
502+end;</code></pre>
503+<p>Every name must have an arm, and only one, unless there is an <code>| else:</code> arm. A variant’s arm names one case: the fields it may name belong to that case alone.</p>
498504 <p><code>match</code> on an integer runs the arm whose labels hold its value:</p>
499505 <pre><code>match ch of
500506 | &#39; &#39;, &#39;\t&#39;: skip := true;
@@ -1096,6 +1102,7 @@
10961102 <li><strong>2026-10.18.</strong> A code procedure takes and returns slices (section 8).</li>
10971103 <li><strong>2026-10.19.</strong> The library gains <code>Bytes</code> (section 11).</li>
10981104 <li><strong>2026-10.20.</strong> <code>try</code>: a call of a procedure whose last result is an <code>ERROR</code>, which makes the procedure it stands in return that error when it isn’t <code>nil</code> (sections 2, 5.8, 6, 7.8 and appendix B). <code>try</code> becomes a reserved word, which breaks a program with a name <code>try</code>.</li>
1105+<li><strong>2026-10.21.</strong> An arm of a <code>match</code> on an enumeration may name several of its names (section 7.4).</li>
10991106 </ul>
11001107 <h1 id="appendix-a.-what-an-implementation-chooses">Appendix A. What an implementation chooses</h1>
11011108 <p>Everything in this report binds every implementation of raz, except what follows, which each chooses for itself and documents. This compiler’s choices are in <code>doc/compiler.md</code>, under “This compiler’s choices”. The programs in <code>conform/</code> are how an implementation shows that it follows this report: it passes them all, its reals aside where its target has none; <code>conform/check.sh</code> runs them.</p>

site/public/tour/hello.html (history) modified +1 -1

@@ -70,7 +70,7 @@
7070 <span class="cmd">$ raz run Quiet.raz</span>
7171 hello, again
7272 <span class="cmd">$ ls -l Quiet | awk &#x27;{print $5, &quot;bytes&quot;}&#x27;</span>
73-28392 bytes</code></pre>
73+28488 bytes</code></pre>
7474 <p>The program is a static executable with no run time besides the code it uses, so it is a few kilobytes, and runs without any library installed.</p>
7575 <h2>What <code>Out</code> can write</h2>
7676 <p><code>Out</code> is the library's buffered output. It writes strings, single characters, numbers in decimal or hexadecimal, and a line feed. A string is written as it is, with <code>\n</code> for a line feed, <code>\t</code> for a tab, <code>\"</code> and <code>\\</code>.</p>