Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

No, because that's a completely different thing.

Throwing your code at a compiler/CPU and saying "Here! you decide what order to execute this in", means I have to write MORE code to deal with that.

eg asyc/event programming => less code, less complexity, more efficient

Managing memory yourself would mean writing more code and more complexity.

So it's comparing apples to inverse apples.



I don't get what you're saying to be honest... When you have 2 actors that are executing "independently", you're just doing (very-pseudo-code) this: (assume recv == wait_for_N_bytes_or_timeout_after_M_seconds)

    case recv(10, 5) in
        timeout -> handle_this_and_throw
        data -> do_something(data)
in do_something you've already made a progress to another state (unless you want to handle the FSM explicitly, then nothing is preventing it) and can throw to cleanup.

In an event based scenario:

    def got_some(data):
        buffer += data

        switch(current_processing_state):
            case state1:
                buffer = try_to_handle(buffer)
            case state2:
                ....
Now you might have enough data in the buffer to handle it, or you might not. You cannot check it before, because each state might need different amount of data. Try to insert timeouts into this code in a way that also closes the in-state resources now... yeah... forget about throwing exceptions really. Any internal exception thrown by bad code is very likely to hit your code in a bad way unless you handle all possible exceptions in every state separately.

I see more code and more complexity in event style. Care to provide some counter-example? (and I'm not saying it's not possible - just haven't really seen one yet)


That's strange. I always get a headache when I have to think about order of execution (e.g. in C or Ocaml). Haskell (which is not parallel by default, so it's slightly off-topic here), manages the order for me, and I feel I have an easier time writing code, less code.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: