Money-Native Programming
What if payments weren't a library you bolt on, but part of the language itself? Money-native programming makes wallets, payments and settlement first-class - and lets the same program settle on different rails.
Every idea in this course has been about handling money correctly around a language. The frontier idea is to bake money into the language: make wallets, payments, guardrails and metering first-class, so the compiler and runtime enforce correctness instead of relying on you to remember it. This is money-native programming, and the Larz stack has a working example. This final session explores the idea and the concept that makes it powerful: pluggable settlement.
Money as a language primitive
In a money-native language, the things this course treated as careful patterns become built-in keywords the runtime enforces.
wallet customer = $50.00 # a balance is a type
price coffee = $3.50 # money is a value ($ = exact cents)
pay coffee from customer to shop # moves money, records a ledger entry
require customer.balance >= $10 # a guardrail the runtime enforces
fn charge() gas 500 { ... } # metered: can't run past its budget$3.50 is exact cents, not a float, because the language says so. pay ... from ... to ... moves money and records a ledger entry, so you can't move money without recording it. require is a guardrail the runtime enforces, not a check you might forget. Functions can be gas-metered so untrusted or billable code can't run past its budget. The stack's larzscript is exactly this - a small money-native language where these are keywords. It's the ideas from this whole course, turned into syntax the machine enforces.Pluggable settlement: one program, many rails
The deepest idea: separate what a payment means from how it settles. The program says 'pay'; a settlement backend decides whether that's in-memory, fiat, or on-chain.
| Settlement backend | What 'pay' does | Used for |
|---|---|---|
| In-memory | moves balances in the program | testing, simulation |
| Fiat (checkout) | a card/PayPal checkout tops up credit | real-world charging |
| On-chain | a real signed blockchain transaction | crypto settlement |
| Audit log | records every movement externally | compliance |
The <i>same unchanged program</i> can settle different ways by swapping the backend - and each backend can <b>authorize</b> a payment before any money moves (an over-spend is declined, never partially settled) and <b>record</b> it afterward to a real ledger. This is how larzscript settles against <a href='/stack/larzchain'>larzchain</a> (real on-chain LARZ) or a fiat gateway, with the program logic untouched. It's the culmination of the course: correct money handling, made a property of the system rather than a discipline you hope everyone follows.
The money-native idea
- Make money first-class: wallets, payments, guardrails and metering as language primitives.
- The runtime enforces correctness - exact money, recorded movements, guardrails that can't be skipped.
- Pluggable settlement separates what a payment means from how it settles (fiat, on-chain, memory).
- The same program settles on any rail - authorize before moving, record after.
๐งฉ Do it with LarzOS
Turn this lesson into action with the exact free tools and AI workflows for the job:
๐ฏ Key takeaways
- Money-native programming makes wallets, payments, guardrails and metering first-class language primitives.
- When money is in the grammar, the runtime enforces exact amounts, recorded movements and guardrails you can't skip.
- Pluggable settlement separates what a payment means from how it settles (in-memory, fiat, on-chain).
- The same program can settle on any rail - authorize before money moves, record after - see larzscript + larzchain.
Frequently asked
Is a money-native language actually practical, or just a neat idea?
It's both a genuinely interesting idea and a practical one for a real niche, though it's not aiming to replace general-purpose languages - and understanding where it fits is the key to judging it fairly. A brand-new general-purpose language competing head-on with established ones is almost always impractical, because the value of a language lies heavily in its ecosystem (libraries, tools, community, hiring), which takes years to build. A money-native language succeeds not by trying to be a better general language, but by owning a specific concern that mainstream languages treat as an afterthought: money as a first-class citizen. In domains where money correctness is paramount and money logic is the core of the program - payments platforms, fintech, ledgers, smart contracts, billing systems - a language (or a well-designed embedded DSL) that makes exact money, wallets, enforced guardrails, recorded transactions, and metering into built-in, compiler-and-runtime-enforced features can genuinely reduce whole classes of bugs, because correctness is structural rather than dependent on every developer remembering the right patterns. That's a real, practical benefit for that niche. In practice, 'money-native' ideas show up in several forms: dedicated small languages/DSLs for financial rules or contracts; smart-contract languages (which are essentially money-native, with value and transfers as primitives, gas metering, and enforced constraints - a large, real domain); and libraries or type systems within existing languages that bring money-native discipline (exact money types, ledgers, state machines) to a mainstream ecosystem. So the practical answer: a full standalone money-native general language is a niche play that makes sense where money logic dominates and correctness is critical, and even where a full new language isn't warranted, the money-native principles (first-class exact money, enforced money rules, pluggable settlement, metered execution) are practical and valuable as libraries and patterns within languages you already use - which is much of what this whole course and the Larz money stack demonstrate. The idea's practicality is proven by smart-contract platforms (money-native languages running real value) and by the widespread use of exact-money libraries and ledger patterns in serious fintech. It's not going to replace Python or JavaScript for general work, and it doesn't try to; its practicality is in being the right tool where money is the point. larzscript is a working demonstration of the concept - a small, real money-native language - and studying it is a good way to understand both the appeal and the sensible scope of the idea. Neat idea, yes; but also a practical one in its proper domain, and a source of principles you can apply even in mainstream code.
What does 'pluggable settlement' really give me that ordinary payment code doesn't?
Pluggable settlement gives you a clean separation between your business logic (what a payment means) and the payment mechanism (how it actually settles), which in turn gives you testability, flexibility, and the ability to support multiple payment rails without rewriting your program - benefits ordinary payment code, where the payment mechanism is usually hard-wired into the logic, doesn't easily provide. In typical payment code, the act of charging is tangled directly into the business flow: the code that decides a customer should pay $50 also directly calls a specific payment provider's API to do it, so the 'what' (charge $50 for this order) and the 'how' (call Stripe/PayPal/etc.) are fused. That fusion causes friction: testing the business logic requires either hitting the real payment system or building ad-hoc mocks; supporting a second payment method or provider means threading new code through your business logic; and simulating scenarios (what if this payment is declined?) is awkward. Pluggable settlement inverts this: your program expresses the intent to pay (move this amount from here to there) through a settlement interface, and a swappable backend decides how that intent is actually carried out. The same unchanged business program can then be run with different settlement backends: an in-memory one for fast, safe tests and simulations (no real money, no network - you can run your whole payment logic in unit tests instantly); a fiat/card backend for real customer charges; an on-chain backend for crypto settlement; an audit-logging backend for compliance; or a backend that authorizes against real balances and declines over-spends before any money moves. The concrete gains: (1) Testability - you test your money logic thoroughly against an in-memory backend, with no external dependencies, which is huge for correctness and speed. (2) Flexibility - you can switch or add payment rails (a new provider, a new currency, crypto) by writing a new backend, without touching the business logic that decides who pays what. (3) Correctness controls - a settlement backend can enforce cross-cutting rules uniformly (authorize before moving money so nothing partially settles, record every movement to a ledger, dedupe by transaction id) in one place rather than scattered through the code. (4) Clarity - the separation makes the system easier to reason about, because 'what should happen' and 'how it's executed' are distinct. This is essentially the dependency-inversion / strategy pattern applied to payments, and it's how the Larz stack lets the same larzscript program settle in-memory, on-chain via larzchain, or through a fiat gateway, unchanged. Ordinary payment code can achieve some of this with disciplined abstraction, but pluggable settlement makes it the default structure, giving you clean testing, multi-rail flexibility, and centralized correctness for free. It's a design that pays off as soon as you need to test money logic without real charges (always) or support more than one way of settling (often) - which is why it's a valuable pattern to know and a fitting capstone for handling money in software well.
You've finished the Money & Payments in Software sessions
Now lock it in with the coursework.
Do the assignments โRelated lessons
Charging Customers Safely
Taking a payment is more than calling an API. Idempotency, webhooks, subscription lifecyclโฆ
Money & Payments in SoftwareKeeping the Books: Double-Entry
Once money moves, you need to record it so nothing is lost. Double-entry bookkeeping - eveโฆ
Crypto & Web3Crypto Safety First: How Beginners Actually Lose Money (and How Not To)
Before you chase gains, learn to not get rekt. Most beginners don't lose money to the markโฆ