Exercises and Discussion Topics
-
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.
-
Learn the regular expression syntax and the related
find commands provided by the editor you are using.
-
Write regular expressions to locate integers, floating point numbers,
and a given word within a character string.
Where would you use such expressions?
-
Learn about and experiment with the tag facility of the editor you
are using.
-
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.
-
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.
-
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.
-
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?
-
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.
-
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.
-
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.
-
Format one of the course's example files using a pretty-printer.
-
See if your editor supports user-defined syntax coloring.
Define syntax-coloring for a language that you use and the editor
does not support.