My class had a discussion prompt that stated "Many programming languages, especially older ones, provide no language support for concurrency. C and C++ are examples of such languages." I thought C had the fork() command, maybe it's talking about an older version? I was then curious whether there were more languages that don't support it and couldn't find anything on Google.
2 Answers
fork()
is a posix API, not a primitive of the C language. Not all OSes even implement fork()
. For example Windows doesn't.
In C++ multi-threading support was only recently standardized and, AFAIK, there is no standard way to execute another process.
Programming languages that have concurrency built-in are in fact rare, where it is handled it is usually bolted on (like using the POSIX API around fork(2)
and process handling or the equivalent functionality under Windows in C, this even if the language is used routinely to write concurrent programs like operating system kernels) they are becoming more common with the current tendency of CPU performance increasing not by making operations faster but doing many operations in parallel (multi core, hyperthreading, ...).
Part of the reason is that we are wired to think in terms of doing one thing, then another, concurrency isn't really natural. Synchronization is a complex matter (see e.g. Downey's The Little Book of Semaphores, take a peek at the variety of primitives available for different uses in the Linux kernel). What are useful, easy to use primitives, that are efficient in a wide enough variety of uses and platforms is still not settled.