Presentation is loading. Please wait.

Presentation is loading. Please wait.

CLIP Command Line InterPreter for a subset of C++.

Similar presentations


Presentation on theme: "CLIP Command Line InterPreter for a subset of C++."— Presentation transcript:

1 CLIP Command Line InterPreter for a subset of C++

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

3 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++

4 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

5 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

6 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

7 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

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

9 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.

10 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

11 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

12 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

13 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

14 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

15 CLIP vs. compiler We compared the differences between CLIP and GNU C++ compiler (g++) by giving them the following piece of code: #include using namespace std; int main() { vector i; cout << i; return EXIT_SUCCESS; }

16 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 & std::basic_ostream<_CharT, _Traits>::operator & (*) (std::basic_ostream &)) [with _CharT = char, _Traits = std::char_traits ] /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 & std::basic_ostream<_CharT, _Traits>::operator & (*)(std::basic_ios &)) [with _CharT = char, _Traits = std::char_traits ]

17 CLIP vs. compiler CLIP gave the following error: Semantic error on line 6: Can't print type ”vector of int” to cout. cout << i; ^

18 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.

19 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.

20 Questions


Download ppt "CLIP Command Line InterPreter for a subset of C++."

Similar presentations


Ads by Google