Hacker Newsnew | past | comments | ask | show | jobs | submit | wa1987's commentslogin

State charts / FSM's work wonders in these situations.


For these situations I often use IFFEs with if-statements and early returns inside.


What's the pros/cons vs Promise.all([...])?


> Assuming the first request is done much faster than the second request, we can already utilize the CPU and doSomeCalculation while waiting for the second request to finish. In this case, the shown code is better than Promise.all([request1, request2]).


    Promise.all([request1.then(doSomeWork), request2])

?


yes this would work. It's just nested.


The nesting has the advantage of directly expressing the dependency structure of the promises, which is otherwise a bit hard to infer.


There's Clojure too.


> Please stop spreading this misnomer.

That's a fairly… direct way of putting it :-)

Anyway:

1. What are the key differences in terms of usage and use cases?

2. Why isn't Deno a 'wholesale' replacement for Node?

3. In which respect are the vastly differently inner workings relevant in regards to usage of both products?


I suspect the reply was snide, masked by a smiley face, but here ya go anyhow. First result on Google for "deno vs node" https://www.imaginarycloud.com/blog/deno-vs-node/#:~:text=Wh...) that covers the basics of all three asked points.


I did not want to have to sift through a hefty article to get answers to the questions. Anyone can google search, but I see the points of the comments to share condensed information not just to "link" to google.

Here's what I discovered as what I presume andrew_'s reasoning for why its not a node replacement (from the article)

"Node has been under development for over a decade, which makes it more stable and battle-tested, making it the de facto standard for server-side JavaScript. Deno has only been under development for just two years and continues to be improved. Among other things, Deno is an excellent replacement for utility scripts that are usually written with bash or python."


"Money earned"


Except both "money" and "earned" are debatable. Net worth isn't all liquid, and whether it's "earned" seems to be the entire point of the website.


That doesn't make any sense. It's not like he could offload all his shares at the market price.


"earned" is tricky, though.


One of your best bets might be the vintage keyboard community:

- https://www.modelfkeyboards.com/

- https://deskthority.net/

- https://geekhack.org/


Thanks, I will have a look :-)


> On a Mac, there is a major performance hit whenever you do disk IO in a bind mount (i.e. voluming a directory of the host system into the container). Working without bind mounts is extremely limiting. [..] If you’re using Docker on a Mac and you’ve never tried it on Linux, you owe it to yourself to try it on Linux.

Or use named volumes. I'm running a dockerized WordPress dev environment on my MacBook with average TTFB's of 40 ms.


I had to investigate why our docker-ized dev environment was so slow on macOS at my last job and this was the root cause. One project's test suite ran in about 5-10 mins in our linux CI/CD environment, and about 50+ mins in macOS with docker.

There was a very in-depth thread on the docker forums where the devs explained why there was such a huge performance penalty. IIRC it was due to all the extra bookkeeping that had to be done to ensure strong consistency and correct propagation of file system events between the virtualized docker for mac environment and the host file system.

The test suite would run integration tests that performed a lot of npm/yarn operations which meant lots of disk IO.


The reason is that docker on mac runs in a Linux VM and VM mounts are slow.


> Or use named volumes

And how do you access these from your host with high performant IO?


There’s no need to in my situation. 99% of the files are dependencies installed through Composer (PHP) while building the Dockerfile. The few directories I need to work on directly are bind mounts and don’t have much impact on overall runtime performance.


> - for in loop - for of loop

It's 2020 and you still use loops? ;-)

source: https://github.com/buildo/eslint-plugin-no-loops


Disallowing for..of iterators is the reason I cannot use or recommend the Airbnb lint preset. A very nice example of an anno 2014-2017 cargo cult that clearly hasn't held up. https://github.com/airbnb/javascript/issues/1271


Don't worry, there's plenty of 2020 cargo culting to replace it.


for/of is an iterator. It consumes the Symbol.iterator interface and is totally different from the for(i++) statement.

That eslint rule is a good example of a cargo cult. The second link in its rationalization argues for using underscore over touching a dangerous loop yourself.


Often times operations are order-independent. Specifying those as sequential `await`-s does not make a lot of sense in those situations. I guess less fine grained control is desirable under such circumstances :-)

There's also other useful utilities such as Promise.all(), Promise.any() and Promise.race().


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: