Hacker News new | ask | show | jobs
by boxed 760 days ago
Go, and F# do almost all positional arguments. I think Rust too. Java, C#, C, PHP are also positional only or 99% of the time. I assume Dart too.

We are talking named/keyword/etc.

Personally I find positional arguments to be an anti-pattern in all but a very specific set of circumstances.

2 comments

If I understand correctly, we aren't talking about named/keyword arguments. This is about a shorthand syntax in ES6 objects, nothing to do with function arguments.

In JS, when creating an object, instead of writing {name: name}, where "name" is both the key in the map as well as the variable you want it to assign to, you can do {name}, whereas e.g. in Go you would do map[string]any{"name": name}.

Edit: Or, for completeness' sake, it's the same with structs in Go, where you would instantiate a struct like this: Person{name: name}.

C#, F# and PHP all support named arguments and they're quite common for optional parameters.