This blog post showcases V in a positive light. I suppose it is good that people can have productive experiences with it now, although I don't see from this post why it is a significant improvement on Go.
The problems discussed (performance, compiler fragility) are somewhat worrying though. My impression is still that V is not particularly robust and focuses on flashy things instead of getting the basics right. I must admit that it is however still hard to look at V objectively, given the near-fradulent presentation it had when it was first announced.
"near-fradulent presentation it had when it was first announced"?
It's not just in the past, the lies are still here. A very simple to explain example: https://vlang.io/ proudly says "No null (allowed in unsafe code)", while going to V playground and typing
x := []&int { len: 10, cap: 0 }; println(x[4])
still prints "&nil" (note how there is no unsafe in sight).
The V team are either intentionally misleading people or have only vague idea about how languages are designed. Stay away.
Such code will generate warnings, "arrays of references need to be initialized right away, therefore `len:` cannot be used (unless inside `unsafe`, or if you also use `init:`)". By the way, the other optional parameter, besides `len` and `cap`, is `init` (in the documentation too). The person is being told to use unsafe or do something else.
Warnings are given to allow the programmer to experiment or solve by other methods. Beta means language still in development. Lastly and for V, the warnings mean that in production mode (-prod flag), that kind of code will not compile.
When comparing V and Golang, I feel like V serves as a warning for why the Go maintainers say "No" so often. You can see the author being weirdly confused both by bugs and ambiguity in the language.
> This is a double-edged sword, with Go, you get what you got. With V, I got what I got but I wonder if what I got can be gotten differently.
I have used both Go (extensively) and V (not so much). Go's cross compilation, concurrency support, GC & stability are much better than V's. V compiles much much faster in spite of generating C (unless you use clang), plays better with C, its syntax choices seem better (default to const, less onerous error handling, sum types, option type, not relying on Capitalization for exporting etc.), optional GC (though far from perfect), etc. I can see writing an OS in V (but not in Go). I am in two minds about whether it should try to simulate concurrency like Go does (goroutines are coroutines, mapped to system threads only for blocking syscalls) as that might not be the right choice for kernel level code.
V hasn't had the resources or backing that Go continues getting. Most of its work is done by volunteers. AFAIK it hasn't had the benefit of the experience of multiple world class programmers like Go's designers. Good language design also involves leaving out features and that involves discussing or experimenting with such features. IMHO V can use more of that. But so far I like a lot of what I see in V.
The article author, Kris Tun, agrees you - "I like V a lot. The abstraction over the syntax is so nice that made me enjoy writing the syntax as a whole. It makes me wish that Go could do more with what they have, but you and I know that Go would never."
What also comes across is his open-mindedness and enthusiasm for the language. There have been many Golang developers, including those who created and joined the V (Vlang) project, that wanted particular features. After being able to get what they wanted, they are happy about it.
This is interesting. It's good to read up-to-date impressions of V, considering its shaky beginnings. This describes a more positive experience from mine about a year ago, which is a good sign. I remember running into similar weird errors and undefined behavior, which really put me off from the language.
The problems that V is trying to solve aren't something I find to be dealbreakers with Go. I'm fine with Go's syntax, error handling, lack of bells and whistles, enums, and so on. In fact, I've learned to appreciate the brutalist simplicity of its design. What I do need is a language that is robust, well defined according to its specification, and performs well at most tasks. Go excels at these, while V fumbles at all of them.
How much longer can we excuse these issues on account of it being a young language? V is 6 years old now, yet these issues still exist. The authors and community seem to prioritize writing text editors, kernels, and operating systems over addressing these core issues. And, frankly, I don't trust that things will improve with the current leadership, so I'll continue to stay away and write boring Go code.
> I'm fine with Go's syntax, error handling, lack of bells and whistles, enums, and so on. In fact, I've learned to appreciate the brutalist simplicity of its design.
Assembly language is going to blow your mind; it lacks even more features than Go.
Actually not, if you look into powerful macro assemblers from Amiga/PC heritage, they might even do stuff, Go's designers keep considering as language fluff.
On one hand, I think there needs to be an applications programming language that's both fast, statically typed, and minimalistic (like C). C# and Java are unwieldy and carry too much baggage. I hoped Go would be that language. Unfortunately Go's weird choice to use green threads and channels made it very difficult and slow to interop with native code, especially desktop frameworks, which usually rely on a pumped message loop. V was supposed to be that language, that keeps the excellent syntax, but replaces much of the weirdness with much more convenient stuff, while adding a few extra features.
I first learned of V after reading the hit piece someone wrote on it, which has formed the majority of people's opinion's on the language. Back then I though most of the criticisms were unnecessarily harsh and belligerent, most of it boiling down to the compiler/stdlib having bugs, and one asserting that it's 'autofree' implementation leaked memory, based on an incorrect understanding of how valgrind and C memory management works.
I decided to get the truth for myself, and delve into the V language source code (after all, it's up on github). Oh boy.
- The 'compiler' itself doesn't seem to have a a codegen backend, it just produces C code, with every code generation call essentially becoming a stringbuilder concat pushing C code into a buffer. So it's more of a transpiler than a compiler.
- The compiler's code is very worrying - commented out snippets of code, TODOs like 'TODO: this isn't supposed to be null here' over a stray if statement
- The vaunted 'autofree' which (to be fair never claimed to be 100% effective, relying on GC for cases it can't figure out) is just checking objects allocated in the function scope, and frees them at the end of scope. (to be fair, autofree seems to have been deprioritised)
While it works in some cases (including the original critical post where it claimed to fail), and I don't pretend to understand all the nuances of the compiler, I feel like the engineering behind this project is somewhat unsound.
It's super impressive just how much stuff they managed to do over the past few years, and I think a simple and pragmatic desktop language (that produces small binaries, has few dependencies and is easy to write and read) is still needed, I'm kinda reluctant to give V that role until the engineering behind it becomes more solid.
I don't think it's fine the way V does it. What V's compiler is essentially doing is that it parses the V code into an AST, then it walks the AST and tries to generate an equivalent C code on the fly:
How a proper compiler should work (and how they actually do from what I've seen), is that they first take the AST, try to remove all fancy syntatic sugar by converting it to simpler constructs, and then they generate an intermediate representation that's either stack, or SSA based. It might skip the lowering of syntatic sugar, and generate IR directly. At some point either on the AST, or the IR, you might want to do control or data flow analysis to support some of your features.
From that point on, the backend generates either LLVM IR, C or might even attempt to generate machine code itself.
The problem with targeting C is that you lose access to stuff not accessible in C, like precise variable tracking on the heap/stack (needed for a good GC), or unwinding support needed for exceptions.
While I do like Zig, I would prefer automatic memory management for most application code. My priorities there are spending the least amount of effort and complexity on solving the problem, while ensuring the created code is both bug-free and maintainable, and am willing to give up some performance for that compared to raw C speed.
Zig seems to be a step back in that manner, even compared to C++ which at least has unique_ptr/shared_ptr.
For Pascal variants, way back when I used to enjoy writing Delphi, I think it was a great language, however I haven't been keeping up with the Pascal world.
Well clearly not everyone agrees with that position. Everybody has a preference, with various people also saying terrible things about Golang or whatever language. Possibly the better position is that people have options to choose from versus having viable options forcibly or sneakily removed.
The problems discussed (performance, compiler fragility) are somewhat worrying though. My impression is still that V is not particularly robust and focuses on flashy things instead of getting the basics right. I must admit that it is however still hard to look at V objectively, given the near-fradulent presentation it had when it was first announced.
It's not just in the past, the lies are still here. A very simple to explain example: https://vlang.io/ proudly says "No null (allowed in unsafe code)", while going to V playground and typing
still prints "&nil" (note how there is no unsafe in sight).The V team are either intentionally misleading people or have only vague idea about how languages are designed. Stay away.
Warnings are given to allow the programmer to experiment or solve by other methods. Beta means language still in development. Lastly and for V, the warnings mean that in production mode (-prod flag), that kind of code will not compile.
Last I heard in 2024, the situation has not improved
https://news.ycombinator.com/item?id=39503446
> This is a double-edged sword, with Go, you get what you got. With V, I got what I got but I wonder if what I got can be gotten differently.
Dead Comment
V hasn't had the resources or backing that Go continues getting. Most of its work is done by volunteers. AFAIK it hasn't had the benefit of the experience of multiple world class programmers like Go's designers. Good language design also involves leaving out features and that involves discussing or experimenting with such features. IMHO V can use more of that. But so far I like a lot of what I see in V.
What also comes across is his open-mindedness and enthusiasm for the language. There have been many Golang developers, including those who created and joined the V (Vlang) project, that wanted particular features. After being able to get what they wanted, they are happy about it.
The problems that V is trying to solve aren't something I find to be dealbreakers with Go. I'm fine with Go's syntax, error handling, lack of bells and whistles, enums, and so on. In fact, I've learned to appreciate the brutalist simplicity of its design. What I do need is a language that is robust, well defined according to its specification, and performs well at most tasks. Go excels at these, while V fumbles at all of them.
How much longer can we excuse these issues on account of it being a young language? V is 6 years old now, yet these issues still exist. The authors and community seem to prioritize writing text editors, kernels, and operating systems over addressing these core issues. And, frankly, I don't trust that things will improve with the current leadership, so I'll continue to stay away and write boring Go code.
Assembly language is going to blow your mind; it lacks even more features than Go.
On one hand, I think there needs to be an applications programming language that's both fast, statically typed, and minimalistic (like C). C# and Java are unwieldy and carry too much baggage. I hoped Go would be that language. Unfortunately Go's weird choice to use green threads and channels made it very difficult and slow to interop with native code, especially desktop frameworks, which usually rely on a pumped message loop. V was supposed to be that language, that keeps the excellent syntax, but replaces much of the weirdness with much more convenient stuff, while adding a few extra features.
I first learned of V after reading the hit piece someone wrote on it, which has formed the majority of people's opinion's on the language. Back then I though most of the criticisms were unnecessarily harsh and belligerent, most of it boiling down to the compiler/stdlib having bugs, and one asserting that it's 'autofree' implementation leaked memory, based on an incorrect understanding of how valgrind and C memory management works.
I decided to get the truth for myself, and delve into the V language source code (after all, it's up on github). Oh boy.
- The 'compiler' itself doesn't seem to have a a codegen backend, it just produces C code, with every code generation call essentially becoming a stringbuilder concat pushing C code into a buffer. So it's more of a transpiler than a compiler.
- The compiler's code is very worrying - commented out snippets of code, TODOs like 'TODO: this isn't supposed to be null here' over a stray if statement
- The vaunted 'autofree' which (to be fair never claimed to be 100% effective, relying on GC for cases it can't figure out) is just checking objects allocated in the function scope, and frees them at the end of scope. (to be fair, autofree seems to have been deprioritised)
https://github.com/vlang/v/blob/master/vlib/v/gen/c/autofree...
While it works in some cases (including the original critical post where it claimed to fail), and I don't pretend to understand all the nuances of the compiler, I feel like the engineering behind this project is somewhat unsound.
It's super impressive just how much stuff they managed to do over the past few years, and I think a simple and pragmatic desktop language (that produces small binaries, has few dependencies and is easy to write and read) is still needed, I'm kinda reluctant to give V that role until the engineering behind it becomes more solid.
V has plenty of other issues, though.
https://github.com/vlang/v/blob/master/vlib/v/gen/c/match.v
How a proper compiler should work (and how they actually do from what I've seen), is that they first take the AST, try to remove all fancy syntatic sugar by converting it to simpler constructs, and then they generate an intermediate representation that's either stack, or SSA based. It might skip the lowering of syntatic sugar, and generate IR directly. At some point either on the AST, or the IR, you might want to do control or data flow analysis to support some of your features.
From that point on, the backend generates either LLVM IR, C or might even attempt to generate machine code itself.
The problem with targeting C is that you lose access to stuff not accessible in C, like precise variable tracking on the heap/stack (needed for a good GC), or unwinding support needed for exceptions.
While at it, does Zig fit this bill? (Or, haha, Free Pascal / Lazarus, if we talk about desktop software.)
Zig seems to be a step back in that manner, even compared to C++ which at least has unique_ptr/shared_ptr.
For Pascal variants, way back when I used to enjoy writing Delphi, I think it was a great language, however I haven't been keeping up with the Pascal world.
Lazarus always looked good, so there's probably value there if having a GC isn't an issue.
(!) it is my opinion, I am going from robust principles and foundations; that's not everyone
Another disclaimer: I like Go but i'm not a diehard fan; I will always be common lisp until I die. We all have taste/opinion.
Deleted Comment