216
LISP is ugly (lemmy.ml)
you are viewing a single comment's thread
view the rest of the comments
[-] Tartas1995@discuss.tchncs.de 3 points 1 year ago

It is not really tangential to the discussion. You claimed it is because Js single threaded. Also it is not single threaded from the "users" perspective if you mean the developer. There are workers.

If your issue is asynchronous function calls, just call synchronous functions. You might be stuck in a while loop somewhere but if you prefer that, use it. There are sync functions for everything in Js and/or you can easily create them yourself.

[-] yogthos@lemmy.ml -5 points 1 year ago

Js is single threaded from user perspective. You have no access to the threading runtime as a user and cannot spawn a thread in Js to do some background work. Workers are a recent addition, but using them is quite different from what I'm talking about.

And being stuck in a while loop is precisely why people have to use callbacks and why all the APIs are async. This is literally the problem. If you're dealing with any non trivial load, you are forced to use async mechanics.

[-] Tartas1995@discuss.tchncs.de 2 points 1 year ago

And what is the alternative? How do you handle any non trivial load in any other language? Without a second thread or while loop. Because apparently you dislike both. You like it sync for your database -> while loop somewhere, but while loops are bad. But asynchronous is bad because it adds complexity to your code when you use functions to reduce the nesting.

On nodejs, the platform that you talked about earlier, they are literally called worker_threads". So they are different? How? Why can't you use them?

this post was submitted on 24 Sep 2023
216 points (93.5% liked)

Programmer Humor

32067 readers
374 users here now

Post funny things about programming here! (Or just rant about your favourite programming language.)

Rules:

founded 5 years ago
MODERATORS