Hacker News new | ask | show | jobs
by deagler 3544 days ago
The one image that describes JavaScript perfectly: https://i.imgur.com/qPlBUp5.png

Not much more needs to be said, It amazes me that there are people that actually think JavaScript is an "important" language, It's an archaic mess that has simply been polished over and made to look shiny(as the article states).

If you polish a dirty shoe, It's just a dirty shoe that's shiny.

3 comments

This image is absolutely ridiculous.

    Problem: JavaScript won't run outside browser.
    Solution: V8 (V8 was built for Chrome, btw, NodeJS is what took V8 outside of the browser)
    Problem: JavaScript is single threaded by design. (This isn't a problem, you even said BY DESIGN)
    Solution: Asynchronous programming. (This is a solution that literally allowed applications running on 20-30 machines to drop to 2 machines and still see over an order of magnitude performance improvements).
    Problem: Callback hell. (Callback hell is NOT the way any reasonable Node developer programs. Promises are completely sensible to reason through).
    Solution: Compile to better language (Promises are native)
I don't know how many times I have to post this, but this is what good Node code looks like.

    function doComplexAsyncTask() {
      return Promise.join(
        doParallelAsyncTask1(),
        doParallelAsyncTask2(),
        doParallelAsyncTask3()
      )
      .spread((result1, result2, result3) => {
        let combo = doSomething(result1, result2, result3);
        return saveComboToDBAsync(combo);
      })
      .then(result => doSomethingElseAsync(result))
      .catch(err => handleError(err));
    }
And that's an overly complicated example. And then from anywhere else in the code you can call

    doComplexAsyncTask()
    .then(result => doSomethingWithResultAsync(result));
There is no callback hell. The error handling is trivial. Doing parallel tasks is trivial. And that "single threaded" issue is not an issue. The moment parallel tasks1, 2, and 3 START, your application is already serving the next request. There is 100% CPU availability for every single thread, not a single moment is wasted blocking. And if you're running on a multi-core machine, you use node clustering to get 100% CPU usage of all of the cores.

People do just regurgitate the same nonsense over and over.

You may not like JavaScript, and that's fine (I can certainly understand why), but like it or not it is an "important" language because it's all over the web, where "important" has some debatable meaning of weightiness. Right now hundreds of millions of people around the world are running JavaScript code, whether they know it or not (and most probably don't).
Would be great if you can entertain the idea that all that digging might be to get to the other side