Tutorial · About 10 minutes · No install
Write a rule once. Get it in six languages.
Five short lessons. Write a business rule in plain words, prove it with examples, and watch it turn into TypeScript, Python, Go, Rust, C#, and Java as you type. Everything runs in your browser.
Lesson 1 of 5
Say the rule in plain words
A contract names one business rule. A decision is a question with named inputs, and each when line answers it.
Picture it
A decision is a short flowchart you can read top to bottom: check a condition, give an answer; otherwise, the fallback answer.
- contract
- Names the rule you are writing.
- purpose
- One sentence a teammate could check.
- decision
- The question, with its inputs and their types.
- when ... ->
- If the condition is true, this is the answer.
- otherwise
- The answer when no rule matched.
All 2 examples pass. The rule does what you said it should.
- Passed: a big order
- Passed: a small order
Try this
Raise the free-shipping threshold to $75.
// Generated from ThunderLang. Deterministic, no AI. The first matching rule wins. export function ShippingFee(total: number): string { if ((total >= 50)) return "Free"; return "Standard"; }
Generated in your browser by the ThunderLang compiler, deterministically, with no AI. Each tab is the same rule; the first matching rule wins in every language.
Keep writing where you work
The same file works in the browser, in your terminal, and in OpenThunder. Download this lesson as standard ThunderLang to carry it over.
In the browser
Write larger contracts with completions, diagrams, and proofs. Nothing to install.
In your terminal
Run the examples, generate code, and run the examples against that code.
# install once
npm install -g @skillstech/thunderlang
thunder test Shipping.thunder
thunder gen Shipping.thunder --target python
thunder test Shipping.thunder --target typescriptThe published CLI generates TypeScript, Python, C#, and Java. Go and Rust output above comes from the newer compiler that powers this page.
In OpenThunder
Open .thunder files in the OpenThunder editor with highlighting, completions, and hover help. From the repository, check every contract and compare languages:
openthunder intent prove openthunder intent conform