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.
No runtime and such a small language!
How does it do threads? Networking? Any story on cross-compiling?
It supports only traditional threads right now (but with automatic locking).
Networking is supported. It uses curl/windows api.
Cross compiling will be top notch, just like with Go.
The "Detailed comparison of V and other languages." link on the homepage doesn't seem to work.
How long was this language in development? In what language was the compiler originally written in?
About 2 months later I rewrote it in V. Bootstrapping is fun. Did it 4 times (V1 => V4).
Where can I find code illustrating V Option types?
They are very simple and combine Rust's Option<T> and Result<T>.
// `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