Transcript
Page 1: CLIP Command Line InterPreter for a subset of C++

CLIP

Command Line InterPreter for a subset of C++

Page 2: CLIP Command Line InterPreter for a subset of C++

This presentation Introduction and why CLIP was made Other C++ interpreters Main ideas in CLIP C-- Other features CLIP vs. compiler Evaluation Questions

Page 3: CLIP Command Line InterPreter for a subset of C++

Introduction In teaching programming the intention is not to

teach only one programming language but problem solving in general

However, a programming language is needed for student motivation

Teacher is often not free to choose the language based on the pedagogical facts

Thus, teacher should try to make learning the chosen language as easy as possible At TUT this means C++

Page 4: CLIP Command Line InterPreter for a subset of C++

Why CLIP? Learning programming is hard When using compilers, there is much overhead

in writing the first complete programs By using an interpreter-based approach, this

problem can be avoided

Page 5: CLIP Command Line InterPreter for a subset of C++

Why CLIP? C++ is not the best language for teaching Compiler error messages are far from intuitive Compilers may be hard to use CLIP is made to smooth these problems

Page 6: CLIP Command Line InterPreter for a subset of C++

Other C++ interpreters Ch, CINT, UnderC, IfNCP None of these interpreters met our

requirements, which were Available for free Localizable Easy to use Reliable Easy integration of visualization module

Page 7: CLIP Command Line InterPreter for a subset of C++

CLIP background CLIP was developed from the interpreter used

in VIP, a Visual InterPreter for a subset of C++. VIP was made by Antti Virtanen.

Professor Hannu-Matti Järvinen is making a book where he presents a interpreter-based programming education and he needed an interpreter to support the book

Page 8: CLIP Command Line InterPreter for a subset of C++

Main ideas in CLIP Clear error messages Localization to students mother language Imperative-first approach

Page 9: CLIP Command Line InterPreter for a subset of C++

How to use CLIP In interactive mode (normal mode) you can run

the commands like inside main-function. You can still define functions and structs etc. like in global scope.

You can also start CLIP in a single file mode from command line, and then the interpreter functions in a slightly different mode.

Page 10: CLIP Command Line InterPreter for a subset of C++

C-- The language that CLIP supports, called C--, is

a subset of C++. Main features which are included:

All the basic data and control structures Pointers and references Functions Enums Structs (no methods) String, vector, cin and cout partly Math library partly

Page 11: CLIP Command Line InterPreter for a subset of C++

C-- Main features which are missing:

goto statement Classes (exceptions: cin, cout, string, vector) File streams Bit operators Exceptions Namespaces (using namespace is allowed) Templates (with the exception of vector) Overloading of function names

Page 12: CLIP Command Line InterPreter for a subset of C++

Other features CLIP adds these features compared to a

standard compiler: When an error is found from code, show the line

where the error came from Show contents of the symbol table in runtime Teachers can turn some features on or off

depending on the topic which is taught Commands for saving and loading functions to and

from external files. Faster feedback than from compiler

Page 13: CLIP Command Line InterPreter for a subset of C++

Constraints At the moment the following features can be

disabled from the interpreter: Switch statement Pointers Altering the for loop variable inside the for loop Subroutines, which have both non-const

parameters and a return value Global variables

Page 14: CLIP Command Line InterPreter for a subset of C++

Runtime error messages The interpreter detects also the following

runtime errors: Divide by zero Too deep recursion Infinite loop Reference through a null pointer Index or pointer out of bounds Use of uninitialized variables

Page 15: CLIP Command Line InterPreter for a subset of C++

CLIP vs. compiler We compared the differences between CLIP

and GNU C++ compiler (g++) by giving them the following piece of code:

#include <iostream>

#include <vector>

using namespace std;

int main() {

vector<int> i;

cout << i;

return EXIT_SUCCESS;

}

Page 16: CLIP Command Line InterPreter for a subset of C++

CLIP vs. compiler g++ gave an error which was about 80 lines

long and started with the following lines:b.cc: In function 'int main()':

b.cc:6: error: no match for 'operator<<' in 'std::cout << i'

/share/gcc/gcc-4.1.1/lib/gcc/i686-pc-linux-gnu/4.1.1/../../../../include/c++/4.1.1/bits/ostream.tcc:67:

note: candidates are: std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT,

_Traits>::operator<<(std::basic_ostream<_CharT, _Traits>& (*) (std::basic_ostream

<_CharT, _Traits>&)) [with _CharT = char, _Traits = std::char_traits<char>]

/share/gcc/gcc-4.1.1/lib/gcc/i686-pc-linux-gnu/4.1.1/../../../../include/c++/4.1.1/bits/ostream.tcc:78:

note: std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT,

_Traits>::operator<<(std::basic_ios<_CharT, _Traits>& (*)(std::basic_ios<_CharT, _Traits>&))

[with _CharT = char, _Traits = std::char_traits<char>]

Page 17: CLIP Command Line InterPreter for a subset of C++

CLIP vs. compiler CLIP gave the following error:Semantic error on line 6: Can't print type ”vector of int”

to cout.

cout << i;

^

Page 18: CLIP Command Line InterPreter for a subset of C++

Evaluation CLIP is intended to be used in the elementary

programming courses at TUT. Hypothesis is that the students will learn the

basic concepts easier than before. Although the first real experiences of the usage

of the interpreter are still in the future, we feel that the tool statisfies the requirements we have put on it.

Page 19: CLIP Command Line InterPreter for a subset of C++

Conclusions CLIP smooths the first steps in C++ by offering

to the novice programmer a limited programming language and friendly interpreter environment.

Later on a visualization module will be integrated with it and we get a system where students can visualize and debug their code.

Page 20: CLIP Command Line InterPreter for a subset of C++

Questions


Recommended