Programming Model Comparison
| Aspect | Solidity | Daml |
|---|---|---|
| Paradigm | Imperative, object-oriented | Functional, declarative |
| State | Mutable storage | Immutable contracts |
| Execution | Sequential operations | Transaction trees |
| Types | Static with dynamic calls | Strongly typed, ADTs |
| Side effects | Unlimited | Controlled via monads |
State Model: Mutable vs. Immutable
Solidity: Mutable State
In Solidity, contracts have mutable storage that you modify directly:Daml: Immutable Contracts
In Daml, contracts are immutable data. State changes create new contracts or archive existing contracts:UTXO vs. Account Model
Ethereum: Account Model
- State is a global mapping of accounts to balances
- Transfers modify account entries
- Easy to query total balance
- Contention on popular accounts
Canton: Extended UTXO Model
- State is a set of contracts (like unspent outputs)
- Transfers archive existing contracts, create new ones
- Balance is sum of owned contracts
- Better parallelism, explicit data flow
Language Comparison
Type System
| Feature | Solidity | Daml |
|---|---|---|
| Type safety | Moderate | Strong |
| Null handling | Implicit (0/empty) | Explicit (Optional) |
| Custom types | Structs, enums | ADTs, records |
| Generics | Limited | Full parametric polymorphism |
Solidity Types
Daml Types
Solidity Control Flow
Daml Control Flow
Authorization Model
Solidity: Runtime Authorization
- Authorization checked at runtime
- Easy to forget checks
- Anyone can attempt the call
- Authorization mixed with logic
Daml: Declarative Authorization
- Authorization declared, not coded
- Impossible to forget (compiler enforces)
- Only authorized parties can attempt
- Clear separation of concerns
Multi-Party Coordination
Solidity: Manual Multi-Sig
Daml: Native Multi-Party
Common Patterns Translated
| Solidity Pattern | Daml Equivalent |
|---|---|
| Ownable | Signatory declaration |
| Pausable | Contract archival + recreation |
| ERC-20 | Token Standard (CIP-0056) |
| Proxy/Upgradeable | Smart Contract Upgrade (SCU) |
| Pull payment | Propose/accept pattern |
| Factory | Template + create |
| Registry | Contract keys (when available) |
What to Unlearn
| Solidity Habit | Daml Reality |
|---|---|
| Mutate state in place | Archive + create new contracts |
Runtime msg.sender checks | Compile-time controller declarations |
| Public functions anyone can call | Only controllers can exercise |
| Global contract address | Contract IDs change on every update |
| Loops for iteration | Use forA, mapA, fold patterns |
| Try/catch everywhere | Assertions for validation; exceptions are deprecated |