Non-blocking programming is the hardest most rage-inducing paradigm I've ever programmed in

Non-blocking programming is the hardest most rage-inducing paradigm I've ever programmed in.

Attached: index.png (287x175, 4K)

Other urls found in this thread:

kore.io/
stackoverflow.com/questions/32536049/do-i-need-to-return-after-early-resolve-reject
twitter.com/SFWRedditVideos

Faggot

>I can't handle callbacks

Lmaoing @ your life.

how much of a faggot do you have to be to not understand brainlet meme web dev frameworks?

just use await

Node.JS was and is a mistake.

Fascinating how it's still better than python

>Corporate users of Node.js software include GoDaddy,[11] Groupon,[12] IBM,[13] LinkedIn,[14][15] Microsoft,[16][17] Netflix,[18] PayPal,[19][20] Rakuten, SAP,[21] Voxer,[22] Walmart,[23] and Yahoo!.[24]

Good thing I use none of these companies' products.

For me it was reactive programming (Flutter for Android). I was forced to use that shit and I swear I've never in my life been closer to punching the computer screen, and I've played a lot of rage-inducing games in my youth.

That has nothing to do with NodeJS though.

>comparing the flavors of different kinds of shit

Go write a fucking RESTful API with C, brainlet.

I'm actually doing that - and the whole http server as well

#include
#include

int page(struct http_request *);

int
page(struct http_request *req)
{
uint16_t id;
const char *hdr;

if (http_request_header(req, "x-request", &hdr))
http_response_header(req, "x-response", hdr);

http_populate_qs(req);

if (!http_argument_get_uint16(req, "id", &id)) {
http_response(req, 400, NULL, 0);
return (KORE_RESULT_OK);
}

kore_log(LOG_INFO, "id parameter: %u", id);
http_response(req, 200, NULL, 0);

return (KORE_RESULT_OK);
}


Seems easy enough? kore.io/

one of the chapters in Hacking the Art of Exploitation is about that

>imagine wasting your time and being proud about it

Nah, it's fine. Any sort of async control-flow becomes trivial when you use async/await. Though, I guess it would still be nice if explicit asynchronicity in programming languages went away and was replaced by implicit coroutines or green threads or something. Go has the right idea.

How is it a waste of time? I found it boring to make one CRUD app after the other in JS and Java. I find it a fun exercise to know how everything works all the through (besides at the hardware level).

You sounded like you do this professionally. If it's just a hobby project you're working on there's nothing wrong with it.

try throwing parallelism across multiple hosts into the mix c:

nodejs is comfy with await statements.

Sorry you lack the IQ to write asynchronous software.

This tbqh. Wish you could use await in the node inspector though.

Anyone figured out an easy way to hotswap code with vsc?

I just use the chrome debugger. Has good shortcuts

Grug-brained C weenies can't handle anything more abstract than their virtual PDP-11

I use the chrome debugger for the electron frontend but I write the backend server in vscode which automatically attaches to the running process. But unlike chrome, editing something doesn't immediately apply it to the eunning node process

lmao dude run the process separately from vscode. jesus christ fucking web devs man

why do you even want to edit the code while running it? Debug is literally just to figure out what you've missed and to continue on - it sounds like you literally develop with the debugger

A S Y N C
S
Y
N
C

Why? It's gotten easier than ever before since every language worth learning now has some form of "await".

What is your problem? Just use await, it's super comfy.

Green threads are more lightweight and faster, there is no reason to block multiple threads to wait for some IO. I can't wait for real green threads in Rust.

I'm dealing with other people's code, there's not a single async/await in the program, just lines of "when(something).then(somethingelse).then(something).then(something)...", really enjoying the countless different unhandled rejections coming from wherever.

>C
Enjoy ur vulnerabilities.

>there's not a single async/await in the program
async/await appeared later than promises

Poor thing, OP would literally killed himself if he would try call by continuation.

Go wasn't the only one to implement non-blocking parallel coroutines without function modifier commitment.

Attached: 154862148872476.png (476x160, 8K)

It's not even that hard. It took me a week to learn how to use promises, but once you're done with that hurdle it becomes piss easy. All you need to do is create a promise, use it in async blocks, and you're done. It's not that hard... Node will handle the rest for you.

const myPromise = () => {
return new Promise((reject, resolve) => {
// Do stuff
// If error return reject
// if success return resolve

// You can even return objects inside. It's that easy.
return resolve("OP is a faggot");
});
}


then later on...

const myFunction = async () => {
const op = await myPromise();
console.log(op);
}


"OP is a faggot"


Seriously, just learn to use promises, then await/async. Everything else is easy. Node is easy...

node js is comfy

Attached: 8u3qCoZ.png (866x764, 755K)

>knocking Node and Python out of the running leaves only C as an option
You genuinely need to get out more. If you think Node's async/await bullshit is the ideal way of doing business, you should really check out a language with an actual concurrency story, like Clojure.

The world is filled with too many exciting possibilities for you to languish in the paradigms of shitty languages for supposed want of a better option.

Attached: 1531221712857.png (1102x1600, 362K)

Used to dislike NodeJS due to the callback hell every script seemed to end up like.

With await it's simple as fuck and code now looks pretty clean. Just like any other language.

It's not, you just don't how sockets work

You don't need return anything from executor function. Just call reject or resolve, return value is not used.

>t. room temperature IQ

user is retarded, but using the return statement is useful to stop the code execution.
If you're checking for errors, and have a reject call before the end of the promise, then you will most likely want to use return.

Sure, it isn't needed, but discarding it may create traps in the future, especially if you're chaining multiple promises inside of each other.

stackoverflow.com/questions/32536049/do-i-need-to-return-after-early-resolve-reject


Also, I'm surprised you were able to quote those other posts lol. I thought I was slick.

And you do realize that you don't need to manually write a promise, right? Async functions already wraps the return or the throw statement into a resolve/reject. The only reason to write the promise yourself is to mix it with some API that still utilizes callbacks to do non-blocking stuff.

Do't run it in vscode dumbass, use some shit like nodemon in a seperate process

>this thread
Just proves the point about low iq js "developers"

Async/await is built on promises. An async function is just a promise.

Comfy until you get users

git gud

>return resolve
>() => { return
Hows college user

>Non-blocking programming
yep, it's fucked up, specially if you jump in without anybody telling you about it (lets say from PHP)..

but it gets easier with promises and syntactic sugar like async/await

>look for eventloop videos on yt
done

vanilla callbacks aren't even that hard
js is bby tier

.t full time pajeet

Unnecessary verbosity imo. Unless you are likely to do something as retarded as adding code with side-effects after resolving/rejecting.

>especially if you're chaining multiple promises inside of each other.
Why would you ever do that? All you should do is call some legacy api and pass res/rej as an arguments(or do (err, data) => err ? rej(err) : res(data)).

topkek. FPBP

>Memes so hard, mommy tries to evict ya

>he still types function

Attached: laughing.jpg (600x536, 81K)

You're only making things worse for yourself.

Attached: images.png (500x537, 5K)

Maybe you're just dumb

Just use go. Even the creator of node and the creator of express now use and recommend go.

> using dynamically typed garbage

Fuck off brainlet. Clojure's STM is also complete garbage.

The creator of express uses Go but he's a brainlet. The creator of node dropped Go completely and is working on a Typescript runtime called Deno based on v8 and Rust.

The process runs seperately. Vscode just attaches to it. And I am working on a server with in memory state it keeps track off. Whenever I restart the server, I lose said in memory data. I find a bug, I try to write a fix for it and lose everything with the restart