Getting Started With V #17980
hungrybluedev
started this conversation in
Blog
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Introduction
V is a simple, fast, safe, compiled general purpose programming language for developing maintainable software. There are several compelling reasons for using V, which you can learn more about here: The V Programming Language
In this post, we focus on getting new users up to speed so that they can start working with V right away.
Installing (and Updating) V
Since V is in active development, there will be a lot of breaking changes often. Therefore, it is recommended that you install V from the source repository at github.com/vlang/v.
Installing V from Source
It is recommended to go through the steps listed here. Briefly, these are the steps you need to follow:
V compiles itself really fast and requires no dependencies and libraries for self compilation. It ships with TCC by default but it is recommended to install an established C compiler so that you can make optimised builds.
Weekly Release
V makes weekly releases (besides the normal semantic version update releases) if you do not prefer compiling V yourself. You can find the releases here: Releases.
Symlinking
The V executable generated (or obtained) is not automatically added to your
PATH
. V provides a convenient solution to this.If this did not work correctly, refer to the official instructions for more information.
Updating V
Similar to
rustup
, V supports the following command:This command updates the V compiler to the latest version available from the main Github repository.
Learning V
Syntactically, V is similar to Go. Therefore Go devs can feel at home when they write V code. Knowledge of Go is not necessary; the language is very simple and the fundamental concepts can be learned over a weekend.
The official documentation for the language is written in a single markdown document: V Documentation.
The documentation for all the modules included in the V standard library (vlib) is available here: vlib Documentation. You are encouraged to use the search bar to find the functions and structs you need for your project.
For a taste of V, here is a truncated example of TOML file parsing. The sample TOML file is available here: TOML Example
Setting up your Development Environment
Code Editor
As of 2023, Visual Studio Code is still a popular choice in the community. However, the IntelliJ V Plugin for JetBrains IDEs is also well-favoured. For help with other editors, please join our Discord Server.
Running a V Program
Your project should have at least one
main
function. Then you can compile and run your code in one of two ways:v run file.v
orv run directory
. You can even dov run .
to run the onlymain
function in the directory. Note that amodule main
needs to be present at the top of your entry file when you want to execute a directory.v file.v
(optionally asv -prod file.v
) and then run the generated executable.Miscellaneous
You need
git
to clone and update V. Make sure that it is installed on your machine.Additionally, use
v new
andv init
as necessary, and usev fmt -w /path/
to automatically format your source code. Consultv help init
andv help fmt
for more information.Bonus: look at all the tools accessible using the
v
front-end here: cmd/tools.Getting Help and Reaching Out
It is recommended that you make frequent use of
v help
, consult the language documentation and the modules documentation. If you want to get specific help, reach out to us directly, or just hang out with the V community members, join our Discord Server. Use the appropriate channels for your needs.While developing in V, you may encounter bugs. Please report them in the
#bugs
channel, and file Github issues about them withv bug file.v
.Beta Was this translation helpful? Give feedback.
All reactions