Skip to content

Conversation

@tolk-vm
Copy link
Collaborator

@tolk-vm tolk-vm commented Nov 24, 2025

Live demo: https://companyname-a7d5b98e-tolk-docs.mintlify.app/languages/tolk/overview

I have completed a long effort to provide a from-scratch documentation for Tolk.

The previous version, which I had been incrementally maintaining since January, focused on "Tolk vs FunC" differences.

The new one does not require any prior knowledge of FunC. A reader approaches Tolk directly.

The documentation contains many examples, snippets, and real-world cases. Before starting this work, I reviewed the official docs for Rust, Go, and Kotlin — to absorb best practices for presenting a programming language.

What's inside: brief description

Every aspect of the Tolk language is covered:

  • Type system — every type has its own page. Numbers, addresses, other atomics, structures and generics, nullable and union types, tuples, maps, callables, etc. Each page includes nuances and examples. Overall pages describing how each type is represented in TVM and serialized into cells are also included.
  • Syntax details — how various language constructs look and what they are used for. Variables, conditions, loops, exceptions, functions, methods, imports, etc. Grouped into distinct pages, with examples and usage guidelines.
  • Language features — how to use Tolk for TON smart contracts. Handling and sending messages, storage and get-methods, auto-serialization, lazy loading, etc. Every page focuses on a dedicated topic and provides a deep dive, including answers to common questions.
  • Migrating from FunC — a fully redesigned set of pages for developers coming from FunC. No separate "in short" and "in detail" versions; instead, a single long-read with short examples and references to other pages.

Additionally, there are two entry-point pages:

  • Basic syntax — to get an overall picture of how the language looks.
  • Idioms and conventions — best practices for writing idiomatic Tolk code.

The english style used while writing

All pages are written in a short, formal style (as opposed to the PR descriptions I like to create).

  • no introductory sentences, like "this page describes ..." or "here we will learn ..." — clear and to the point
  • no second-person rule ("you", "we") — although in a few specific places I intentionally used "you"
  • pixel-perfect rendering — I not only "just write" the content, but always check how it renders in a browser. The goal is to avoid hanging words, keep line lengths readable, keep bullets one-line where possible, etc. In many places, the English may be slightly incorrect — and most of those cases are intentional for shortening and precise rendering.

Syntax highlighting!

The current documentation lacks of syntax highlighing, because Mintlify does not support custom languages. FunC, Fift, etc. — all of them are rendered as black plain text.

Tolk documentation contains hundreds of snippets and looks too depressive without highlithing.

That's why I implemented a temporary solution — all snippets are now colorful, in both dark and light modes. Just take a look:

syntax-highlighting

All ```tolk snippets are highlighted automatically: no changes in mdx markup is required.

The highlighing is client-side, via Prism.js, whose sources are embedded. See extra.js for implementation, and extra.css for coloring.

Hopefully, some day, Mintlify will introduce native server-side highlighing. Then, we can discuss across coloring. I fine-tuned grammar and palette the way I prefer it (for example, structures and variables have different colors, because of the capital letter). The current VS Code tmLanguage file is not suitable for this — it must be updated.

For reviewers

If anyone decides to review all the text in this PR, keep this in mind:

  • ... three dots in code snippets are intentional; small snippets are not meant to be copy-pasted — they demonstrate a specific feature
  • "you" is intentionally used in several (seldom) places, even though it formally breaks a no second-person rule, because in those places it sounds significantly better

About merging this PR

Git history is split into multiple sensible commits. For instance, a syntax highlighter is a separate commit.

It's up to you whether to "Squash and merge" all changes into a single commit or to "Rebase and merge" to preserve Git history. I do not see any disadvantages in having multiple commits.

For future changes

If anyone plans to modify the contents in the Tolk documentation, please remember:

  • pixel-perfect rendering — do not change content (especially replacing short words with long ones) without checking how it renders with default settings (100% zoom, desktop). Avoid handing words, prefer one-line bullets, and double-check whether a particular word was chosen specifically to fit the line.
  • syntax highlighting — described above

The documentation in numbers

All together, the new Tolk documentation contains:

  • 46 pages
  • 480 ```tolk snippets
  • 40000 words
  • 280000 characters

I invested ~200 hours developing the text and picking every word — exactly 14 days, about 14 hours a day.

I hope that, cumulatively, this documentation will save noticeably more time for all TON developers.

Closes #1473
Closes #1114
Closes #1128

Live demo: https://companyname-a7d5b98e-tolk-docs.mintlify.app/languages/tolk/overview

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the solid Tolk docs update; I left several style and wording suggestions in languages/tolk files—please apply the inline suggestions where they make sense.

@github-actions
Copy link

github-actions bot commented Dec 1, 2025

bouncer.yml

The most recent commit has made this PR go over 800 added lines. Please, decrease the size of this pull request or consider splitting it into several smaller requests.

Until then, the CI will be marked as failed.

UPD: #1504

@tolk-vm
Copy link
Collaborator Author

tolk-vm commented Dec 1, 2025

A fatal mistake: decided to rebase a branch onto 'main' to have a fresh live demo.

@novusnota
Copy link
Collaborator

novusnota commented Dec 1, 2025

A fatal mistake: decided to rebase a branch onto 'main' to have a fresh live demo.

Yeah, we're experimenting with things, and on top of that, Dependabot (seems to have) pushed an incomplete package-lock.json, so it is what it is. Fixes incoming: 1, 2.

A couple of points regarding the bouncer.yml:

  1. It shall be a bit less noisy, and that is being resolved.
  2. It already ignores changes to package-lock.json, tvm/instructions.mdx, and many other generated files, scripts, and snippets, because this check is mainly concerned with new docs and how easy it is to review things when they're smaller.
  3. It is meant as a guideline, so the wording of its messages will be smoothed out with time. Perhaps, once some checks become truly mandatory, while checks made by this workflow won't.
  4. We've checked the size of the biggest doc pages, and they rarely exceed 500 lines. That is to say, trying to do a lot at once is fun, and I'm a big fan of that personally, but it's very daunting for reviewers. Like, ambition and initiative are still appreciated, but clarity and manageability of contributions are also important for effective collaboration ¯\_(ツ)_/¯.

Sorry for the possible inconveniences along this bumpy way :)

P.S.: Rebases hinder reviews to some degree, because GitHub starts to consider all viewed files as new ones on each rebase. Not to mention the annoying search for comments that were made on files present during some point in the past but were deleted since then.

@verytactical
Copy link
Collaborator

I think it was already discussed internally, but will write about this here too.

@aigerimu is splitting this large PRs into single-article PRs and editing style/language issues, so that we can ensure reviewing it won't take forever.

When the process is over, we'll likely close this PR. If we closed it right now, Mintlify would turn off the link in the title of the PR, and we'd prefer to have it for reference.

At the moment, I'll move the PR to Draft status, so that it doesn't show up in the filtered list of PRs for daily review.

@verytactical verytactical marked this pull request as draft December 3, 2025 09:22
@tolk-vm
Copy link
Collaborator Author

tolk-vm commented Dec 3, 2025

Mda

Copy link
Collaborator

@verytactical verytactical left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Merging on "as is" basis after internal discussion.

@verytactical verytactical changed the title Documentation for Tolk written from scratch feat: documentation for Tolk Dec 4, 2025
@verytactical verytactical merged commit dca4afe into main Dec 4, 2025
18 of 22 checks passed
@verytactical verytactical deleted the tolk-docs branch December 4, 2025 11:46
Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the thoughtful Tolk docs updates in languages/tolk/; I’ve left several suggestions to align pronouns, tone, and wording with the style guide. Please apply the inline suggestions where they make sense for your intent.

Comment on lines +295 to +321
1. to suppress the error; it means "okay, I understand"
1. or reorganize a struct by splitting into multiple cells

Why "potentially exceeds"? Because for many types, their size can vary. For example, `int8?` is either one or nine bits, `coins` is 4..124 bits, etc.

So, given a struct:

```tolk
struct MoneyInfo {
fixed: bits800
wallet1: coins
wallet2: coins
}
```

And trying to serialize it, the compiler prints an error:

```ansi wrap
struct `MoneyInfo` can exceed 1023 bits in serialization (estimated size: 808..1048 bits)
... (and some instructions)
```

Actually, two choices are available:

1. if `coins` values are expected to be relatively small, and this struct will 100% fit in reality; then, suppress the error using an annotation:

```tolk
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[HIGH] First-person “we/I” usage in technical explanations

The overflow-handling guidance includes “to suppress the error; it means 'okay, I understand'”, which introduces an implicit first-person speaker (“I understand”) rather than an objective explanation. Elsewhere, languages/tolk/types/nullable.mdx uses an inline comment “we are sure that a global is set, convert to cell” (around L147–L149), which similarly brings the author and reader into the text. The style guide forbids first-person “I/we” in technical sections, preferring neutral descriptions of assumptions, behavior, and required actions.

Please leave a reaction 👍/👎 to this suggestion to improve future reviews for everyone!

Comment on lines +7 to +8
Tolk language has a magic feature — the `lazy` keyword.
The compiler tracks exactly which fields are accessed, and automatically loads only those, skipping the rest.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[HIGH] Marketing-style “magic” and “powerful” language

The lazy-loading introduction states “Tolk language has a magic feature — the lazy keyword.”, which uses “magic” as hype language instead of describing behavior. Similar marketing phrasing appears elsewhere, such as “The magic lazy keyword loads only required fields…” in languages/tolk/features/compiler-optimizations.mdx (around L230–L244), “The converter may look like magic: any FunC project can be immediately transformed…” in languages/tolk/from-func/converter.mdx (around L8), “The match expression is a powerful 'pattern-matching' feature.” / “It is a powerful construct…” in languages/tolk/syntax/conditions-loops.mdx and languages/tolk/syntax/pattern-matching.mdx (around L5–L8), and “A powerful, but harder to understand solution.” in languages/tolk/features/contract-storage.mdx (around L196–L198). The style guide discourages such subjective marketing terms in technical docs, preferring precise descriptions of behavior or impact.

Suggested change
Tolk language has a magic feature — the `lazy` keyword.
The compiler tracks exactly which fields are accessed, and automatically loads only those, skipping the rest.
Tolk provides the `lazy` keyword for selective loading.
The compiler tracks exactly which fields are accessed, and automatically loads only those, skipping the rest.

Please leave a reaction 👍/👎 to this suggestion to improve future reviews for everyone!

Comment on lines +241 to +242
When a contract accepts an external message, it has a very limited gas amount for execution.
Once a request is validated, remember to call `acceptExternalMessage()` to increase this limit.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[HIGH] Banned intensifier “very” in technical descriptions

The external-message section describes gas limits as “a very limited gas amount for execution”, using “very” solely as an intensifier. The style guide classifies this as a banned hedge/intensifier because it adds emphasis without conveying measurable information. Additional occurrences include “a very limited set of goals” in languages/tolk/features/compiler-optimizations.mdx (around L284), “remains very close to the FunC original” in languages/tolk/from-func/converter.mdx (around L27), and “intN types are very common” in languages/tolk/features/lazy-loading.mdx (around L225). In each case, “very” can be removed or replaced with a more specific qualifier.

Suggested change
When a contract accepts an external message, it has a very limited gas amount for execution.
Once a request is validated, remember to call `acceptExternalMessage()` to increase this limit.
When a contract accepts an external message, it has a limited gas amount for execution.
Once a request is validated, remember to call `acceptExternalMessage()` to increase this limit.

Please leave a reaction 👍/👎 to this suggestion to improve future reviews for everyone!

Comment on lines +35 to +44
There are many ways in which contracts interact.

- sometimes, you "send to an address"
-     ... but sometimes, you have workchain + hash
- sometimes, you compose `StateInit` from code+data
-     ... but sometimes, `StateInit` is a ready cell
- sometimes, you send a message to basechain
-     ... but sometimes, you use a `MY_WORKCHAIN` constant
- sometimes, you just attach tons (msg value)
-     ... but sometimes, you also need extra currencies
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[HIGH] Second-person pronouns in Tolk docs

The bullet list in the “The concept is based on union types” section addresses the reader directly with “you” (“sometimes, you 'send to an address'”), which conflicts with the style rule against second‑person narration for the reader. The same pattern appears elsewhere, such as “if you trust the input and need just to proxy data as‑is” and “Do you need validation…” in languages/tolk/features/jetton-payload.mdx (around L48–L56), “If you are migrating from FunC:” in languages/tolk/overview.mdx (around L49), “Ensure you've called random.initialize…” in languages/tolk/features/standard-library.mdx (around L260–L267), and “If you use RichBounce, that's the way” in languages/tolk/features/message-handling.mdx (around L189). These constructions introduce an implicit narrator–reader relationship instead of neutral or imperative technical guidance.

Please leave a reaction 👍/👎 to this suggestion to improve future reviews for everyone!

Comment on lines +7 to +11
This section summarizes common patterns and conventions used in idiomatic Tolk code.

While [Basic syntax](/languages/tolk/basic-syntax) introduces the language itself,
this page outlines the preferred **ways of expressing ideas** and **best practices** in Tolk.
It may serve as a style reference throughout development.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[HIGH] Throat-clearing “This section/page…” openers

The idioms and conventions page opens with meta-commentary about the document itself (“This section summarizes…”, “this page outlines…”, “It may serve as a style reference…”), which the extended style guide flags as throat‑clearing. Equivalent constructions appear in languages/tolk/syntax/structures-fields.mdx (“This page focuses on syntax details only.” at L6), languages/tolk/syntax/operators.mdx (“This page lists them briefly…” at L6), and languages/tolk/types/list-of-types.mdx (“This section describes all the types…” at L14). These introductions delay substantive content instead of immediately stating what the reader can do or understand.

Please leave a reaction 👍/👎 to this suggestion to improve future reviews for everyone!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

6 participants