Home /Modules/tutorial/06-the-triplet.md

06-the-triplet.md

tutorial/06-the-triplet.md · 58 line(s) · markdown

Lesson 06 — The Triplet: Java, Sleela, C

Series: index · prev: 05 · next: 07 — Conducted methods

One SLeeLa source renders faithfully into three targets — the triplet. You choose the target with target-language in the sheet.

TargetWhat you getNote
javaidiomatic Java: a class with static methodsprinted to stdout
sleelacanonical Sleela, runnable on the C corewritten as an artifact
cC with a tiny tagged-value runtimeprinted to stdout

Why three?

Because SLeeLa's governing principle (§20) is that any client — C, C++, Java, or other — can implement the connector without becoming a SLeeLa runtime. The triplet proves the same logical program is expressible in each idiom.

Retarget the same source

Only one line changes in the sheet:

target:
  target-language java     # or: sleela | c

Then:

impl/build/nordshrift build impl/nordshrift/examples/demo/build.sst

The runnable Sleela artifact

The sleela target is special: its output runs directly on the Sleela Core VM. That's what makes the demo end-to-end — Nordshrift compiles Demo.sleela to a runnable build/Demo.sleela artifact, then the core can execute it.

Same logic, three faces

A method like square(n) becomes:

The behavior is identical; only the idiom differs. That fidelity across targets is a core part of "SLeeLa at her source best."

Next: Lesson 07 — Conducted methods