Welcome to the complete Zero-to-Hero tutorial for Vlang! This guide covers everything from basic variables to advanced concurrency and standard library usage.
The repository is organized by learning progression, so it is easier to move from beginner concepts to more practical application topics:
- Foundations:
variables_and_constants/,primitive_types/,control_flow/, andfunctions/ - Data and program design:
structs/,error_handling/,modules/, andtesting/ - Applied topics:
concurrency/,channels/,json_and_orm/,sqlite/, andnotes_api/- Reference material:language_updates_and_stdlib/now has a clearer split between newer language features and grouped standard library examples This structure makes it easier to jump straight to the concept you want to study and to understand how the topics build on one another.
- Start with the foundational folders to learn the core syntax and mindset.
- Move to data modeling and correctness topics once the basics feel comfortable.
- Finish with the applied examples to see V used in real-world style programs.
- Keep each topic in its own folder.
- Use numbered lesson folders such as
01_topic_name/and02_topic_name/for consistency. - Add a short explanation or README when a topic needs more context.
- Keep examples runnable and focused on one idea at a time.
Tip
Interactive Viewer: Read this guide and other tutorials as a responsive HTML site on the Markdown Tutorials Live App (source code available in the GitHub Repository).
Note
Enhanced HTML Textbook Version: We now include a premium, interactive HTML documentation site compiled locally from this guide. You can read it live at codefreelance.net/apps/vlang.html or open it locally at docs/index.html. It features a collapsible navigation tree, dynamic search filters, dark/light/cyberpunk theme togglers, and interactive links to run code examples in the V Playground with automatic code loading.
V is a statically typed, compiled programming language designed for building maintainable, highly performant software. It shares similarities with Go and is influenced by Rust, Swift, and Julia.
- Zero Dependencies: The entire language, compiler, and standard library have no external dependencies. Everything you need is compiled into a single, clean codebase.
- Extreme Compilation Speeds: V compiles to native C code (and from there to machine code) or directly to machine code/WebAssembly in under a second. Rebuilding the entire V compiler itself takes less than 1.5 seconds.
- Safety: Immortality by default (no globals, immutable variables, immutable struct fields by default), bounds checking, no null pointers, and strict control over variable scopes.
- No Heavy Runtime: V compiles directly to native binaries without a Virtual Machine (VM), interpreter, or heavy runtime library. Resulting executables are extremely lightweight (usually < 1MB).
| Scenario / Goal | Choose V when... | Choose Go when... | Choose Rust when... | Choose C when... |
|---|---|---|---|---|
| Lightweight CLI Tools | Highly Recommended. Tiny binaries, instant startup, zero dependencies, easy arguments/flags parsing. | Binaries are larger (~5-15MB) and startup is slightly slower due to GC. | Great, but development speed is slower and setup is more complex. | Good, but lack of modern string handling and collections makes it tedious. |
| Fast-Booting Microservices | Excellent. Low memory overhead, instant boot (ideal for Serverless/Docker environments). | Excellent standard library, but higher memory footprint and GC pauses. | Excellent performance, but longer compilation cycles and steeper learning curve. | Too low-level, unsafe web-facing library ecosystem. |
| Embedded & Systems | Excellent. Easily compiles to C, runs on bare-metal or resource-constrained boards. | Not suitable due to garbage collector and runtime footprint. | Excellent. Safe concurrency and hardware control, though more complex. | The classic choice, but lacks V's safety guards against memory corruption. |
| Desktop GUI Apps | Excellent. Built-in gg graphics library and simple Webview bindings. |
Not ideal; lacks first-class native desktop GUI support. | Possible, but complex ecosystem. | Possible, but extremely verbose and unsafe. |
This tutorial and all code examples have been updated and tested for V version 0.5.1.
If you are using an ARM-based Mac (Apple Silicon) and installed V via Homebrew, you may encounter standard library resolution issues when using the v-analyzer extension in VSCode or the Antigravity IDE. To fix this, you need to point the analyzer to the correct V root directory.
Update your v-analyzer settings (typically in a config.toml or IDE settings) to set the custom_vroot to the Homebrew installation path (e.g., /opt/homebrew/Cellar/vlang/0.5.1/libexec/v or /opt/homebrew/opt/vlang/libexec/v). This ensures the analyzer correctly locates the vlib standard library.
Important
Vlang Textbook Learning Guide & Code Examples All code examples and detailed, step-by-step programming lessons have been moved to the dedicated textbook guide: The V Programming Language: A Comprehensive Textbook Guide.md (or vlang-complete-guide.md).
Please use The V Programming Language: A Comprehensive Textbook Guide.md (or vlang-complete-guide.md) as your primary resource for learning V, as it features a structured, school-book syllabus designed specifically for new and experienced developers alike.
For comprehensive and up-to-date information about V, please refer to:
- Interactive HTML Guide (Live Web Version) - Read the compiled guide online on the web.
- Interactive HTML Guide (Local Version) - The premium, interactive HTML version of this textbook with built-in search, theme togglers, and V Playground integration.
- V Official Documentation - Complete reference guide for the V programming language.
- Vlang Complete Guide - Comprehensive textbook and learning guide for V.
- Markdown Tutorials Live App - Interactive HTML viewer featuring this Vlang guide alongside other programming tutorials (GitHub Repository).
The interactive HTML guide integrates directly with the V Playground:
- Run in Playground: Pre-loads the specific V code block directly into the playground editor using the
base64query parameter. - Copy & Open: Copies the V code block to your clipboard and opens the playground pre-loaded with the exact code snippet.
If you update The V Programming Language: A Comprehensive Textbook Guide.md, you can recompile the interactive HTML version at any time by running:
node build.js