-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Sugar is expensive #20
Comments
You can say that about a few features of ES2015 when they were just polyfills in tools like Babel and Tracur but yet these features are now gaining engine support of optimized code generation so why would this be considered a waste of time if developers see a value in it. ES2015, 2016, 2017 are all examples of sugar to "fix" the existing javascript language by making it more modern. |
Try to match
with |
@phillipCouto native syntax extensions are a different story - they gain engine support because they're driven by the TC39. That said, some of the features are actually detrimental both in overhead (this is measurable) and engineering patterns (this is opinion) - (see http://npm.im/es2020 and http://npm.im/es2040) If you see value, and that value outweighs the cost (in terms of developer learning and performance overhead) then that's cool Interesting way to construct an error function howAreWe (thing) {
switch (true) {
case thing === 'ok': return ok()
case isErrArray(thing) && thing[1] === 'shit went wrong': return shitWentWrong()
default: return somethingElse()
}
}
function isErrArray (thing) {
return Array.isArray(thing) && thing[0] === 'error'
} But it doesn't have to be a function howAreWe (thing) {
return thing === 'ok' ?
ok() :
(isErrArray(thing) && thing[1] === 'shit went wrong' ? shitWentWrong() : somethingElse())
} |
@davidmarkclements You got me. It surely is correct, but I had something slightly else in mind and should have be more clear. I should have add "in equally readable manner". |
@davidmarkclements I totally agree with your points in your posts, the issue I had especially was just the reference of wasting time. Is this solution a performant one? Definitely not. The implementation spends time serializing and deserializing objects which in hot code paths would be devastating but what I love about these projects is that it can open peoples minds to possibilities. For both sides, either to support it or not. Example being you providing more efficient native solutions that is close to similar readability. |
you seem to be trying to "fix" the language, at the cost of unnecessary overhead in both compute time and your time.
The text was updated successfully, but these errors were encountered: