v

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

V (Vlang)

V(Vlang)

V (2024 updates) focuses on compilation speed (1 million LOC/s) and safety (Autofree). It aims to be a modern C replacement with Go-like simplicity.
V(2024更新版)专注于编译速度(每秒100万行代码)和安全性(Autofree自动内存管理)。它的目标是成为兼具Go语言简洁性的现代C语言替代方案。

When to Use

使用场景

  • Fast Compilation: Iteration speed of an interpreted language.
  • Graphics:
    v ui
    module provides a cross-platform UI toolkit.
  • No Dependencies: V is a single binary executable.
  • 快速编译:拥有解释型语言般的迭代速度。
  • 图形界面
    v ui
    模块提供跨平台UI工具包。
  • 无依赖:V是单一二进制可执行文件。

Core Concepts

核心概念

Autofree

Autofree

Compiler inserts
free()
calls automatically (experimental/improving).
编译器会自动插入
free()
调用(实验阶段/持续优化中)。

C Interop

C语言互操作

C.printf()
. Direct calling of C functions.
C.printf()
。可直接调用C语言函数。

Option/Result

Option/Result

fn foo() ?int
. Error handling with
or { ... }
.
fn foo() ?int
。通过
or { ... }
进行错误处理。

Best Practices (2025)

2025最佳实践

Do:
  • Use
    v fmt
    : Built-in formatter.
  • Use
    v install
    : Built-in package manager.
  • Cross-compile: V makes outputting C for other platforms easy.
Don't:
  • Don't use globals: V discourages mutable global state.
建议
  • 使用
    v fmt
    :内置代码格式化工具。
  • 使用
    v install
    :内置包管理器。
  • 交叉编译:V可轻松生成面向其他平台的C代码。
不建议
  • 不要使用全局变量:V不鼓励可变全局状态。

References

参考资料