Go v 语言基于 c 后端的六大好处

chenge · 2021年10月29日 · 最后由 tablecell 回复于 2021年11月05日 · 654 次阅读

大概是如下六大好处:使用 c 是完全有效的,容易启动开发依赖少,c 是好平台,工具链,稳定, 简单(不像 LLVM 依赖 c++)

通常听说是用 LLVM 一种虚拟机后端,不知道 go 和 rust 是如何的。

再八卦一下,五年前我预测 elixir 会进入主流,结果没有实现,不过并没有完全看走眼。 今天再预言一下 v 语言五年内进入主流,看这次能否说准。

原文,发文的应该是作者本人 Alex。

vlang 官网

“ 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. ”

生成到 C 不也得依赖一个 C 编译器吗?这和 LLVM 的所谓依赖 C++ 不是一个概念

ecnelises 回复

c++ 可是要复杂得多吧。

elixir 是个好东西,但是生不逢时,恰好赶上容器化时代,很多 erlang 的解决方法其他方式也能实现,另一方面 ruby 开发者大多数场景 ruby 够用,追求性能可能直接学习 golang 了,能力和运气缺一不可啊😂

EvanYa 回复

golang 有明显的弱点,刚看一个调查,抱怨最多的是错误处理。v 语言语法是模仿 go 语言的,感觉对比而言 v 语言要愉快的多。

ubuntulinux 回复

vala 影响力小多了,主要针对 gnome,不太了解。v 是基于 go、rust 改进的,更现代吧。

ubuntulinux 回复

Vala 这是要 pk c++

需要 登录 后方可回复, 如果你还没有账号请 注册新账号