“If Go and Rust had a baby it would be this language. Grandpa C should be proud.”
“如果Go和Rust有一个孩子的话,那应该就是V,他的爷爷C也挺自豪有这么一个孙子。”
rust我很喜欢,虽然go没用过,vlang的语法个人感觉比go舒服一点,博采众家之长。
尽管有不少的人认为没有银弹,对Vlang提出了很多质疑。但是新的事物(目前是v0.2)还是要鼓励的。
初步看了一下,vlang的确有很多可取之处。快,简洁,也相对安全。学习成本很小,我感觉1个小时左右的确是可以上手。属于那种可以边看,边上手的那种。
今天就来试一下vlang,当一个FLAG,让我们期待vlang的进一步发展,能得到更多的支持。
进一步资料可以 参考:
https://github.com/vlang/v/blob/master/doc/docs.md#sum-types
安装环境
songroom@DESKTOP-MEDPUTU:~$ git clone https://github.com/vlang/v
Cloning into 'v'...
remote: Enumerating objects: 114041, done.
remote: Counting objects: 100% (10/10), done.
remote: Compressing objects: 100% (10/10), done.
remote: Total 114041 (delta 0), reused 3 (delta 0), pack-reused 114031
Receiving objects: 100% (114041/114041), 49.81 MiB | 38.00 KiB/s, done.
Resolving deltas: 100% (81370/81370), done.
songroom@DESKTOP-MEDPUTU:~$ cd v
songroom@DESKTOP-MEDPUTU:~/v$ make
songroom@DESKTOP-MEDPUTU:~/v$ make
cd ./vc && git clean -xf && git pull --quiet
cd ./thirdparty/tcc && git clean -xf && git pull --quiet
cc -std=gnu99 -w -I ./thirdparty/stdatomic/nix -o v1.exe ./vc/v.c -lm -lpthread
./v1.exe -no-parallel -o v2.exe cmd/v
./v2.exe -o ./v cmd/v
rm -rf v1.exe v2.exe
Your `tcc` is working. Good - it is much faster at compiling C source code.
V has been successfully built
V 0.2.4 0cc6310
建立软链接:
songroom@DESKTOP-MEDPUTU:~/v$ ls
CHANGELOG.md CONTRIBUTING.md Dockerfile.alpine GNUmakefile Makefile ROADMAP.md cmd examples thirdparty v vc
CODE_OF_CONDUCT.md Dockerfile Dockerfile.cross LICENSE README.md TESTS.md doc make.bat tutorials v.mod vlib
songroom@DESKTOP-MEDPUTU:~/v$ pwd
/home/songroom/v
songroom@DESKTOP-MEDPUTU:~/v$ sudo ln -s /home/songroom/v/v /usr/local/bin/v
测试一下:
songroom@DESKTOP-MEDPUTU:~/v$ v
____ ____
\ \ / / | Welcome to the V REPL (for help with V itself, type exit , then run v help ).
\ \/ / | Note: the REPL is highly experimental. For best V experience, use a text editor,
\ / | save your code in a main.v file and execute: v run main.v
\ / | V 0.2.4 0cc6310
\__/ | Use Ctrl-C or exit to exit, or help to see other available commands
>>>
IDE方面:
vscode下安装:
可以随意写一个脚本:
也可写一个main()
都可以很方便运行。感觉到python的轻巧。
感觉又回到了动态脚本时代。
看看并发,也非常方便:
包管理:v install ,也比较简洁。
其它:
Vlang还刚开始,很年青,初生牛犊。期待 Vlang可以走得越来越远,生态进一步强大。