@tmikov
Tzvetan Mikov
8 months
@kadikraman Potentially much slower though. A heap allocation. If you don't always use the same order, it will require polymorphic property access. Even a JIT will have trouble making it reliably fast.
5
1
29

Replies

@kadikraman
Kadi Kraman 💚
8 months
Readability before brevity! An object arg is often so much easier to read: - argument order won't matter (easy to add optionals) - see the arg names without checking the function definition When a function has 3+ args (or 1 bool) I start itching to convert them to an object
Tweet media one
20
8
147
@thymikee
Michał Pierzchała
8 months
@tmikov @kadikraman Performance over readability then
3
0
3
@tmikov
Tzvetan Mikov
8 months
@thymikee @kadikraman No judgement from me, as long as it is an informed and deliberate tradeoff in either direction.
0
0
8
@kadikraman
Kadi Kraman 💚
8 months
@tmikov This is a valid point! Tradeoffs everywhere, as was said below. I need a "sad sigh" emoji
1
0
4
@CanadaHonk
CanadaHonk
8 months
@tmikov @kadikraman This 100%. I made a benchmark before and used an array of 16 numbers instead of 16 arguments, I changed it to 16 arguments and it was ~10x faster in Node.
1
0
7
@cliffordfajard0
Clifford Fajardo 🇳🇮
8 months
@tmikov @kadikraman @tmikov - have you seen any bundler (esbuild,swc etc) take the initial definition (options obj style) & rewrite it to regular args style to avoid object creation?
0
0
2
@btrindadeabreu
Bernardo Trindade
8 months
@tmikov @kadikraman @tmikov would you care to share an example ?
0
0
0