Hacker News new | ask | show | jobs
by kachapopopow 481 days ago
Tell that to inexperienced developers or making a massive single-thread project have multi-threaded capabilities.
2 comments

I've been that developer making a single-threaded app multi-threaded. Best way to learn though!
Multi-threading - ain't nobody got time for that.
Yeah, our software politely waits for one customer to finish up with their GETs and POSTs before moving onto the next customer.

We have almost one '9' of uptime!

There are better ways than threading.
Yeah, like pretending you aren't
I don't know what you mean.
If you write:

  int balance = 0;
  int get {...}
  void set(int balance) {...}
  void withdraw(int amt) {
    if amnt <= balance {
      balance -= amnt;
    }
  }
it will be flagged immediately in code review as a race condition and/or something that doesn't guarantee its implied balance>=0 invariant. Because threading.

But lift the logic up into a REST controller like pretty much all web app backends:

  GET /balance/get
  POST /balance/set
  POST /balance/withdraw
And it will sail straight through review. (Because we pretend each caller isn't its own Thread.)
async/await, for example.