Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. The Lounge
  3. Asynchronous waaahh???

Asynchronous waaahh???

Scheduled Pinned Locked Moved The Lounge
javascriptasp-netalgorithmsquestion
30 Posts 5 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Jeremy Falcon

    Same applies on the console. If you cannot cancel a long running process then that's no bueno. If data integrity is a concern then making operations atomic should be a consideration. It's never a good idea to look up a computer more than a second or so.

    Jeremy Falcon

    P Offline
    P Offline
    PIEBALDconsult
    wrote on last edited by
    #19

    Jeremy Falcon wrote:

    never a good idea to look up a computer more than a second or so.

    Bullpuckey. Ctrl-C kills most console utilities anyway. Not a problem.

    J 1 Reply Last reply
    0
    • J Jeremy Falcon

      JavaScript has a very specialized execution engine that everything goes though. Not sure how much you wanna read up on it, but if you're curious Google "javascript event loop". Its entire runtime model is designed to be non-blocking and runs on a single thread. Makes it brain dead simple to have several worker scripts running at the same time. Don't have to worry about inter-thread communication and still get the benefit of always being non-blocking. But, there are tradeoffs and that's where those new to JavaScript usually freak out.

      Jeremy Falcon

      P Offline
      P Offline
      PIEBALDconsult
      wrote on last edited by
      #20

      Truly not interested in it. Is it time-sharing one thread in the engine? Or does each process get one thread in the engine? Unsure that the terms "blocking" and "non-blocking" truly apply to the situation.

      J 1 Reply Last reply
      0
      • P PIEBALDconsult

        Truly not interested in it. Is it time-sharing one thread in the engine? Or does each process get one thread in the engine? Unsure that the terms "blocking" and "non-blocking" truly apply to the situation.

        J Offline
        J Offline
        Jeremy Falcon
        wrote on last edited by
        #21

        PIEBALDconsult wrote:

        Truly not interested in it.

        :laugh:

        PIEBALDconsult wrote:

        Is it time-sharing one thread in the engine? Or does each process get one thread in the engine?

        If I were to give it an oversimplification, the time sharing analogy fits perfectly. It's all in one thing, but no one particular bit of code will block the app in the traditional since, since they all get their orders from the event loop. Now, all of this is under the hood of course, and most peeps will never notice what's going on.

        PIEBALDconsult wrote:

        Unsure that the terms "blocking" and "non-blocking" truly apply to the situation.

        Fair enough. When I say non-blocking, I mean something along the lines of this:

        JavaScript is also known for it’s non-blocking behavior. Non-blocking means that JavaScript doesn’t wait for the response of an API call, an Ajax request, an I/O event or a timer but moves on with the other block of code below it.

        Stuff like methods, etc. can block execution, but a lot of peeps opted for routines that do not block and that's where callback hell came from. The event loop made this a breeze to deal with because of the way it scheduled execution and returns. So, I kinda just lump sum crap when I talk about it these days. Old age stuff. :laugh:

        Jeremy Falcon

        P 1 Reply Last reply
        0
        • P PIEBALDconsult

          Jeremy Falcon wrote:

          never a good idea to look up a computer more than a second or so.

          Bullpuckey. Ctrl-C kills most console utilities anyway. Not a problem.

          J Offline
          J Offline
          Jeremy Falcon
          wrote on last edited by
          #22

          Gotta disagree there, it sends a signal like [SIGINT](https://www.gnu.org/software/libc/manual/html\_node/Termination-Signals.html) which can totally be ignored if a program hangs. I've had way more than one app just tell me "whatever bro" after smashing Ctrl+C over and over.

          Jeremy Falcon

          P 1 Reply Last reply
          0
          • J Jeremy Falcon

            PIEBALDconsult wrote:

            Truly not interested in it.

            :laugh:

            PIEBALDconsult wrote:

            Is it time-sharing one thread in the engine? Or does each process get one thread in the engine?

            If I were to give it an oversimplification, the time sharing analogy fits perfectly. It's all in one thing, but no one particular bit of code will block the app in the traditional since, since they all get their orders from the event loop. Now, all of this is under the hood of course, and most peeps will never notice what's going on.

            PIEBALDconsult wrote:

            Unsure that the terms "blocking" and "non-blocking" truly apply to the situation.

            Fair enough. When I say non-blocking, I mean something along the lines of this:

            JavaScript is also known for it’s non-blocking behavior. Non-blocking means that JavaScript doesn’t wait for the response of an API call, an Ajax request, an I/O event or a timer but moves on with the other block of code below it.

            Stuff like methods, etc. can block execution, but a lot of peeps opted for routines that do not block and that's where callback hell came from. The event loop made this a breeze to deal with because of the way it scheduled execution and returns. So, I kinda just lump sum crap when I talk about it these days. Old age stuff. :laugh:

            Jeremy Falcon

            P Offline
            P Offline
            PIEBALDconsult
            wrote on last edited by
            #23

            OK. Seems OK given the language's primary usage. But backward for general purpose development. We (many of us) keep asking for more and more cores and hyperthreading so we don't have to share a thread. From my point-of-view, the caller should be able to request blocking or non-blocking behavior as appropriate for the current task. If I have to wait for an asynchronous call to complete anyway, then why bother going through all that trouble. </rhetorical> I would much rather spin up a thread on my side as needed. It seems you don't have that luxury.

            J 1 Reply Last reply
            0
            • P PIEBALDconsult

              OK. Seems OK given the language's primary usage. But backward for general purpose development. We (many of us) keep asking for more and more cores and hyperthreading so we don't have to share a thread. From my point-of-view, the caller should be able to request blocking or non-blocking behavior as appropriate for the current task. If I have to wait for an asynchronous call to complete anyway, then why bother going through all that trouble. </rhetorical> I would much rather spin up a thread on my side as needed. It seems you don't have that luxury.

              J Offline
              J Offline
              Jeremy Falcon
              wrote on last edited by
              #24

              For sure, but it's just a different way of thinking. Personally, I like both models and think JS (despite its beginnings) has come a long way and does some really interesting stuff.

              Jeremy Falcon

              1 Reply Last reply
              0
              • J Jeremy Falcon

                Gotta disagree there, it sends a signal like [SIGINT](https://www.gnu.org/software/libc/manual/html\_node/Termination-Signals.html) which can totally be ignored if a program hangs. I've had way more than one app just tell me "whatever bro" after smashing Ctrl+C over and over.

                Jeremy Falcon

                P Offline
                P Offline
                PIEBALDconsult
                wrote on last edited by
                #25

                Never, not once. But then again, I don't write utilities which hang. And Ctrl-Z on OpenVMS.

                J 1 Reply Last reply
                0
                • P PIEBALDconsult

                  Never, not once. But then again, I don't write utilities which hang. And Ctrl-Z on OpenVMS.

                  J Offline
                  J Offline
                  Jeremy Falcon
                  wrote on last edited by
                  #26

                  I dunno what apps you've used, but clearly we've used different ones. Either way, looks like we're gonna disagree on whether or not some things should be non-blocking. I still still think non-blocking is cool and the way to go, if possible. Oh the upside, it's Saturday and there's ice cream to be had. :laugh:

                  Jeremy Falcon

                  P 1 Reply Last reply
                  0
                  • J Jeremy Falcon

                    I dunno what apps you've used, but clearly we've used different ones. Either way, looks like we're gonna disagree on whether or not some things should be non-blocking. I still still think non-blocking is cool and the way to go, if possible. Oh the upside, it's Saturday and there's ice cream to be had. :laugh:

                    Jeremy Falcon

                    P Offline
                    P Offline
                    PIEBALDconsult
                    wrote on last edited by
                    #27

                    It certainly has its uses, but that doesn't mean that it should be forced on everyone all the time. Use it when it makes sense, same with everything. Something to bear in mind is whether or not you have anything else to do while you wait. If not, you're still just waiting. Or, in a real language, I can spin up a thread and do other things in my process, zing bang Bob's your mascot.

                    J 1 Reply Last reply
                    0
                    • P PIEBALDconsult

                      It certainly has its uses, but that doesn't mean that it should be forced on everyone all the time. Use it when it makes sense, same with everything. Something to bear in mind is whether or not you have anything else to do while you wait. If not, you're still just waiting. Or, in a real language, I can spin up a thread and do other things in my process, zing bang Bob's your mascot.

                      J Offline
                      J Offline
                      Jeremy Falcon
                      wrote on last edited by
                      #28

                      PIEBALDconsult wrote:

                      Something to bear in mind is whether or not you have anything else to do while you wait. If not, you're still just waiting.

                      I'm trying to end this discussion because it's going nowhere man. I've already mentioned there is always something to do, like respond to user input or signals. It's clear you have zero desire to agree with me, so not sure why we be dragging this out man. If you need to read a 1 byte file that's guaranteed to be small, cool... assuming it's local and not network attached. I'm referring to long operations. Not sure why this needs to be dragged out.

                      Jeremy Falcon

                      P 1 Reply Last reply
                      0
                      • J Jeremy Falcon

                        PIEBALDconsult wrote:

                        Something to bear in mind is whether or not you have anything else to do while you wait. If not, you're still just waiting.

                        I'm trying to end this discussion because it's going nowhere man. I've already mentioned there is always something to do, like respond to user input or signals. It's clear you have zero desire to agree with me, so not sure why we be dragging this out man. If you need to read a 1 byte file that's guaranteed to be small, cool... assuming it's local and not network attached. I'm referring to long operations. Not sure why this needs to be dragged out.

                        Jeremy Falcon

                        P Offline
                        P Offline
                        PIEBALDconsult
                        wrote on last edited by
                        #29

                        Again, I write mostly back-end stuff, there's no user input or anything. A long-running task is still going to take a while. Querying a database for some data and writing it to a file of some sort could take minutes or longer no matter what. And I can use a different process to do something else at the same time. Or spin up multiple threads in one process to write multiple files, no big deal. That's my bread and butter. Other languages can support other needs.

                        J 1 Reply Last reply
                        0
                        • P PIEBALDconsult

                          Again, I write mostly back-end stuff, there's no user input or anything. A long-running task is still going to take a while. Querying a database for some data and writing it to a file of some sort could take minutes or longer no matter what. And I can use a different process to do something else at the same time. Or spin up multiple threads in one process to write multiple files, no big deal. That's my bread and butter. Other languages can support other needs.

                          J Offline
                          J Offline
                          Jeremy Falcon
                          wrote on last edited by
                          #30

                          A user can be a script. Clearly, you just don't wanna agree man. :laugh: But hey... ice cream.

                          Jeremy Falcon

                          1 Reply Last reply
                          0
                          Reply
                          • Reply as topic
                          Log in to reply
                          • Oldest to Newest
                          • Newest to Oldest
                          • Most Votes


                          • Login

                          • Don't have an account? Register

                          • Login or register to search.
                          • First post
                            Last post
                          0
                          • Categories
                          • Recent
                          • Tags
                          • Popular
                          • World
                          • Users
                          • Groups