大概是如下六大好处:使用 c 是完全有效的,容易启动开发依赖少,c 是好平台,工具链,稳定,简单(不像 LLVM 依赖 c++)
通常听说是用 LLVM 一种虚拟机后端,不知道 go 和 rust 是如何的。
再八卦一下,五年前我预测 elixir 会进入主流,结果没有实现,不过并没有完全看走眼。 今天再预言一下 v 语言五年内进入主流,看这次能否说准。
原文,发文的应该是作者本人 Alex。
“ Using a C backend is a completely valid strategy (for example, the first C++ compiler Cfront did exactly this). C can be viewed as a modern cross-platform assembly language. To the end-user, it doesn't really matter what intermediate step is used to generate their binary, as long as it works, and the performance is good.
Easy bootstrapping and development. To bootstrap V, you need to download v.c and run cc v.c. That's it. No dependencies, no bootstrapping chains, nothing. The developers of the language don't need to work on two parallel implementations, new features can be introduced and used in the language right away. V has been 100% written in V since the release.
C gives us amazing platform support. C runs on everything, literally everything. LLVM supports lots of platforms and architectures, but it will never beat C. Being able to run V software on everything that C supports is huge.
Great tooling. Warnings, static analyzers, Valgrind, etc help to ensure that everything is correct. Writing programs that pass -Wall -pedantic, Clang analyzer, PVS, and result in zero Valgrind warnings/errors is a dream of any C/C++ developer. With V it's going to be guaranteed for every V program. (We are not there yet, but very close.)
Stability. New languages using LLVM directly are going to crash often. That's inevitable, and can be seen across all new languages using LLVM. Major C compilers like Clang/GCC/MSVC are very stable and are highly unlikely to result in crashes when compiling C code generated by V. The V compiler hasn't crashed once for me, and I haven't received any crash reports from other users.
Simplicity. LLVM is a huge C++ dependency, meaning that both developers of the language and the users are forced to install it. Calling C++ is not easy from V/C, so C wrappers have to be used, increasing the number of dependencies and complexities. ”