Why OCaml's threading is considered as `not enough`?

后端 未结 2 1987
别那么骄傲
别那么骄傲 2020-12-31 05:59

It seems many people are saying OCaml does not have a good capacity for concurrency and it is also not good for web server applications.

I am currently learning oca

2条回答
  •  情书的邮戳
    2020-12-31 07:03

    See Concurrency vs. parallelism — What's the difference?. OCaml's threads offer concurrency, as you can have the next function start before the previous one is finished. But OCaml does not offer parallelism, so when that second function starts, the first one has to be put on hold. Two threads cannot run simultaneously, so multiple CPU-bound computations in a process will block each other, and you can't max out all your CPU cores in one process.

    That's people's beef with OCaml's threading. Does it mean you can't use OCaml for something like a server? No. It's something you will have to take into account in your server design, but it's not generally a showstopper. Heck, Node.js is straight-up single-threaded, yet its main purpose is creating servers.

提交回复
热议问题