> ## Documentation Index
> Fetch the complete documentation index at: https://companyname-a7d5b98e-nft-comparison.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Tolk vs FunC: in short

Tolk is more similar to TypeScript and Kotlin than to C or Lisp.
It provides complete control over the TVM assembler, as it includes a FunC kernel within.

### Declarations

* `fun` declares a function.
* `get fun` declares a get method.
* `var` declares a variable.
* `val` declares an immutable variable.

Types are written on the right.

Parameter types are required; **return** and **local** variable types are inferred automatically.

Specifiers such as `inline_ref` are written as `@` attributes.

```tolk theme={null}
global storedV: int;

fun parseData(cs: slice): cell {
    var flags: int = cs.loadMessageFlags();
    // …
}

@inline
fun sum(a: int, b: int) {   // auto inferred int
    val both = a + b;       // same
    return both;
}

get fun currentCounter(): int { ... }
```

### Syntax and semantics

* No `impure`. All functions are treated as `impure` by default; the compiler does not remove user function calls.
* Use `onInternalMessage`, `onExternalMessage`, and `onBouncedMessage` instead of `recv_internal` and `recv_external`.
* `2+2` is 4, not an identifier. Identifiers are **alphanumeric**. Use `const OP_INCREASE` instead of `const op::increase`. `cell` and `slice` are valid identifiers; not keywords.
* Logical operators AND `&&`, OR `||`, NOT `!` are supported.

#### Syntax improvements

* `;; comment` → `// comment`
* `{- comment -}` → `/* comment */`
* `#include` → `import`; strict rule: **import only what is used**
* `~ found` → `!found`; used for boolean values only (true is -1, as in FunC)
* `v = null()` → `v = null`
* `null?(v)` → `v == null`, similar for `builder_null?` and others
* `~ null?(v)` → `c != null`
* `throw(excNo)` → `throw excNo`
* `catch(_, _)` → `catch`
* `catch(_, excNo)` → `catch(excNo)`
* `throw_unless(excNo, cond)` → `assert(cond, excNo)`
* `throw_if(excNo, cond)` → `assert(!cond, excNo)`
* `return ()` → `return`
* `do ... until (cond)` → `do ... while (!cond)`
* `elseif` → `else if`
* `ifnot (cond)` → `if (!cond)`
* `"..."c` → `stringCrc32("...")` and other postfixes

### Compilation model

* Functions can be called before declaration.
* Forward declarations are not required.
* The compiler first parses and then resolves symbols, producing an AST representation of the source code.

### Standard library

* Standard library functions use clear, camelCase names.
* The stdlib is embedded and split into multiple files.
* Common functions are available; specialized ones can be imported. For example, `import "@stdlib/tvm-dicts"`.
* IDEs provide import suggestions.
* See [the FunC-Tolk stdlib mapping](/languages/tolk/from-func/stdlib).

### Language features

* No `~` tilde methods. See [mutability details](/languages/tolk/from-func/mutability).
* Type mismatch errors are clear and readable.
* The `bool` type is supported.
* Indexed access `tensorVar.0` and `tupleVar.0` is supported.
* Nullable types `T?`, null safety, smart casts, and the operator `!` are supported.
* Union types and pattern matching are supported for types and expressions, with switch-like behavior.
* Type aliases are supported.
* Structures are supported.
* Generics are supported.
* Methods as extension functions are supported.
* Enums are supported.
* Trailing comma is supported.
* A semicolon after the last statement in a block is optional.
* Fift output contains original `.tolk` lines as comments.
* Auto-packing to and from cells is supported for all types.
* Universal createMessage simplifies cell composition.
* `map<K, V>` instead of low-level TVM dictionaries.
* Anonymous functions (lambdas).
* The compiler automatically detects and inlines functions.
* Includes gas optimization improvements.

### Tooling around

* [JetBrains IDE plugin](https://github.com/ton-blockchain/intellij-ton)
* [VS Code extension](https://github.com/ton-blockchain/ton-language-server)
* [FunC-to-Tolk converter](https://github.com/ton-blockchain/convert-func-to-tolk)
* [tolk-js](https://github.com/ton-blockchain/tolk-js) WASM wrapper for blueprint

### Gas benchmarks

The [Tolk-bench repository](https://github.com/ton-blockchain/tolk-bench) contains contracts migrated from FunC to Tolk, with identical logic and passing the same tests.
