Skip to content
This repository has been archived by the owner on Jul 22, 2020. It is now read-only.

Is this worth the syntax complexity? #2

Closed
robpalme opened this issue Mar 19, 2018 · 5 comments
Closed

Is this worth the syntax complexity? #2

robpalme opened this issue Mar 19, 2018 · 5 comments

Comments

@robpalme
Copy link

Logical operators in JavaScript have unexpected behavior (short-circuiting) compared to other languages that return a boolean. Given the long list of proposed syntax additions competing for the complexity budget, is it worth spending it on yet another way to surface this somewhat odd behavior? My feeling is no, but I would like to hear more from other reviewers.

(This was the general feeling that came out of a company-internal discussion between a bunch of us reviewing forthcoming proposals.)

@ljharb
Copy link
Member

ljharb commented Mar 19, 2018

One possibility is the fact that &&= and ||= are missing is a source of complexity, and adding these operators might instead reduce the complexity budget.

@jridgewell
Copy link
Member

Every time I have to put a value into an object, I'm super annoyed that I have to repeat the obj.foo. I think the proposal has minimal syntax complexity, but may cause confusion due to the short-circuiting semantics.

But, setters in general are still super rare, so the majority of cases won't matter at all. And where they are common (mainly DOM APIs?), having short-circuiting semantics is actually desired.

@ljharb
Copy link
Member

ljharb commented Feb 8, 2020

@rdsedmundo this repo is for logical assignment; opinions on other syntax are irrelevant here.

You're saying that you understand what &&, ||, and ?? do; and you understand what += and friends do in comparison to +, but you had trouble understanding what &&=, ||=, and ??= do? Please elaborate; I'd love to understand your confusion here.

@jimmywarting
Copy link

jimmywarting commented May 29, 2020

My first impression when i saw this in chromestatus was whata heck is this new weird complex stuff? 😳 never seen it before

looked at the example and i knew what it was, honestly I'm more annoyed by the new syntax that gets added all the time. javascript have become a fatigue. I have long waiting for the day for when i no longer need babel to transpile my code. Or when i forcefully need to update my engine to work with new tools. or having to downgrade my code cuz something don't work in xyz.

can't browser just focus more on

  • bugs, missing feature and performance in that order?
  • secondly add new api's that can't be polyfilled - things that would make you choose PWA over native
  • and last syntactic sugar that you don't really need and can live without.

@robpalme
Copy link
Author

Apologies I forgot this issue was still open.

We've seen plenty of use-cases and the outcome was that the committee does believe this feature is worthwhile. Thanks to everyone who contributed to this thread!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants