News for hackers. Stuff that matters.
Re:Practical Go: Real-world advice for writing maintainable ... by amedvednikov on Thursday February 21, 2019 @12:41PM (#19218749)
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

Re:Practical Go: Real-world advice for writing maintainable ... by axaxs on Thursday February 21, 2019 @12:47PM (#19218821)
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.
Re:Practical Go: Real-world advice for writing maintainable ... by amedvednikov on Thursday February 21, 2019 @12:54PM (#19218906)
Thanks!
Re:Practical Go: Real-world advice for writing maintainable ... by int_19h on Thursday February 21, 2019 @11:14PM (#19223072)
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.

Re:Practical Go: Real-world advice for writing maintainable ... by amedvednikov on Friday February 22, 2019 @07:16AM (#19224677)
I agree with you, but I want the language to be not too different from C/C++ and Go, to make the transition easier.
Re:Practical Go: Real-world advice for writing maintainable ... by stouset on Thursday February 21, 2019 @01:03PM (#19218980)
This seems to address basically all of my frustrations with go. Well done!
Re:Practical Go: Real-world advice for writing maintainable ... by kochthesecond on Thursday February 21, 2019 @02:07PM (#19219637)
Hi, 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?

Re:Practical Go: Real-world advice for writing maintainable ... by amedvednikov on Thursday February 21, 2019 @02:09PM (#19219656)
The 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.

Re:Practical Go: Real-world advice for writing maintainable ... by axaxs on Thursday February 21, 2019 @05:17PM (#19221050)
Does this mean it doesn't support standard linux socket operations, or am I misreading it?
Re:Practical Go: Real-world advice for writing maintainable ... by amedvednikov on Thursday February 21, 2019 @09:27PM (#19222614)
It does. I was describing the HTTP library. My bad.
Re:Practical Go: Real-world advice for writing maintainable ... by hwj on Friday February 22, 2019 @01:08AM (#19223490)
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.
Re:Practical Go: Real-world advice for writing maintainable ... by TeddyDD on Thursday February 21, 2019 @02:00PM (#19219569)
I 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.
Re:Practical Go: Real-world advice for writing maintainable ... by amedvednikov on Thursday February 21, 2019 @02:06PM (#19219624)
Well it's pretty new. I launched the website today :)
Re:Practical Go: Real-world advice for writing maintainable ... by edflsafoiewq on Thursday February 21, 2019 @02:06PM (#19219626)
The binary size and compilation speed look amazing.

The "Detailed comparison of V and other languages." link on the homepage doesn't seem to work.

Re:Practical Go: Real-world advice for writing maintainable ... by wuschel on Thursday February 21, 2019 @01:55PM (#19219524)
Exciting!

How long was this language in development? In what language was the compiler originally written in?

Re:Practical Go: Real-world advice for writing maintainable ... by amedvednikov on Thursday February 21, 2019 @02:05PM (#19219611)
It 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).

Re:Practical Go: Real-world advice for writing maintainable ... by slimsag on Thursday February 21, 2019 @02:03PM (#19219592)
Re:Practical Go: Real-world advice for writing maintainable ... by SaulOfTheJungle on Thursday February 21, 2019 @01:15PM (#19219093)
> - No err != nil checks (replaced by option types)

Where can I find code illustrating V Option types?

Re:Practical Go: Real-world advice for writing maintainable ... by amedvednikov on Thursday February 21, 2019 @01:17PM (#19219113)
https://github.com/vlang-io/V/blob/master/examples/users.v

They are very simple and combine Rust's Option<T> and Result<T>.

Re:Practical Go: Real-world advice for writing maintainable ... by Sholmesy on Thursday February 21, 2019 @02:56PM (#19220020)

  // `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).
Re:Practical Go: Real-world advice for writing maintainable ... by int_19h on Thursday February 21, 2019 @11:17PM (#19223080)
What's the difference between "break" and "continue" inside an or-block? Or do they apply to the outer enclosing loop if there is one?
Re:Practical Go: Real-world advice for writing maintainable ... by amedvednikov on Friday February 22, 2019 @07:14AM (#19224667)
Yes, just like in Swift.
Re:Practical Go: Real-world advice for writing maintainable ... by int_19h on Friday February 22, 2019 @12:17PM (#19227027)
Then 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?