
The V language now compiles itself in 0.09 seconds - amedvednikov
https://github.com/vlang/v/wiki/The-V-language-now-compiles-itself-in-0.09-seconds
======
rishav_sharan
Last time when V was presented in HN, it got completely ripped apart by most
posters. This was probably due to the many empty promises by the creator which
V simply wasn't able to deliver on. There were also hard criticisms posted by
creators of other languages like Zig, wren etc.

I want to know from V's critic, where do they feel the language is right now,
now that it has had some more months behind it? Do you still feel that its a
lot of snake oil or do you think it is going along a good path? Not trying to
push an agenda but I am genuinely curious because I have never seen such
definitive opinions against a language before in HN.

I am yet to use V (waiting for the Doom demo which would be the proof of the
pudding for me), but i do check its chat and github every now and then; and
things seem to be going along much better now. lots of contributions, better
project management and timely fixes.

Here are some of the older threads on V;

[https://news.ycombinator.com/item?id=19403271](https://news.ycombinator.com/item?id=19403271)

[https://news.ycombinator.com/item?id=20250990](https://news.ycombinator.com/item?id=20250990)

[https://news.ycombinator.com/item?id=20229632](https://news.ycombinator.com/item?id=20229632)

~~~
amedvednikov
Soon I'll actually make a post covering all these "vaporware"/scam posts and
articles.

Zig's author's criticism is hard to respond to, since he claims things like
"the V compiler has freetype and glfw dependencies", which is absurd:

[https://news.ycombinator.com/item?id=20230351](https://news.ycombinator.com/item?id=20230351)

Also he claimed there was no REPL, cross compiling or hot code reloading, when
all these things were there:

[https://twitter.com/i/status/1137537130887077890](https://twitter.com/i/status/1137537130887077890)

[https://twitter.com/i/status/1153363259715702784](https://twitter.com/i/status/1153363259715702784)

~~~
kdmccormick
TBH the main criticism seems not to be of the language itself, which seems
like a cool and worthwhile project, but of its "marketing".

Clickbaity rhetoric like "V Language Released" with no source code and many
missing features, and now "compiles itself in _stunning_ 0.09 seconds" without
a rigorous dataset or accompanying list of features that said compiler
supports are likely the source of the backlash.

My outsider advice, as someone who has never made a language (so, props to you
for that) is to lower the hype level, and instead focus on posting news like
deep-dives into design decisions and implementation stories, which people in
the PL community are more likely to appreciate.

~~~
amedvednikov
What do you mean no source code?

I think 0.09s compilation is pretty cool, I worked a lot to make it happen,
and I'm excited to share it.

~~~
kdmccormick
What I mean is that when it was announced that "V Programming Language is
Released", it was just binaries and no source code:
[https://news.ycombinator.com/item?id=20229632](https://news.ycombinator.com/item?id=20229632)

There's nothing wrong with releasing the binaries, but a more genuine headline
might've been like "V Language: Alpha Compiler Binary Preview".

And the 0.09 second compilation is really cool! But a more genuine headline
would've been "I got V to compile itself in 0.09 on my computer".

If you think I'm ranting or nit-picking, so be it. But my experience in
software development is that exaggeration leaves a bad taste in people's
mouths, and could harm the reputation of your otherwise really interesting
language project.

~~~
amedvednikov
This was posted by someone else, I never announced it. Never saw this post.

The binaries were released 2 days before the source code, which was a weird
decision. I never realized literally tens of thousands were following my every
move. I'd be more careful then.

~~~
kdmccormick
That is fair.

You've piqued a lot of interest, and now a lot of people are following your
every statement. I can imagine that managing those people's expectations isn't
trivial.

Best of luck! Looking forward to 1.0

~~~
amedvednikov
Thanks!

------
curuinor
How many of Dodrill's problems have they solved so far?

[https://christine.website/blog/v-vaporware-2019-06-23](https://christine.website/blog/v-vaporware-2019-06-23)

~~~
kstenerud
Wow... talk about a mean-spirited article!

~~~
amedvednikov
Yeah basically complaining that WIP features explicitly marked as WIP are not
ready and that the first public alpha release is not stable.

Focusing on the fact that the language is written 100% in itself from the
start? Nope!

Mention that it builds itself in <1 second? Nah

Graphics library, DOOM's p_enemy.c translated to p_enemy.v which can be
compiled and replace p_enemy.o, safety features? No.

The language can be bootstrapped with "cc v.c" without any dependencies? Who
cares!

There's a temporary one-line os.system() hack? VAPORWARE!

~~~
chubs
`p_enemy.c translated to p_enemy.v which can be compiled and replace
p_enemy.o` <\- that's extremely impressive, good on you! :)

~~~
amedvednikov
Thanks.

Here's how it looks like, although it doesn't compile at the moment:

[https://github.com/vlang/doom/blob/master/p_enemy.v](https://github.com/vlang/doom/blob/master/p_enemy.v)

I have to finish this project asap.

------
NiekvdMaas
V is a pretty interesting language. I've been playing with it for the last few
months, it takes a lot of the good stuff from Go with saner syntax and
defaults. And compilation speed is amazing.

The big missing item so far is GC (memory management is manual). Another thing
is that the language evolves constantly, so you keep having to change your own
code every week or so to stay valid.

~~~
amedvednikov
Indeed, the language changes very quickly. Things will stabilize by 0.2.

The memory model is going to be similar to Rust. No GC or manual management.
I'm actually working on it right now. Should have done it sooner, but it took
me lots of time to do the research and chose the right model.

~~~
Yoric
I'm very curious about this.

Getting the Rust compiler to handle memory correctly took years one complete
refactoring of the type system, and a number of less major changes before Rust
reached version 1.0. Even after that, the borrowing system has regularly been
refined to become gradually more intuitive and more powerful.

Do you have precise plans for this feature? If they're written somewhere, I'm
quite interested :)

~~~
delian66
Pioneering is nearly always harder, and takes more time than later
developments.

------
verroq
That Go code on this page [0] isn't particularly idomatic (or even
functional), consider something like this [1] perhaps.

[0] [https://vlang.io/compare](https://vlang.io/compare)

[1] [https://pastebin.com/raw/FsjAQvGt](https://pastebin.com/raw/FsjAQvGt)

~~~
Thorrez
That return err from the goroutine looks wrong, I don't think the error is
ever used. log.Fatalln(err) would keep the behavior of the V code.

~~~
verroq
It'd just cause a panic and stop that particular goroutine. To properly handle
it, it needs to be passed back into a results channel or something. Generally
we don't intentionally cause panics in go code as a matter of style.

You can insert a `defer log.Println(err)` if you want to handle that
particular error but I didn't bother.

~~~
Thorrez
log.Fatalln() does an os.Exit(1), it doesn't just cause that particular
goroutine to stop[1]. log.Panicln() will also cause the entire program to exit
unless there's a recover[2].

log.Println(err) would be better than returning err, because returning err
makes people wrongly think the error is being handled somewhere, when in
reality nothing is looking at the return value. Using defer for that seems a
bit strange though.

[1]
[https://play.golang.org/p/wwiq1bYjwVH](https://play.golang.org/p/wwiq1bYjwVH)

[2]
[https://play.golang.org/p/MpzafFlBSfx](https://play.golang.org/p/MpzafFlBSfx)

------
chaz6
V looks like a promising language. You know you have made it when there is an
"awesome v" page on github. One question, why is the original `v` much smaller
than the `v` compiles using itself?

    
    
      $ size v
         text    data     bss     dec     hex filename
       445817    1032     688  447537   6d431 v
    
      $ ./v -o v2 v.v && size v2
         text    data     bss     dec     hex filename
       651086   51000    1000  703086   aba6e v2

~~~
amedvednikov
It's built with GCC and -O2.

------
delian66
Wow, on my old i3:

    
    
        0[08:48:16] /v/v $ time ./v v.v
       
        real    0m0.219s
        user    0m0.153s
        sys     0m0.064s
        0[08:48:25] /v/v $
    

I guess it is high time to upgrade my machine...

------
chousuke
I think I might have to try v for scripting. I've been wanting a non-dynamic
language for that purpose, and v having few dependencies and fast compile
times might actually make it usable for that purpose.

------
teggot
Like a contributor I can say that @amedvednikov make a big effort to make such
compilation speed possible. Also I can say that language is still easy to
learn while having so many features.

~~~
amedvednikov
Well I wouldn't say the language itself has many features.

Its goal is to be minimalistic, simple, readable, maintainable.

------
a1pulley
Pleased to read that hot reloading is a central feature!

~~~
amedvednikov
Yes, really excited about it.

Hot reloading UI:

[https://cdn.discordapp.com/attachments/592118040179507207/63...](https://cdn.discordapp.com/attachments/592118040179507207/632545652596801537/live_vig3-2019-10-12_13.46.00.gif)

Hot reloading a graphical application:

[https://twitter.com/i/status/1153363259715702784](https://twitter.com/i/status/1153363259715702784)

------
skrebbel
V seems pretty similar to Zig in that it tries to compete directly with C. Has
anyone here used both? Which do you prefer and why?

------
jokoon
How can I use V as a scripting language? I managed to use TinyCC as a
scripting language but V seems to make more sense.

I'm also interesting in C++ interop...

This language looks pretty great. Simple, fast, nicer and lean syntax.

I'm still curious why I often see "name string" intead of "string name". I
guess it's easier to parse? pythonic indent would make this language perfect.

~~~
nedp
Scripting is one of V's main features[0]. Just a couple days ago, it was
incorporated into the 'master' branch[1] so you can now use it.

0 - [https://vlang.io/docs#bash](https://vlang.io/docs#bash)

1 -
[https://github.com/vlang/v/commit/5cd38ec91bc1919aca9f63432e...](https://github.com/vlang/v/commit/5cd38ec91bc1919aca9f63432e38aad27233d6f8)

~~~
jokoon
I meant compiling and executing V from C++, calling V functions from C++, and
C++ function from V.

~~~
delian66
V produces .c files, which are then compiled to .o files, like C.

Interfacing v code into a C++ app, is like interfacing with any other C
library, with the addition, that you may have to write the C headers yourself
(or you can cut/paste them from the produced C file).

If you want to call a C++ function from V, you have to export it from the C++
side, like you would do for a C app: extern "C" { int your_function(int x) }
... and then call it from the V side like any other C function.
([https://vlang.io/docs#calling_c](https://vlang.io/docs#calling_c))

------
tsegratis
Congratulations!

On reading the docs, I wonder if immutable variables and const globals can be
merged as a concept?

I realize the consts can be fun complex 'structs', and have features that
maybe immutable variables can't? -- No mutable globals is good. But still, is
there a deeper reason to not merge const/immutable

------
isawczuk
Can I use live reload on functions that use imported c libs?

~~~
raphman
Hmm, this gif (linked elsewhere in the thread) seems to indicate that C libs
can be used in `live` code.

[https://cdn.discordapp.com/attachments/592118040179507207/63...](https://cdn.discordapp.com/attachments/592118040179507207/632545652596801537/live_vig3-2019-10-12_13.46.00.gif)

------
delian66
Amazing ... That would make
[https://www.xkcd.com/303/](https://www.xkcd.com/303/) obsolete ;-) !

~~~
sdan
It's already obsolete for people who do ML work.

I remember having to wait days or even weeks for something to train while I
either sit back and relax or work on the next thing to train.

~~~
delian66
And now you do not have to wait more than a few seconds, while you train them?

------
rustemb
Wow! Amazing!!!

------
Jahak
Many features were stolen from Golang

~~~
raphman
In the context of programming language design, "stealing" sounds like the
wrong term. Every programming language is inspired by others, isn't it?

