Re:“Node.js is one of the worst things to happen to the soft...
by lacker on Tuesday August 23, 2016 @12:23AM
(#12341380)
If you think promise-based code with a lot of "then" is annoying, perhaps ES7 async/await will make you happier.
[ Parent
| on HN ]
Re:“Node.js is one of the worst things to happen to the soft...
by nurettin on Tuesday August 23, 2016 @01:16AM
(#12341559)
This is exactly what I was about to write. Also, the amount of "callbacks, that's how it's supposed to be" and "hardware is like that" and "programming is hard, deal with it" kind of replies for a readily solved problem are staggering.
Re:“Node.js is one of the worst things to happen to the soft...
by lootsauce on Tuesday August 23, 2016 @01:43AM
(#12341656)
I don't know about others but the imposition of try catch for error handling in async/await seems to cut against the syntax gains over promises.
Re:“Node.js is one of the worst things to happen to the soft...
by nurettin on Tuesday August 23, 2016 @04:04AM
(#12342110)
If by promises you mean the `some.fun(had).catch(had, function(){handle stuff here})` syntax compared to async/await, that is actually a very fair point and it does make two syntaxes similarly verbose.
However, it is still easier to follow a ladder of conditional statements using async/await compared to escher-style stairs of callbacks inside callbacks.
Re:“Node.js is one of the worst things to happen to the soft...
by edwinjm on Tuesday August 23, 2016 @07:03AM
(#12342728)
Interesting. In which language is this "readily solved"?
Re:“Node.js is one of the worst things to happen to the soft...
by iends on Tuesday August 23, 2016 @07:33AM
(#12342836)
Erlang, Elixir, & Go have nicer models.
Re:“Node.js is one of the worst things to happen to the soft...
by Capt-RogerOver on Tuesday August 23, 2016 @04:49AM
(#12342268)
It's a solution for a made-up problem. Sure, async/await makes it easier. But not as good as the normal sync code would be. And for what reason?
The concurrency problems are already a solved issue in many many frameworks. Sure, if you do fully manual threads in something like C++ and code up everything yourself - you're in for the trouble down the road unless you are a good professional. But there are heaps of concurrency frameworks in all major languages that make this very easy.
And what about performance, how does JavaScript justify putting virtually every single return value of every function into some Promise object? Talk about wasted resources.
Re:“Node.js is one of the worst things to happen to the soft...
by Salgat on Wednesday August 24, 2016 @03:56PM
(#12354755)
Await lets you preserve the sequential syntax that normal programmers are used to. It's syntactic sugar, which is fine if you prefer to code in a way that most people are familiar with, versus callbacks that can be messier (callback hell).
Re:“Node.js is one of the worst things to happen to the soft...
by edwinjm on Tuesday August 23, 2016 @07:06AM
(#12342745)
JavaScript uses one thread so not switching threads with all its contexts saves a lot of overhead.
Re:“Node.js is one of the worst things to happen to the soft...
by Capt-RogerOver on Tuesday August 23, 2016 @06:56PM
(#12348434)
JavaScript being single-threaded is one of it's biggest drawbacks. This is universally agreed on by both it's proponents and critics.
Yes sure, some very few resources are wasted on each thread, but in case of JavaScript, it wastes a lot more by not using all the cores, of which there are usually several present in almost any modern computer that will run JS.