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

Speaking of language perspective. I see obj spread in JS for arguments as an ugly hack to make up for the lack of named and optional args. It gets really ugly when you attempt to set defaults.

My perspective is from Python, which I think gets it very right.




But named-args in Python are also syntactic sugar for passing dictionaries around. Object-unpacking of the the kind described here is another one.


Syntactic sugar is the important part here.

You can always pass an object and handle defaults and default merging within the function body, sure.

I use JavaScript a ton and I do love object spread and array destructuring. But writing function signatures is still very clumsy.


There is optional args for JS.

And it's not hack since it's a partial form of pattern matching.

Although simple and consice is absolutely not JS is famous for, a lot of functional programming languages with consice design do the same thing.




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

Search: