1. Getting Started in CMPT 125
1.1. What is CMPT 125?
CMPT 125 is a courage in computer science for people who already know
how to program in a language like C or Python. It uses C++ to teach
programming and a little bit of basic theoretical computer science
(such as how to evaluate basic searching and sorting algorithms).
By the end of this course students will be able to:
- Define basic terms such as: programming, specification,
implementation, debugging, testing, tracing, correctness, static
memory, stack memory, free store (heap) memory, algorithm, compiler,
linker, makefile, etc.
- Apply the basic elements of good coding style to programs:
indentation and whitespace, self-descriptive identifiers, comments,
and appropriate use of language features.
- Understand and apply basic programming idioms, such as flag
variables, state variables, sentinels, and sub-array ranges.
- Apply basic error checking techniques (such as exceptions, or error
codes) to validate input and check for other error conditions.
- Specify, implement, test, trace, and debug:
- Small to medium size programs that use literals, variables,
numeric and string types, expressions, statements, if-statements,
loops, functions, recursion, exception handling, objects, classes,
setters/getters, constructors/destructors, free store memory,
console and disk I/O, compilers, linkers, and make files;
- Simple sequence-based algorithms such as finding the min/max/sum,
locating items using linear search or binary search, counting
occurrences of a particular value, and sorting using simple
algorithms such as linear insertion sort or selection sort.
- A dynamic sequential data structure, such as a stack or queue,
that uses the free store.
- Simple sequence-based algorithms using pre/post conditions,
invariants, assertions, and unit tests.
- Estimate the running-time of simple sequence-based algorithms by
counting key instructions both empirically and theoretically.
- Give examples of embedded systems, and define the basic issues in
embedded systems programming (correctness, fault-tolerance,
predictability, etc.) that distinguishes it from regular
programming.
This is not a “bird” course. Programming is about problem-solving, and
so it requires concentration, the ability to think logically, and
creativity. In practice, most students find that this course is a lot
of work.
This courses combines theory and practice, with a bias to practice. We
assume that most students in this class will one day be professional
programmers who will be writing programs for other people. Our goal is
to learn how to create robust, high-quality program that are not only
efficient and easy to use, but handle errors gracefully and can be
easily understood an extended by other programmers.
1.2. Why C++?
A question that some students ask is “Why C++?”. Well, we have to pick
some language, and C++ is one of the most popular programming
languages ever created. It has a reputation for high-performance and
also good abstraction tools (i.e. things likes classes and
templates). It is also known for being a big and complex language that
is difficult to master in its entirety: almost nobody knows all the
rules and features of C++.
Thus we won’t be learning all the features of C++ in this
course. Instead, we will stick to a small but useful subset of C++
that will let us write pretty good small programs, and also help us
read and understand larger ones.
In practice, C++ is often used for writing low-level applications
where performance is important. For example, C++ is used in many
applications,
such as:
- The Mars rover
- Graphics (e.g. AAA video games)
- Photoshop
- GUIs
- Operating systems
- Compilers (e.g. C++ is a good language for writing a C++ compiler!)
- Chip design and manufacture
- Scientific computing
- and many more
Bjarne Stroustrup,
the inventor of C++, has given a number of interesting interview where
he explains the rationale behind the design of C++. For example:
- video interview that
discusses a number of topics related to C++ and programming;
- another video interview where he
discusses the intended uses of C++ at the start, and then in the
second part discusses a couple of new C++ features in more detail.