G2 - A Design Language To Help Novice C Programmers Geoffrey. P. Ellis Centre for Database Access Research, School of Computing and Mathematics, University of Huddersfield Queensgate, Huddersfield, HD1 3DH e-mail g.ellis@hud.ac.uk Geoffrey. R. Lund Department of Mathematical and Computer Sciences, University of Abertay Dundee, Bell Street Dundee, DD1 1HG e-mail MCTGRL @dct.ac.uk Abstract The aim of most introductory programming courses is not to teach the syntax of a programming language but to teach the principle of program design using the chosen language as.a vehicle for student expression. Teaching C as a first language is perceived to be a hard task because of the difficult syntax and unhelpful compilers. It was felt that students would have difficulty with the syntax and never be able to look beyond the syntax to consider the underlying principles of programming. The authors’ solution to combat this problem was to develop a design language, G2. A design language is a language in which a program design can be expressed easily rather than a language such as Pascal or C where details of implementation dominate the program design. The problem with design languages and pseudo codes is that the student cannot see the results of the design unless it is translated into program code. If the student does the translation themselves then they become confused between the two languages and are hindered by the syntax of each. The G2 language is designed to be translated into C automatically. Thus the students only have to learn one language at the start of their studies. Built into the language are a number of features that promote good programming discipline but are not enforced by many programming languages. There is facility to separate abstract data types from the top down development of the code. The use of global variables is not allowed although types and constants are allowed to be global. The G2 code is designed to be read by people and the design is presented in a natural top down manner. This is in contrast to PASCAL where reading the code top down does not give the reader much insight into the program structure. The educational development is in three stages. Initially Students learn the G2 language and use the translator to produce programs for them. The C code matching the design is compiled and run. Once the students gain some familiarity with the language they are introduced to C. This is done using comparisons of the G2 design and the resulting code. Finally as there is no market for G2 programmers, the students have to learn to program in C. Hence in the final stage of the course the automatic translator is unavailable and the students are expected to design the program on paper and translate this into C themselves. The translation rules used by the G2 translator are used by the students to do this task. An informal evaluation of the results of the G2 experience is presented. 1. Introduction Many of the students arriving at University to study computing have some background in programming. This may be GCSE standard grade, A-Level or BTEC modules. Of these many will already know Pascal. Traditionally introductory programming courses have taught Pascal but now with the change in intake this causes problems. Students who know Pascal switch off from the course at the beginning thinking that they know everything. Unfortunately they do not switch on again when the rest of the class passes their knowledge threshold. A recent survey (Jones & Pearson 1993) shows that a number of universities are changing away from Pascal to other languages. In our case the language C was chosen. C is in widespread use throughout the industry, and is popular with students who think it a “real” language. Also C is not normally taught at sub- degree level. The aim of introductory programming languages is not to teach the syntax of a programming language but to teach the principles of program design using the chosen language as a vehicle for student expression. There are many perceived problems of teaching programming using C. The main one being the idiosyncratic nature of the syntax. This the authors thought would swamp the students and they would concentrate on program syntax rather than the programming principles that are required. The solution was to develop a design language, G2, which would allow the students to express the design of their programs in a clear manner and later translate this design to C. To help with the design a translator was written that automatically translated the G2 code to C. 1