We often hear about parallel programming and parallel execution to provide a sustainable architecture where multi-tasking thrives. However, most people consider the aspects of Parallelism and concurrent programs similar, which seems correct in the verbal matter, but they vary in the technical applications of programming.
Through this blog, we will take a quick dive into the definition of concurrency and how Golang (A compiled programming language designed at Google) provides means of supporting concurrency in a lightweight manner inside an application.
The difference between Concurrency and Parallelism
Before we dive into technical details, we might need to highlight a few thoughts since the terminology of both can easily mislead people if they don’t have a fair share of developing/running multiple processes simultaneously, so they might get easily confused by the upcoming terms. so first things first, let’s start with defining parallel execution Vs. concurrent processes:
Parallelism in Software Architecture
As a general term, it means that you want to do multiple actions at the same time, in programming terms, it mainly refers to application tasks divided into smaller sub-tasks that are being processed simultaneously. Using multiple processors to achieve this helps in a faster execution in computational speed than running the processes sequentially.
An example of parallel processes would be in any normal scaling scenario where you have an operation and you want to increase work execution on multiple machines to run in parallel rather than waiting on a single machine to execute them on-by-one
Concurrency in Golang Software Engineering
Being ‘concurrent’ as a term usually refers to simultaneously, which verbally is equal to ‘parallel’ but in our technical terminologies, they have their differences, running concurrent processes relates to running more than one task independently in overlapping periods; meaning this might eventually reach each other but that’s not the target here, running concurrent processes means that they can run in no particular order. So a concurrent program has more flexibility than parallel execution.