Open Access. © 2018 Tosin P. Adewumi, published by De Gruyter. This work is licensed under the Creative Commons Attribution- NonCommercial-NoDerivs 4.0 License. Open Comput. Sci. 2018; 8:115–122 Research Article Open Access Tosin P. Adewumi* Inner loop program construct: A faster way for program execution https://doi.org/10.1515/comp-2018-0004 Received March 16, 2018; accepted May 18, 2018 Abstract: Loops are repetitive control structures in pro- gramming languages. They are used extensively in many algorithms. The for-loop and while-loop exist, where the former is repeated a number of times while the latter is repeated until a condition is met. Some have asked if re-arranging loops in certain ways can change a pro- gram’s speed to produce machine-independent optimisa- tion. Therefore, this research sought to find out if there is any speed difference in a single loop of computations and a loop with an inner loop of same computations. Greater focus is on inner for-loop. The research used a compara- tive study method in order to evaluate the primary data obtained from running several tests in four popular pro- gramming languages: C, C#, Python and R. The Python im- plementations were further tested on Ubuntu 16 for com- parison with results from Windows 10. Results established that, across all languages, there were more computations performed per unit time with an inner for-loop than no in- ner loop, meaning, given the same number of computa- tions to perform, a loop with an inner for-loop will finish faster. The inner while-loop didn’t perform so well, though. This study will help developers in making better choices with programming language and style. Keywords: for loop, while loop, programming languages, Windows 10, optimisation 1 Introduction Speed is an advantage when it comes to computing and it is a very important factor computer and smart phone man- ufacturers are quick to showcase when marketing their latest products. The choice of programming language by developers or programmers is also heavily influenced by *Corresponding Author: Tosin P. Adewumi: Computer Sci- ences Department, University of Lagos, Lagos, Nigeria, E-mail: adewumi_tosin@hotmail.com speed, though it is by no means the only criterion for se- lecting programming languages [1]. Besides choice of pro- gramming language in developing a software program, how lines of codes are implemented play critical role in de- termining the speed of the program. Two equivalent pro- grams, in terms of purpose written in the same language but implemented in different styles can perform at con- siderably different speeds on the same platform. This re- search work focuses on a tiny but significantly influential aspect of programming, which are loops. The research an- swers the question “Is there any speed difference in a sin- gle loop of computations and one with an inner loop of same computations?” Hence, the objectives are to deter- mine if a nested inner loop of one level makes a difference in terms of speed and therefore, computational attempts and whether there are noticeable differences across pro- gramming languages and operating systems. The main contribution of this research is the provi- sion of confirmation that there is general better speed per- formance or optimisation with inner for-loops than other- wise. This is true for the programming languages and oper- ating systems tested, though Windows 10 is the predomi- nant focus in this research. Some programming languages performed relatively better than others. This will help pro- grammers in making better choices with programming style and programming language among other things. The research uses the method of comparative study to critically analyse the results from the various tests. The scope of the work will be restricted to a brief review of programming languages, loops, optimisation techniques and tests con- ducted in some popular programming languages and op- erating systems. 2 Literature review Von Neumann computer architecture influenced program- ming languages available today since all-purpose comput- ers in use today and many years ago are based on such architecture [2]. Step-wise program execution reflects the adaptation of programming languages to this architecture. Although there are many programming languages, they Unauthenticated Download Date | 8/15/18 9:23 AM