Hacker News new | past | comments | ask | show | jobs | submit login

There are trade-offs for everything. The extra function arguments in Javascript cause all sorts of bugs when you alter the signature of a callback, miss a call site, and the new argument is suddenly being interpreted (without any crash or error message!) according to the semantics of a different argument.

The callback-args struct is common, but has its own set of trade-offs too: it frequently becomes a "data whale", a dumping ground for everything that could happen with no indication in the source code of which parts a subsystem actually uses. Frequently, I've seen these replaced by a dependency injection framework as the software and team gets larger (which has its own set of problems, with it becoming difficult to holistically understand the data flow within the system).

Keyword args are popular in languages that support them, too. They solve the semantic problems of missing positional args, and are semantically identical to the option struct approach but with a bunch of syntactic sugar.




Consider applying for YC's Spring batch! Applications are open till Feb 11.

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

Search: