t27.aiРусский

Seven backends

You will learn

The names of the 7 backends and how much code each wrote for one small spec.

The compiler in your browser has 7 backends: c, js, rust, ts, verilog, verilog_hir and zig. Each reads the same parsed spec and writes code in its language; the verilog_hir backend is written from the hardware view, HIR. The table shows the bytes each backend wrote for the lesson spec, measured with the compiler on this site. Bigger is not better: each language needs a different amount of text.

Try it

Open each backend tab of the lesson spec in the player and find the function add.

Open the interactive lesson →

t27 basics 22: one spec, seven backends
t27 basics 22: one spec, seven backends ↗

How many bytes each of the 7 t27c backends wrote for one small spec, measured with the real compiler. Lesson 22 of the t27 basics course.

specs/basics/22_seven_backends.t27

// SPDX-License-Identifier: Apache-2.0
; t27 basics, lesson 22: Seven backends.
; One spec, seven languages: what each backend of t27c writes.

module basics_22_seven_backends;

pub const WIDTH : u8 = 8;

pub fn add(a: u8, b: u8) -> u8 {
    return a + b;
}

test width_is_a_byte {
    assert WIDTH == 8;
}

Open the lesson's spec in the player ↗

All lessons