tc39 / proposal-nullish-coalescing

Nullish coalescing proposal x ?? y
https://tc39.github.io/proposal-nullish-coalescing/
1.23k stars 23 forks source link

Syntax Clutter #19

Closed igl closed 6 years ago

igl commented 6 years ago

Did you ever think about that js source code will get cluttered and be full of ? symbols everywhere?

I am sure mine will be. I use helpers like _.get/oget/idx a lot and probably should use them even more. Maybe it would be better to replace . altogether?

ljharb commented 6 years ago

@igl if you don't want to use a particular kind of syntax, don't - you can even lint against its use.

. can't be "replaced", old code can't ever be broken, so it will work the same forever.

igl commented 6 years ago

Replace like we "replaced var with let"... bad phrasing... Sorry!

My point is: Having to put multiple question marks to get what should be the default behaviour of a property accessor is not very elegant.

I liked coffeescripts version of ? a lot more than these question-mark constructs here. But it also had comprehensibility problems. Especially if used in multi-conditional if statements (or worse: with unless)

rattrayalex commented 6 years ago

@igl there's a lot to look through, but if you read through the various threads here, I think you'll find that tc39 members very much have clutter in their minds, and have some tricky constraints to wrestle with which necessitate the "clutter" you're referring to.

In general, backwards-compatibility makes this sort of work very hard.

gisenberg commented 6 years ago

Developer ergonomics and experience (in both readability and writability) are always at the forefront when a feature is discussed. The ideal syntax, the syntax available to the language, and the syntax favored by the community do not always intersect.

I'm having a hard time deriving anything actionable from this issue beyond a vague call for a proposal that revisits ., which isn't enough information for me to do something with.