Re:Show HN: Nsynjs – JS engine with stoppable threads and wi...
by cdata on Wednesday May 24, 2017 @01:45AM
(#14407834)
Not disagreeing, but as a long time JavaScripter it is remarkable to me that no matter how delightful or expressive or ergonomic the language tries to become, the same old criticisms manage to evolve with it (this may not be unique to JS).
[Edit] JS has long been criticized (fairly or not) for offering clunky "concurrency" strategies. If you must down vote, please have the decency to offer a counter perspective.
Re:Show HN: Nsynjs – JS engine with stoppable threads and wi...
by Jim99 on Wednesday May 24, 2017 @04:01AM
(#14408272)
As someone who has been around for a long time and manages teams using many different languages (C,C++,C#,Java,Python,JavaScript) my JavaScript/Web teams are the most problematic in terms of cost/performance/gating bugs/upgrades/multi-platform support. The JavaScript critiques that you see are just an expression of the time and resources being wasted.
Re:Show HN: Nsynjs – JS engine with stoppable threads and wi...
by cdata on Wednesday May 24, 2017 @09:41AM
(#14409910)
Where in the stack did you spend your time before you became a manager?
Re:Show HN: Nsynjs – JS engine with stoppable threads and wi...
by sametmax on Wednesday May 24, 2017 @01:59AM
(#14407882)
If you have callbacks, you end up with hard to read and debug code.
If you have transparent async, then:
Then how do you know what blocks and what doesn't ? What's asynchronous and what's going to trigger a switch ? What's a disguised callback and what's the next line ?
What's the solution then ?
Re:Show HN: Nsynjs – JS engine with stoppable threads and wi...
by balfirevic on Wednesday May 24, 2017 @06:48AM
(#14409003)
Why would you need to know, except in some special cases? If you're using async/await, your next line is not executing anyway until the result comes, blocking or not.
Re:Show HN: Nsynjs – JS engine with stoppable threads and wi...
by sametmax on Wednesday May 24, 2017 @08:58AM
(#14409646)
Because otherwise you block the even loop or mismatch life cycle. Espacially reading an unfamiliar code base.
Re:Show HN: Nsynjs – JS engine with stoppable threads and wi...
by z3t4 on Wednesday May 24, 2017 @06:57AM
(#14409034)
embrace higher-order functions. Use named functions and closures!
example code:
var anchors = document.getElementsByTagName(“a”);
for(var i=0,len=anchors.length; i<len; i++){
alertClickAnchor(i); // Named function
}
function alertClickAnchor(i) { // Closure
anchors[i].onclick = function() {
alert(i);
}
}
Re:Show HN: Nsynjs – JS engine with stoppable threads and wi...
by sametmax on Wednesday May 24, 2017 @08:59AM
(#14409657)
This makes anything but basic life cycles very hard to read.
Other languages come either with great concurrency support out of the box (Go, Erlang) or enough constructs to implement cooperative schedulers without having to specify async/await (Lua).