This essay was originally written for NHS4001: Critical Reflection (Old) | (nus.edu.sg), a reflection class at the end of university.

Concurrent programming is essentially regular computing done simultaneously. Concurrent programming allows a programmer to instruct the computer to cleverly multitask by interleaving tasks. This multitasking is akin to a person taking out the trash while waiting for their water bottle to fill up. However, this added optimization of multitasking comes with a set of challenges that do not exist in the serialized computational paradigm. To demonstrate this concept, the authors wrote this piece with some sections, colored in red and blue, that are written in a non-linear manner and may be read in any order so long as some conditions are met. Such conditions are called memory models, and these memory models ensure that the execution order satisfies a predefined order when looking at parts of its execution. The analog for this post will be the paragraphs that are colored black and serve as checkpoints to prior paragraphs, requiring all previous paragraphs to be read before proceeding. The shared experience for both authors lies quite squarely in the module CS3211 Parallel and Concurrent Programming, which touches on some of the more important fundamentals of concurrent programming and correspondingly gave the authors useful insight into how such concepts could potentially be applied outside of the domain of computer science.

For Adam, the manner in which the code was written in the module was what drew his attention: there was a new syntax that would never have made sense in a serial programming paradigm. Just by changing how the language was structured, it was possible to make it so that the written program had to be concurrently executable. Compared to the more traditional languages, there was a reduced need to micromanage how these programs would run simultaneously. Thus, the thinking put into writing a program could solely be focused on the consistency of the program. This was interesting since it opens the possibility for an implicit understanding instead of having to explicitly teach complex fundamentals.

Figure 1: Lecture Slide from CS3211 explaining how a CPU executes concurrent code by slicing tasks into subtasks that are interleaved

Figure 1: Lecture Slide from CS3211 explaining how a CPU executes concurrent code by slicing tasks into subtasks that are interleaved

For Raivat, the core idea of concurrent programming – of efficiently doing multiple things at once – was the key highlight and learning point. Before taking this module, Raivat usually avoided multitasking as research (Bradberry, 2014) has shown evidence against multitasking for better productivity for humans. However, seeing the clever interleaving of tasks in concurrent programming, as illustrated in figure 1.0, was particularly insightful. As seen in the figure, with concurrent programming, we break a task into multiple parts and interleave them in an order that is efficient. The CPU in the figure could be a person wanting to complete task 1 (fill water bottle), task 2 (cook ramen), and task 3 (drink water). The person cleverly places the bottle for filling at first, then switches to put ramen on the hot pot, goes back to close the tap and drinks water, and then devotes attention back to cooking. This efficiency in completing tasks inspired Raivat to re-think how he prioritizes and completes his tasks in general.

Coming from the same experience, both authors took their learnings in opposing directions, one looking at the practical approaches that concurrency as a high-level concept offers and the other looking at the manner in which concurrency was presented. Unsurprisingly, even with the same source material, the experience and correspondingly the takeaways the two authors have would also diverge from this point on.

For Adam, the language used to construct the concurrent programs holds distinct importance in the understanding of previously learned concepts. For instance, standard sorting algorithms in their traditional languages are not compatible with the concurrent model of programming. However, if they were written in a language like Rust, where consistency of the sorted memory is guaranteed, then all it requires is just rewriting it in a different language for it to work concurrently, and no additional thought has to be put into it. It is not a new concept that an identical lexical representation of the same idea can be interpreted in dramatically different ways. In French, 80 (quatre-vingts) is understood to be 4 (quarte) times 20 (vingt), while in English, it is understood to be 8 times 10. Thus, if someone were going to teach a child to divide 80 by 4 in both languages, they can almost be certain that the child would sooner understand it in French than English.

For Raivat, while the focus was on the core idea of clever multitasking by interleaving tasks, the learning did not stop at this general idea. Some of the key questions in concurrent programming are: given the many possible interleavings of tasks, which one is the most efficient? Since not all interleavings will necessarily yield the correct output (tasks are not always commutative), which ones will? These questions helped Raivat think critically about the order of tasks in his own life. For example, if there is a need to follow up with someone via email, this task of sending an email should be of the highest priority since it then frees him up for working on other tasks while increasing the likelihood of faster response from the recipient.

Both experiences distill different aspects of concurrent programming into an applicable form in order to utilize the learning points effectively outside of the niche environment it was taught in. If we were to focus on the syntax itself, parallels to natural language could be drawn, and correspondingly any applications of natural language analysis could use similar viewpoints as what was encountered in concurrent programming. If the focus was instead on the organization of concurrent programs and their sub-processes, the immediate parallel would be with task organization and resource management, helping us to understand the macro view of how different resources can be organized to allow for efficient use of time and money. Both perspectives are equally valid, stemming from the same concepts and yet completely different in their essence, which also leads to applications that differ.

For Adam, the application is essentially about how the process of learning about concurrent programming could be superimposed onto other aspects of life. Applying that change in language forces the mind to alter its perspective on how the fundamentals are understood in order to gain new insight from old material. This could range from learning what each martial arts move is called in its native language to better understand how they should be executed to looking out for the nuances between the design of systems from different countries based on how their local language is structured. These new perspectives to consider could very well help link previously disparate concepts that would be better expressed in another language.

For Raivat, the application of concurrent programming is about the core idea of cleverly doing multiple tasks at once. This application is important for Raivat because he is a self-described optimization nerd who likes to maximize productivity. As an ambitious individual who believes in setting above-par goals, Raivat is now optimistic about how concurrent programming can aid in continuing with a hustle culture lifestyle. For example, Raivat is now more inclined to shift his focus away from his high-focus tasks, albeit for a short while, to cater to other non-work-related tasks that require attention.

How Adam and Raivat apply their takeaways from the class to the outside world shows how each individual’s goals can lead them to have different takeaways. For Adam, understanding the language mechanics and what transpires ‘under-the-hood’ as a program executes is crucial to his future job as a cyber security professional. For Raivat, a yearning desire to someday have a startup makes him interested in looking at the macro-view for all strategies he encounters and keeping them in his toolkit for the day he starts a company or is in a leadership position. Therefore, even though both authors’ experiences and academic profiles are extremely similar, there is no doubt that the takeaways are very different. For Raivat, the focus was more on directly applying the concept of concurrent programming to daily life in order to optimize aspects that were previously thought optimal. In Adam’s case, there was more of a focus on how thinking about concurrent programming had to differ from traditional programming and then applying that change in thinking to other aspects of life to identify new ways to tackle situations. Both conclusions take what the corresponding authors thought to be the important aspects of an academic concept and apply it to other domains in life. Both the cases show how a concept as niche as concurrent programming can be extrapolated to be used in other areas outside of Computer Science. The authors were pleasantly surprised with this extrapolation as neither of them had expected it from a class that is considered a part of a specialized track at the School of Computing. Through this experience, the authors also learn how their individual goals direct them to have different takeaways and to be mindful of what they might be missing by their focus as well.

References

Bradberry, T. (2014, October 8). Multitasking damages your brain and career, new studies suggest. Forbes. Retrieved April 25, 2022, from https://www.forbes.com/sites/travisbradberry/2014/10/08/multitasking-damages-your-brain-and-career-new-studies-suggest/