International Journal of Computer Applications (0975 – 8887) Volume 85 – No 9, January 2014 45 Using Memory Transfer Language (MTL) as a Tool for Program Dry-running Leonard J. Mselle Computer Science The University of Dodoma Dodoma, Tanzania ABSTRACT In this paper, the use of visualization techniques in teaching and learning programming is revisited. It is demonstrated that MTL can be used to visualize most of programming aspects. MTL, as a tool for dry-running programs, tracing and correcting codes is used in a class experiment. Results show that MTL can be used in teaching novice programmers to improve their coding abilities. General Terms Teaching, Learning to program Keywords Program visualization, Memory Transfer Language (MTL), comprehension, program dry-running 1. INTRODUCTION Flow charts, pseudo codes and dry-running are among the traditional tools used for programming comprehension. Disciplines with a high dose of abstractness such as mathematics, physics and programming are usually taught with a combination of various tools and concrete models to simplify both teaching and comprehension. In general, it can be said that, for a subject of high complexity such as programming, the necessity for invention of various concrete models and tools for simplification of teaching, is highly demanded. For computer programming, compared with a discipline like mathematics, the number of tools and the variety of approaches is still very low. The reason why invention and application of varieties of teaching models and techniques are so much underdeveloped in programming, may be due to the reality that machine debugging and compilation have traditionally been assumed to be sufficient in taking care of the business. However, various research findings report that, teaching and understanding programming has stubbornly remained an uphill battle that does not seem to get an easy solution [1], [2]. Recent attempts to introduce visualization as a technique for teaching programming have produced promising results [3], [4], [5]. However, most of the visualization techniques are still very much entangled with machine mechanisms. In addition, visualization in general is still underdeveloped. While machine-driven visualizations are pivotal in program debugging and comprehension, they have a negative effect of inducing hopelessness to a weak novice programmer. Perkins et al [6] report that novices often attribute human-like reasoning to the machine. This has a negative influence in debugging because when the compiler reveals bugs, a novice who does not have confidence in his debugging capabilities feels that the machine is stubbornly rejecting to understand what the novice wants the machine to understand. Researchers suggest that if students were patient enough to soft-track or dry-run their codes, they would succeed in discovering the errors and proceed to successfully produce a correct code [1], [6]. Program dry-running and flow charts are the traditional tools that are used for manual tracing of the code to verify its correctness. Each of these methods have had limited success in their application. Flow charts are used to generally represent the logic that the programmer wants to put in the machine in the form of statements. Flow charts however, lack the means to show how correct a given line of code (the syntax) is. 2. PROGRAM DRY-RUNNING To execute a program by hand, writing values of variables and other run-time data on paper, in order to check its operation or to track down a bug is called dry-running. A dry- run is an extreme form of desk check and is practical only for fairly simple programs and small amounts of data. Most of visualization techniques rely, to a certain degree, on program dry-run which constitutes a mental run of a computer program, where the computer programmer examines the source code one step at a time and determines what it will do when run. In theoretical computer science, a dry-run is a mental run of an algorithm, sometimes expressed in pseudo code, where the computer scientist examines the algorithm's procedures one step at a time. In most cases, the dry-run is frequently assisted by a table (on a computer screen or on paper) with the program or algorithm's variables on the top. Dry-running is similar to proof reading. It is based on the assumption that the programmer knows for sure how correctly the given line should be written. 2.1 Dry-running and trace tables By their nature, dry-run and trace tables normally can go together. Combining trace tables and dry-run evolved as a traditional tool and method for code verification. Trace tables were used for debugging and teaching programming when Pascal and FORTRAN were the teaching languages [7]. The use of trace tables for code dry-running is demonstrated in Figure 1. Fig 1: Dry-running a code segment using a trace table Using the trace table, in Figure 1, the program is mentally run, and values associated with variables x and i are checked at each step of the code execution. Code segment int x=0; i x int i=1; 1 1 while(i<5){ 2 3 x=x+i; 3 6 i++; 4 10 } Trace Table