V is essentially a much cleaner version of Go, syntactically. Though it adds many features that turn it into one of the nicest (IMO) languages to write.
It adds:
- Hot reloading, on a compiled language (WOW)
- Pattern matching/match statements
- Option/Sum types
- A really clean approach to handling Maybe results that I haven't seen in other languages before -- EDIT: I take it back, apparently my own ignorance here
- Generics
- C interop and compile/build integration that's incredibly easy
Some of my favorite bits: // Error-catch + propagation on Maybe's with "?"
fn f(url string) ?string {
resp := http.get(url) ?
return resp.text
}
// Identical to this -- Option types must be handled with "or" if not "?"
resp := http.get(url) or {
return error(err)
}
return resp.text
number := 2
s := match number {
1 { 'one' }
2 { 'two' }
else { 'many'}
}
Additionally, the devs/community on Discord are really friendly, and they spent an hour helping me compile Facebook's reference C++ GraphQL parser library, and interop with the C API from V. I'd never touched low-level stuff before and the experience was a blast.This was all it took (minus figuring out the C++ build process):
// app.v
#flag -I libgraphqlparser_compiled
#flag -L /home/user/Projects/vlang-graphql/libgraphqlparser_compiled
#flag -l graphqlparser
#include <GraphQLParser.h>
#include <GraphQLAstToJSON.h>
struct C.GraphQLAstNode{}
fn C.graphql_parse_string(text charptr, error &charptr) &C.GraphQLAstNode
fn C.graphql_ast_to_json(node &C.GraphQLAstNode) byteptr
node := C.graphql_parse_string("query MyQuery { id email }", "Failed to decode")
json_str := cstring_to_vstring(C.graphql_ast_to_json(node))
println(json_str)
And because the primary compilation target atm is C, performance is generally screaming fast.---
Edit: Want to clarify it's still experimental. As a concept/language, I found it fun.
See Christine Dodrill's negative experience and valid criticisms below for the other side of this coin.