GNU social JP
  • FAQ
  • Login
GNU social JPは日本のGNU socialサーバーです。
Usage/ToS/admin/test/Pleroma FE
  • Public

    • Public
    • Network
    • Groups
    • Featured
    • Popular
    • People

Conversation

Notices

  1. Embed this notice
    Alex Gleason (alex@gleasonator.com)'s status on Monday, 20-Feb-2023 13:35:33 JST Alex Gleason Alex Gleason

    Why is this an async function? It wants every function above it be async. Why not just make all functions async by default in JavaScript? And then get rid of the keywords. Wait…

    In conversation Monday, 20-Feb-2023 13:35:33 JST from gleasonator.com permalink

    Attachments


    1. https://media.gleasonator.com/12b0df760e2e58f5a2e702439124cb4c4677db6b6eb88a1b3141bf2f2c24b853.png
    • Embed this notice
      Alex Gleason (alex@gleasonator.com)'s status on Monday, 20-Feb-2023 13:36:43 JST Alex Gleason Alex Gleason
      in reply to

      You can easily call setTimeout(() => myFunc()) to make any function async. But you can NOT turn an async function into a sync one.

      In conversation Monday, 20-Feb-2023 13:36:43 JST permalink
    • Embed this notice
      Mercurial (mercurialblack@leafposter.club)'s status on Monday, 20-Feb-2023 13:36:48 JST Mercurial Mercurial
      in reply to
      man i hate javascript
      In conversation Monday, 20-Feb-2023 13:36:48 JST permalink
      Alex Gleason likes this.
    • Embed this notice
      Ako Suminoe :njp: (realakosuminoe@poa.st)'s status on Monday, 20-Feb-2023 14:04:04 JST Ako Suminoe :njp: Ako Suminoe :njp:
      in reply to
      @alex According to this article, WebCrypto heavily uses async operations because they can be slow (out of necessity), and they don't want to block rendering or input.

      webkit.org/blog/7790/update-on-web-cryptography/
      In conversation Monday, 20-Feb-2023 14:04:04 JST permalink

      Attachments

      1. Domain not in remote thumbnail source whitelist: webkit.org
        Update on Web Cryptography
        from @alanwaketan
        Cryptography is the cornerstone of information security, including various aspects such as data confidentiality, data integrity, authentication, and non-repudiation.
      Alex Gleason likes this.
    • Embed this notice
      Alex Gleason (alex@gleasonator.com)'s status on Monday, 20-Feb-2023 14:05:41 JST Alex Gleason Alex Gleason
      in reply to
      • Ako Suminoe :njp:

      @RealAkoSuminoe Great find, but here’s what I don’t get: you can turn any sync function into an async function by calling setTimeout on it. However, it’s IMPOSSIBLE to turn an async function into a sync function. So why not make everything available as a sync function? Or even let us force a function to be sync? The bullshit StackOverflow answers say “because JS is an inherently asynchronous language”, but that doesn’t add up.

      In conversation Monday, 20-Feb-2023 14:05:41 JST permalink
    • Embed this notice
      Ako Suminoe :njp: (realakosuminoe@poa.st)'s status on Tuesday, 21-Feb-2023 00:40:16 JST Ako Suminoe :njp: Ako Suminoe :njp:
      in reply to
      @alex I generally don't even look at SO because its full of bad takes.

      Making it possible to do turn an async operation into a sync operation would become a really easy way for developers to do the wrong thing, and potentially block the main thread with a long running operation. The web specs are designed defensively for an environment where there are lots of 3rd party scripts on most pages, each with the ability to theoretically break things. It may suck for some things, but giving developers an easy way to do the wrong thing guarantees that people will do the wrong thing. We want more things to be async, not less.

      We can't just make every function asynchronous and get rid of async/await all together because we still need to have a Promise primitive to get any benefits from it. You couldn't do something like this if everything were automatically await'ed:

      var taskA = heavyTask1(); // starts A
      var taskB = heavyTask2(); // starts B in parallel with A

      var resultA = await taskA;
      var resultB = await taskB;
      // OR
      var [resultA, resultB] = await Promise.all([taskA, taskB])

      If taskA encounters a network request, it can run taskB while it waits for the result and then switch back to taskA.
      In conversation Tuesday, 21-Feb-2023 00:40:16 JST permalink
      Alex Gleason likes this.

Feeds

  • Activity Streams
  • RSS 2.0
  • Atom
  • Help
  • About
  • FAQ
  • TOS
  • Privacy
  • Source
  • Version
  • Contact

GNU social JP is a social network, courtesy of GNU social JP管理人. It runs on GNU social, version 2.0.2-dev, available under the GNU Affero General Public License.

Creative Commons Attribution 3.0 All GNU social JP content and data are available under the Creative Commons Attribution 3.0 license.