Software Types and Language Translators: Question 9
Syllabus 4.2
A student is writing a program in an IDE for a class project.
Feature 1: As the student types, keywords such as IF and WHILE automatically appear in bold blue text, text written between quotation marks appears in green, and each line inside a loop is automatically indented one level further than the line before it.
Feature 2: Before the student even tries to run the program, a wavy red line appears under a line where a closing bracket has been left out, together with a message stating the line number and explaining that a bracket is missing.
(a) Identify the IDE feature shown in Feature 1, and state two specific things it is doing to help the student read and write the code. [3]
(b) Identify the IDE feature shown in Feature 2, and explain how it differs from simply running the program and having it crash or behave incorrectly. [3]
Show worked solution Hide worked solution
Worked solution
Part (a): Feature 1, the editor
The colour-coding of keywords and quoted text, together with the automatic indentation of lines inside a loop, describes the (source code) editor. Specifically it is providing:
- Syntax highlighting. Displaying keywords, quoted text and other parts of the code in different colours or styles so that the different elements of the program are easy to tell apart at a glance.
- Auto-indentation. Automatically indenting lines that belong inside a construct such as a loop, so the code’s structure is visually clear without the student manually adding spaces.
Part (b): Feature 2. Error diagnostics
Detecting the missing bracket and describing exactly where and what the mistake is, before the program is even run, describes error diagnostics. This differs from simply running the program and having it crash or produce wrong output because error diagnostics finds and describes the mistake immediately, giving the exact line number and a description of the problem. If the student instead had to rely on running the program, they would only find out something is wrong once it fails or misbehaves, and would then have to work backwards from that failure to guess where in the code the actual mistake is, a slower and less direct process.
Final answers
- (a) The editor, providing syntax highlighting (colour-coding keywords and quoted text) and auto-indentation (automatically indenting nested lines such as those inside a loop).
- (b) Error diagnostics, which pinpoints the exact location and nature of a mistake, such as a missing bracket, before the program runs, unlike a crash, which only shows that something is wrong after execution, without directly stating where or why.