Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

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



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.


Thanks!


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.


I agree with you, but I want the language to be not too different from C/C++ and Go, to make the transition easier.


This seems to address basically all of my frustrations with go. Well done!


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?


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.


Does this mean it doesn't support standard linux socket operations, or am I misreading it?


It does. I was describing the HTTP library. My bad.


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.


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.


Well it's pretty new. I launched the website today :)


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.


Exciting!

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


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).



> - No err != nil checks (replaced by option types)

Where can I find code illustrating V Option types?


https://github.com/vlang-io/V/blob/master/examples/users.v

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).


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?


Yes, just like in Swift.


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?




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: