9 ms·
Great article, as always, by Dave Cheney. 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
by amedvednikov 8y ago
Great article, as always, by Dave Cheney.
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 http://vlang.io
- axaxs 8y agoJust 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.
- amedvednikov 8y agoThanks!
- stouset 8y agoThis seems to address basically all of my frustrations with go. Well done!
- SaulOfTheJungle 8y ago> - No err != nil checks (replaced by option types) Where can I find code illustrating V Option types?
- amedvednikov 8y agohttps://github.com/vlang-io/V/blob/master/examples/users.v https://github.com/vlang-io/V/blob/master/examples/users.v They are very simple and combine Rust's Option<T> and Result<T>.
- Sholmesy 8y ago// `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).
- int_19h 8y agoWhat's the difference between "break" and "continue" inside an or-block? Or do they apply to the outer enclosing loop if there is one?
- amedvednikov 8y agoYes, just like in Swift.
- int_19h 8y agoThen I don't get it - how do you make the or-block exit normally and yield a value, instead of exiting the outer scope one way or another?
- wuschel 8y agoExciting! How long was this language in development? In what language was the compiler originally written in?
- slimsag 8y agohttps://news.ycombinator.com/item?id=19086712 https://news.ycombinator.com/item?id=19086712
- amedvednikov 8y agoIt was written in Go, my favorite language at the time :) About 2 months later I rewrote it in V. Bootstrapping is fun. Did it 4 times (V1 => V4).
- TeddyDD 8y agoI never heard about this language and it looks impressive on the paper. Keep up great job! I'm waiting for open source release to give it a try.
- amedvednikov 8y agoWell it's pretty new. I launched the website today :)
- edflsafoiewq 8y agoThe binary size and compilation speed look amazing. The "Detailed comparison of V and other languages." link on the homepage doesn't seem to work.
- kochthesecond 8y agoHi, never heard of V before. Looks great. What are the cons? No runtime and such a small language! How does it do threads? Networking? Any story on cross-compiling?
- amedvednikov 8y agoThe main con is it's at a very early stage. 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.
- axaxs 8y agoDoes this mean it doesn't support standard linux socket operations, or am I misreading it?
- amedvednikov 8y agoIt does. I was describing the HTTP library. My bad.
- int_19h 8y agoThis 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.
- amedvednikov 8y agoI agree with you, but I want the language to be not too different from C/C++ and Go, to make the transition easier.
- hwj 8y agoJust 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.