22
JS-Guy
2y

it sucks!
Fuck asynchronous code because

Comments
  • 5
    lol. don't you mean because asynchronous fuck code
  • 6
    I tried replying to this post before it was made, but all I got was a 418 reply.
  • 3
    oh now I get it.
    It sucks is part of the joke haha

    I was being stupid
  • 2
    That‘s why we have await 😉
  • 1
    202 Accepted
  • 1
    @Lensflare I shit you not, I recently looked fucking everywhere for about a day for a bug that involves asynchronous JavaScript.
    I was missing a single. fucking. await.

    Basically had a function x, that takes another function y as parameter. X returns a promise that'll resolve with the returned value of y() AFTER mutating the internal state of the class that contained function x.
    ...
    let res = y();
    //Mutate state
    resolve(res);
    ...

    All fine and good, but one time I didn't think straight and passed an async function as parameter y, which then caused the whole shebang to go haywire because
    let res = y()
    Obviously didn't await the completion of y().

    Now it's
    let res = await y();

    And it cost me almost a full day at work.
    Fuck.
  • 1
    @Ranchonyx That’s why I call JS a clown language. Because a sane language wouldn’t let you compile code without an await on an async function. Or at the very least give you a warning.
  • 1
    @Lensflare yep. I would agree, see the thing is, I really like JS for that fact that it let's you mess around a lot and do things in almost any way you like. Since that even happened I've however partly switched to typescript because it quite literally makes JS not shit and tells you when something is likely to fuck up during runtime.
  • 1
    @Ranchonyx Let’s agree that TS makes JS better and disagree on the "not shit" part 😄
  • 1
    @Lensflare Hmm, whatever I'll yield for now, you've got a good point. Better it is.
Add Comment