3 ms·
I think the critical thing of V, which article only mentions in passing, is it's "Fake it till you make it" philosophy. For me, this completely kills any intere
by theamk 1y ago
I think the critical thing of V, which article only mentions in passing, is it's "Fake it till you make it" philosophy. For me, this completely kills any interest I might have in the language.
In particular, many people close to the language make great-sounding claims, which are simply not true.
An example: if you go to https://vlang.io/ https://vlang.io/, right there in "Safety" section, it mentions "No null (allowed in unsafe code)"
So you might think: great! This sounds like Rust but without all the tedious errors, I hate null pointer exceptions! But turns out this is pretty much a lie, there may be no "null" keyword, but it's not that hard to get it. Go to https://play.vlang.io/ https://play.vlang.io/, enter the program and press "run":
x := []&int { len: 10, cap: 0 }
println(x[4])
flush_stdout()
println(*x[4])
I just this run this and got the response:
&nil
/box/code.v:4: at main__main: RUNTIME ERROR: invalid memory access
/tmp/v_60000/code.01JVGJG6KBEYKWAMZZR4YPHR0S.tmp.c:10807: by main
Exited with error status 255
that sure looks like a null to me (except spelled "nil").. and behaves as it was a null too. And no "unsafe" in sight!
Would you trust the language which outright lies about the basic features on its own front page? I certainly would not recommend so.
(Alternative interpretation is that this was not an intentional lie, but rather that language designers never thought how "no null" and "can create array of pointers without unsafe" rules would interact together.. That's even worse IMHO)
- baranul 1y ago"Null" is not used in "proper" V. It's not a keyword assigned to any variables, outside of unsafe, and even that is strongly discouraged. Additionally, all variables in V have to be initialized with some value and the required memory (which leads to the error from cap being set to 0). V can compile to C, including native (still in development) and other languages (WASM, JavaScript...), so depending on what someone is doing they can see related error messages. Additionally, there is the circumstance of keeping compatibility with other languages. This is why V has "nil", which is explained in the documentation, but its their objective to eliminate or contain its usage to only unsafe. From their documentation- "Zero-value references, or nil pointers, will NOT be supported in the future...". Users of V would be familiar with the circumstances and context, to include seeing examples of proper usage.
- theamk 1y agoI have no objection to Vlang having "null", after all many languages have it. My problem is the outright lies on the front page. Someone who is looking into Vlang might actually believe what's written on the front page, spend some time learning language, and come up disappointed. So I am saving them some time by warning them in advance. And no, if you that using null is V is "improper", this still means V has nulls. If the it will not have nulls "in the future", it means it still has nulls today. The front page does not mention any "future" part. And mentioning that you cannot assign it to any variables outside of "unsafe" is outright wrong.. It works just fine, it's just spelled differently (as "voidptr(0)"). Try it yourself in playground: ptr := &int(voidptr(0)); println(*ptr); The thing is, there are plenty of languages without "null" - Rust of course, but also much more "conventional" languages like Kotlin and Swift. So we know what language-without-nulls looks like - there are nullable and non-nullable pointer-things (they may be called using different terms), they are distinct types, and you need a special ceremony to access nullable pointer-things where you specify what to do if the value is null/missing. Vlang does not have anything like that, and it's trivially easy to get the null pointer (either intentionally or from trivial programming error) in safe code.