loading...

V Programming Language

delta456 profile image Swastik Baranwal ・1 min read

There's a new language called V which could be found here and was open sourced in July and it has got almost 12k stars on Github. It promises a lot of new things and it is said to have a stable release by the end of the year.

It derives its syntax from Go and has memory management like Rust. It could be learned in minutes because of its easy syntax. There are some projects that already use V. Some people say that it won't be able to keep up with promises and it's a meme. So what you guys think about it and will you guys would use V when it comes out?

In my opinion V does have a lot of potential and has rapid development which can keep up with its promises and rock when it comes out.

Discussion

markdown guide
 

memory management like Rust

I wonder about that. According to vlang.io/docs#memory, memory management is "Work in progress" - so I wonder how much of it actually works well yet.

To get its memory management, Rust had to use linear typing and introduce the concept of lifetimes, making the language as complex as it is. Did V really manage to get this type of memory management to work without lifetime notation? Or is it WIP because they are still trying to figure it out?

 

Currently there are many memory leaks. Only some of them are fixed. It still needs an AST and it is said to be in progress and its being worked on rapdily
The docs are currently outdated because of fast pace of development if I recall correctly.

 
 

So basically is uses reference counting but runs aggressive lifetime analysis to convert as many strong references to weak ones, to reduce the number of actual RC updates, and if possible even put the value on the stack and avoid heap allocation altogether?

And the compiler will do all that in super blazing fast speed?

Probably. I don't if this will slow down the compile speed because I am not the creator V lang.

 

V version 0.1.21 got released yesterday!

CHANGELOG

  • none keyword for optionals.
  • Solaris support.
  • All table lookup functions now use none.
  • varargs: fn foo(bar int, params ...string) {
  • Double quotes (") can now also be used to denote strings.
  • GitHub Actions CI in addition to Travis.
  • compress option. The V binary built with -compress is only ~90 KB!
  • More memory management.
  • Unused modules result in an error. "Unused variable/module" errors are now warnings in non-production builds.
  • Duplicate methods with the same name can no longer be defined.
  • Struct names must be capitalized, variable/function names must use snake_case.
  • Error messages are now even nicer!
  • Lots of fixes in automatic .str() method generation for structs and arrays.
  • ~30% faster parser (files are no longer parsed separately for each pass).
  • _is no longer a variable, but an actual syntax construct to skip unused values, like in Go.
  • Multiple returns fn foo() (int, string) {.
  • ! can now only be used with booleans.

For changes in more depth see here.

 

Even if it somehow V just turns into a mini Go but with generics and a tiny compiler it could still be useful. I think it's worth trying.

 

V has finally a basic direct x64 machine code generation.

github.com/vlang/v/issues/2849