Exercises and Discussion Topics

  1. If you are using Windows try installing a Unix-type operating system on a spare (old) computer, or disk drive, or disk partition. Linux (e.g. Ubunutu), FreeBSD, and Solaris are some possible choices for a free Unix-like operating system. Alternatively, install on your Windows machine the Cygwin environment, which offers comparable functionality.
  2. Learn the regular expression syntax and the related find commands provided by the editor you are using.
  3. Write regular expressions to locate integers, floating point numbers, and a given word within a character string. Where would you use such expressions?
  4. Learn about and experiment with the tag facility of the editor you are using.
  5. Often programmers identify code parts that need further attention using a special marker such as XXX or FIXME. Search for, count, and examine such instances in the source code tree.
  6. Propose a simple way to calculate a "measure of similarity" metric for two different files. Apply this metric to files in the source collection that share the same filename and create a list of files that could benefit from a structured approach towards code reuse.
  7. Identify code-reading tasks that can benefit by a custom-built tool. Briefly describe how each such tool could be built. Implement one of the tools you described.
  8. Provide (or, better yet, locate) code examples for some of the compiler warnings discussed in this lecture. Can your compiler detect them? Are there legitimate reasons for using such code?
  9. Many warnings generated by C compilers would be treated as errors in other strongly typed languages. Find a list of warnings that your C compiler generates, and mark those that identify code with legitimate uses. See how many of them are detected in other languages.
  10. Run some of the winning IOCCC entries through the C preprocessor and try to understand how the program works and how the original obfuscation was achieved.
  11. Compile a program (with compiler optimizations disabled) and read the generated symbolic code. Repeat this process with all optimizations enabled. Describe how arguments are passed between functions in each case.
  12. Format one of the course's example files using a pretty-printer.
  13. See if your editor supports user-defined syntax coloring. Define syntax-coloring for a language that you use and the editor does not support.