Hacker News new | ask | show | jobs
by option_key 1455 days ago
>"As fast as C" is not a lie. It literally translates to C.

No, just because it outputs C it doesn't mean it's as fast as hand-written C. Using that logic, every language that outputs machine code is as fast as assembly, which is obviously not true.

2 comments

If you look at the C that's generated using -keepc flag, I think you will be hard pressed to find any glaring inefficiencies to "hand coded C"; especially none of which GCC optimization wouldn't handle with -prod compiler flag. Even if there were, for the very large majority of users who are not highly proficient in C (which is becoming more and more common these days - Grey beards are rare), the V way is going to outperform novice to intermediate-skilled C programmers hands down.
I don't see how that really follows. V heap allocates any value which is address taken. You don't need to be an advanced C programmer to use pointers.
But it is true. V doesn't add any overhead. You can verify with `v -o file.c file.v`.

As long as you use the same data structures and algos, you'll get the same perf.

There's stuff like bounds checking, but it can be disabled, and it adds like 5%.