3 ms·
Nope, `doStuff().then(function(value)" != try` A closer representation would be `try { var value = doStuff()` which has similar verbosity. ES6 will have gener
by spion 13y ago
Nope, `doStuff().then(function(value)" != try`
A closer representation would be `try { var value = doStuff()` which has similar verbosity.
ES6 will have generators and "arrow" function syntax. Meaning:
doThing().then(function(value){
//blah blah blah
})
.catch(function(err){
//handle it
})
becomes either:
try {
var value = yield doThing();
//blah blah blah
} catch (err) {
//handle it
}
or
doThing().then(value => /* blah blah blah */)
.catch(err => /* handle it */);
meaning you can pick your paradigm :) Except that the functional one composes slightly better, perhaps.
doThing().then(value => /* blah blah blah */)
.catch(only(ParseError, err => /* handle it */));
vs
try {
var value = yield doThing();
//blah blah blah
} catch (err) {
only(err, ParseError); // argument repetition
//handle it
}
- moron4hire 13y agoUhhh, you're not convincing me that you've said anything meaningful towards improving software quality.
- spion 13y agoAs opposed to what, threads? They have contributed towards improving software quality? In most languages with mutable state they've been a disaster -- correct me if I'm wrong. Adding threads in JavaScript would also be a disaster. Practically everything is mutable and there are absolutely no locking mechanisms.
- audreyt 13y agoOne possible solution to introduce threads to JS is to isolate threads from each other and use only message-passing: https://github.com/audreyt/node-webworker-threads/ https://github.com/audreyt/node-webworker-threads/
- spion 13y agoSorry, but share-nothing threads that can only communicate via (afaics) serialized message passing are no longer threads. There is very little benefit to those compared to just spawning child processes.