Just wanted to say...as both a language nerd and opinionated snob, I'm really excited by what I see with V thus far. I'll be following your progress for sure and wish you the best.
This is interesting. Go proclaims itself as a modern spiritual successor to C, but I think what you've done is much closer to that goal.
BTW, if you're going for immutability by default, perhaps swap := and =? Reason being, if variables are immutable by default, assignments should be far less common, so the language should discourage them with more verbose syntax over initialization of immutables.
Besides, C originally used = instead of Algol's := for assignments for the exact opposite reason - because assignments were more common in C code than comparisons - this would be a nice opportunity to fix that mistake.
Just a note: the .v extension is already used for Verilog and Coq files. Even though V seem more eligible to use it that might disturb LoC counters like tokei or scc I guess.
// `http.get()` returns an optional string.
// V optionals combine the features of Rust's Option<T> and Result<T>.
// We must unwrap all optionals with `or`, otherwise V will complain.
s := http.get(API_URL) or {
// `err` is a reserved variable (not a global) that
// contains an error message if there is one
eprintln('Failed to fetch "users.json": $err')
// `or` blocks must end with `return`, `break`, or `continue`
return
}
This looks really handy. Is there somewhere else (outside of V) where I can read about Option types (in the real world, or in theory).
I took a lot of his advice when designing V [1].
It's very similar to Go, but it has
- No global state
- Only one declaration style (a := 0)
- No null
- No undefined values
- No err != nil checks (replaced by option types)
- Immutability by default
- Much stricter vfmt
- No runtime
- Cheaper interfaces without dynamic dispatch
[1] http://vlang.io