CSE 701:

Foundations of Modern Scientific Programming

McMaster University, Fall 2022

Prof. Barak Shoshany

Table of contents

Course overview

CSE 701 is intended to give the students a good understanding of computing, solid programming skills in C and C++, experience with debugging, optimization, algorithm design, and numerical calculations, and the ability to produce high-quality and well-organized scientific software, both on their own and in collaboration with others. Please see the table of contents of the lecture notes for a detailed outline of the course.

This is an advanced graduate-level course, and is not intended to be a first introduction to programming. Therefore, students must possess basic prior knowledge of some programming language (any language will do) in order to take this course.

About the professor

The professor for this course is Dr. Barak Shoshany (ħe/ħim). I did my BSc in mathematics and physics at Tel Aviv University in Israel and my MSc and PhD at Perimeter Institute for Theoretical Physics in Waterloo, Ontario. I then taught at the University of Toronto for a short time. I joined Brock University as Assistant Professor in September 2020, and I also teach scientific computing at McMaster University.

I am a theoretical, mathematical, and computational physicist. My research focuses on the nature of time and causality in general relativity and quantum mechanics, as well as symbolic and high-performance scientific computing.

I am particularly interested in time travel; I wrote a popular article about my research on The Conversation and was even interviewed about it on the TV show The Agenda. I'm always happy to talk about my research, and theoretical physics in general, so please feel free to ask me about it, both in and out of class!

When I'm not teaching or doing research, I love composing music (look for my album Travel Music About Time on all music streaming services!), playing video games, board games, and tabletop role-playing games, and posting science jokes and puns on my Twitter account.

I will only physically be at the university on Tuesdays, and will hold my office hours immediately after every lecture. You are strongly encouraged to attend the office hours if you want to talk about anything related to the course.

The best way to ask questions about the material outside of class and office hours is to post them on Microsoft Teams so that other students can also see the question and add their own answers. I will answer any question posted on Teams as soon as I can.

For personal matters, please do not hesitate to email me directly at baraksh@gmail.com. If you need to meet outside of class and office hours, please let me know and we can schedule a video chat on Teams.

Schedule and logistics

The course will take place during the Fall 2022 term, from September 6 to December 8, 2022. There will be one 3-hour lecture every week:

  • Tuesdays 13:00-16:00.

There will be no lectures during the mid-term recess, October 10-16, 2022. Thus we will have 13 weeks of 1 lecture each, for a total of 13 lectures and 39 hours.

The lectures will be delivered in person, at room 312 in Hamilton Hall. Important: Students must adhere to the COVID-19 guidelines listed below.

Students should bring their laptops to class, in order to run code examples during the lectures by copying and pasting from the lecture notes. However, this is not mandatory, as some students may prefer to focus on listening to the lecture itself and run the code examples on their own time later.

Please make sure to bring your laptops to the first lecture, as we will be installing the software required to take the course (IDE and compiler), and I would like to make sure every student is able to install the software successfully during the lecture.

Lecture notes

There is no textbook for this course. The official course lecture notes, written by the professor, contain everything you need to know. They are available to view directly on this website in HTML format.

View the lecture notes
(HTML format)
Last updated: June 20, 2022

I originally wrote these notes while teaching this course in 2020, and they were updated and expanded in 2021. I will continue to update them as needed this year as well. The lectures in this course will follow the notes very closely. If you choose to download the notes for offline use, please make sure to always have the most up-to-date version.

IDE and compiler

Throughout the course, we will exclusively use the 64-bit versions of:

Both are cross-platform and work on Windows, Linux, and macOS. Instructions for installing and using them can be found in the lecture notes, and will also be given in the lectures.

All student projects will be evaluated by the professor using the 64-bit version of GCC, so the students must use the latest version of this compiler when writing their code, to ensure compatibility. This compiler is cross-platform, so all of the students should be able to use it regardless of their OS or CPU architecture of choice.

Using Visual Studio Code is mandatory as well. Advanced students may ask the professor for permission to use a different IDE, but please note that I will not be able to provide technical support in that case.

Assignments and grading

There will be 3 course projects, roughly one per month. The topics for the first 2 projects will be determined by the professor, and all students will submit the same project. For the final project, each student will choose a different topic based on their personal and/or research interests, subject to approval by the professor.

The final grade in the course will be composed of the project grades, with the following weights:

  • Project 1: 20%
  • Project 2: 30%
  • Project 3: 50%

For the final project, the students will first submit a draft version. The professor will provide the students with feedback on their drafts, without grading. Each student will have 1 week from the time they received the feedback to submit the final version, with all the issues outlined by the professor fixed. The grade will be determined by the final submission.

Project guidelines

Mandatory guidelines (automatic zero if not satisfied):

  • Your code must be original, that is, written by you in its entirety from scratch. Please note that if you submit code that you did not write yourself, you will receive a grade of 0 and will be charged with academic dishonesty.
    • To be perfectly clear, code generated by tools such as GitHub Copilot and ChatGPT does not count as "original code".
    • You may include short code snippets copied from my lecture notes or other sources, but only under the following conditions:
      1. The code is short, up to a few lines.
      2. The code is not central to the project. For example, it can be a few lines of error checking code, not an important algorithm that your entire project is based on.
      3. You clearly mark where the copied code starts and ends in a comment and indicate where it was copied from, including a URL if applicable.
  • All code must be written in either C (for project 1) or C++ (for projects 2 and 3). You cannot use any other programming languages in your project.
  • Each project must consist of a self-contained C or C++ program, which can optionally be split into multiple source and header files, but must compile and run by itself without any additional requirements or dependencies. I should not be required to download or install anything in order to compile and/or run your project.
  • Your code must compile using GCC v12 with the compiler argument -std=c++20 without any errors. If I cannot compile your project, then obviously I cannot test it.
  • Your code should be fully portable. This means it should compile successfully with any standards-compliant C/C++ compiler and run on any operating system and CPU architecture. Therefore, you must use only standard C/C++, and must not use any features that are compiler- or OS-specific. Note that all code used in the lecture notes is standards-compliant. If you want to use something that is not in the lecture notes, then you can look it up on cppreference.com to check if it is standards-compliant.
  • Your program must accept user input only via files and/or command line arguments. It must not accept input via the terminal at runtime, and the input must not be hard-coded into the source code. Your program must run from start to finish without requiring any user interaction.

If any of the above guidelines are not satisfied, I will notify you by email, and you will get 24 hours to fix your submission. If it is not fixed by then, your grade will be an automatic zero. The reason is that if you program does not satisfy these guidelines, then grading it would be either impossible (e.g. if your program does not compile, then I cannot test that it runs properly) or just extremely time consuming (e.g. if your program takes input during runtime, then I would have to sit down and type the input all over again single every time I run it).

The program itself:

  • Your code must compile using GCC v12 with the compiler arguments -Wall -Wextra -Wconversion -Wsign-conversion -Wshadow -Wpedantic -std=c++20 without warnings. If you get a warning, you must eliminate the mistake that led to it, not the warning itself. For example, a warning about an unused variable x, could technically be eliminated by writing something like (void)x;, but the actual solution should be to not define that variable in the first place.
  • Your program must avoid all of the common errors that I mention in the lecture notes, especially those inside big red boxes!
  • Your program should never make use of any user-defined macros. The reasons for this, as well as suggested alternatives, are explained in the lecture notes.
  • Your program must be able to detect and handle errors, including: user errors (e.g. the user entered a string where they should have entered a number), file errors (e.g. invalid file format), and system errors (e.g. out of memory), and terminate the program with an informative error message, e.g. "Invalid input on line 7 of input.txt: Expected a number".
  • If your program uses dynamic memory allocation, you must make sure there are no memory leaks or other memory-related issues, as explained in the lecture notes.
  • For maximum portability, you must use fixed-width integer types whenever possible, as we learned in class.


  • Your code must include clear and detailed comments explaining what each function does, including the meaning of the return value and each of the arguments; the purpose of each non-trivial variable; and details on any non-trivial algorithms used.
  • Your project submission must include clear and detailed external documentation which explains what your code does and how it works, including any relevant equations, algorithms, and concepts. The documentation must include several examples of possible inputs of interest and the outputs they generate. The format of the documentation (Markdown, LaTeX, Word, etc.) is up to you.
  • Your code and documentation should be free of typos. This includes any output generated by the program as well as the names of variables, functions, and other symbols in the code itself. I highly recommend using the Code Spell Checker extension for VS Code for this purpose.

Additional guidelines only for the final project:

  • The final project is supposed to summarize all that you have learned in this course, and as such, I expect it to be a high-quality production-level program that people could actually use, at least in principle if not in practice.
  • The final project cannot be a C++ library, it must be a complete program that can run independently. With my permission, you can write a C++ library, but only as long as you also write a program which uses that library to do something concrete.
  • Both the draft and the final project must be submitted via GitHub. You do not have to make your repository public, you can also make it private and provide me with access, but ideally this will be a public repository that will contain code that other people might actually want to download and use!
  • Don't think of this project as being submitted to a professor for grading; think about it as publishing a piece of software for other people to use. Potential users should be able to understand how the program works, use it for their own needs, and modify the code - without needing any additional information beyond what's in the documentation, comments, and output of the program itself.
  • The documentation must be written in Markdown and placed inside a file named README.md in the GitHub repository.
  • Comments in Doxygen format must be written for all classes, functions, and variables.
  • All documentation, comments, and output should have proper formatting, phrasing, grammar, and spelling. If you are not a native English speaker, consider asking a friend to go over your files and do some editing. Again, remember - the project should look professional, like any other high-quality scientific software you can find on GitHub!
  • All code must be properly formatted for maximum readability. I highly recommend using VS Code's automatic formatting feature (Shift+Alt+F) and even set it up to automatically format code on save, as explained in the lecture notes.
  • The code must be fully object-oriented, which means objects and their member variables and functions should be used whenever possible, and correctly implement the object-oriented techniques we learned in class, such as encapsulation and class invariants.
  • You may use another programming language, such as Python or Mathematica, to visualize the output of your C/C++ program if desired.

Appropriate final project topics

First of all, and most importantly, since all students in this course are graduate students, a natural choice is to prepare projects directly related to computational aspects of your research. You may want to consult with your supervisor and/or fellow grad students and figure out a suitable project together.

Another option, in case you have not yet started to perform research or your research does not involve any computational component, is to write your own implementation of a known algorithm of sufficient complexity. For this you can consult, for example, the list of algorithms on Wikipedia.

Some suitable examples include differential equation solving, Monte Carlo methods, numerical integration, various computational physics algorithms, statistical analysis, computer graphics, cryptography, machine learning, parsing, error correction, compression, signal processing, and image processing.

It is preferable that the entire project is self-contained consists only of code that you wrote yourself. If necessary, with my permission, you may use third-party code to, for example, read or write image files for computer graphics or image processing algorithms, perform arbitrary-precision integer arithmetic for cryptography algorithms, and so on. However, you must still implement the actual algorithms yourself.

Simple algorithms like searching, sorting, integer factorization, and so on are not complicated enough to constitute a project on their own. However, you could, for example, write a program which implements the same task using several different algorithms and performs comprehensive performance tests to see which algorithm performs best. Note that a performance test must involve not just measuring time but also performing statistical analysis (e.g. perform the same test several times and calculate the mean and standard deviation).

COVID-19 guidelines

Your health and safety is very important to me! Since this course is delivered in person, all students are encouraged to adhere to the following COVID-19 guidelines:

  • It is very strongly recommended that all students wear a medical mask (surgical or N95; not a fabric mask) at all times during the lectures. Even if you're not worried about getting COVID-19 yourself, there may be other students in the class who are in a risk group for COVID-19 (or other airborne illnesses), or are living with people who are in such risk groups. Free surgical masks are available at several locations, including the Campus Store. While masks are not currently required by the university, they may become mandatory later in the term.
  • Vaccine boosters are highly recommended for all students. If you did not receive a booster in the last 6 months, you are encouraged to get one.
  • If you suspect that you are experiencing any COVID-19 symptoms, do not come to class. If you miss a lecture, you can make up the missing material by reading the lecture notes, which will contain all the material needed for the course projects.

If you have any questions, comments, or concerns, please do not hesitate to post them on Teams, send me a direct message on Teams, or email me.

© 2022 Barak Shoshany