Everything you complain about here is straight-up Go syntax.
Re:My Foray into Vlang
by ohdeargodno on Sunday August 31, 2025 @10:27AM
(#45083385)
Mind you, that doesn't prevent Go's syntax from being terribly stupid. They just happen to line up on stupid choices.
Just because you have reverence for C and C syntax, doesn't mean others have to. What is "funny" is subjective.
The paren for the argument to if in C is just there to be able to omit {}. Which is one of the most stupid things in C. Add two characters for ALL if statements to avoid two characters for >1% of if statements. That is a mathematically certain loss.
module main
struct Language { pub mut: score int = -1 name string @[required] }
fn (lr []Language) total() int { mut total := 0 for l in lr { if l.score > 0 { total += l.score } }
return total }
fn (lr []Language) average() int { return lr.total() / lr.len }
fn main() { racket := Language{98, 'racket'} // Simple arrays too! langs_arr := [racket, Language{102, 'ocaml'}] println(langs_arr) println(langs_arr.total()) println(langs_arr.average()) }
Remove
1. Whatever this is "fn (lr []Language) total() int {", why is there an ability to define a special function to an array? How do I know what overload is being used? If I change something from map to vector, how do I know there's nothing else that changes? Member function is just a sugar over regular functions? Great, remove member functions.
2. Why allow this? "racket := Language{98, 'racket'}" ? Why implicitly depend on ordering of parameter? Just use Language { .score = 98, .name = "racket", } Confusing order of evaluation? Great, just force it to be assigned exactly the same as the definition and force ordering that way.
3. Why remove the parenthesises " if l.score > 0 {"? In fact, I would even reject code that assumes any integer != 0 is True. Nope, you have to do the exact check every time. No more if (x) { }
4. Why allow default parameter? Why needing special syntax for @required?
I just want a very limited C with GC, pattern matching and algebraic data types. I don't even need generics.