{"id":13838228,"url":"https://github.com/jcelerier/cpp-teaching-manifesto","last_synced_at":"2025-03-23T07:43:13.472Z","repository":{"id":40545127,"uuid":"196470826","full_name":"jcelerier/cpp-teaching-manifesto","owner":"jcelerier","description":"The C++ teaching manifesto","archived":false,"fork":false,"pushed_at":"2023-02-04T16:52:52.000Z","size":18,"stargazers_count":45,"open_issues_count":1,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-01-28T14:32:48.833Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"cc0-1.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jcelerier.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2019-07-11T22:07:10.000Z","updated_at":"2023-08-08T16:55:50.000Z","dependencies_parsed_at":"2024-01-15T19:00:48.621Z","dependency_job_id":null,"html_url":"https://github.com/jcelerier/cpp-teaching-manifesto","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jcelerier%2Fcpp-teaching-manifesto","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jcelerier%2Fcpp-teaching-manifesto/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jcelerier%2Fcpp-teaching-manifesto/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jcelerier%2Fcpp-teaching-manifesto/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jcelerier","download_url":"https://codeload.github.com/jcelerier/cpp-teaching-manifesto/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245072252,"owners_count":20556353,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-04T15:01:44.129Z","updated_at":"2025-03-23T07:43:13.435Z","avatar_url":"https://github.com/jcelerier.png","language":null,"funding_links":[],"categories":["Others"],"sub_categories":[],"readme":"# The C++ Teaching Manifesto\n\nThis document exists in multiple languages - thanks to the translators ! \n* [English](https://github.com/jcelerier/cpp-teaching-manifesto/blob/master/README.md)\n* [Portuguese](https://github.com/cppbrasil/material-de-aprendizado/blob/master/manifesto-de-ensino-em-cpp.md)\n\nTeaching C++ is a hard task, for students as well as for teachers.\nThis manifesto intends to ensure that this task is not made unintentionally harder for both parties, \nby providing up-to-date best practices for teaching.\n\n\n#### 1. I will teach C++ as a high-level language.\n* Too many courses take the approach of presenting C++ on the same level of abstraction than C. This is severely misguided.\n  * C++ programs are written against the C++ abstract machine, not your classroom's CPUs, and compilers *will* optimize code with the assumptions of the abstract machine in mind.\n  * C++ allows for arbitrarily high levels of abstractions, with generally no runtime penalty for optimized code, if either inlining or LTO are leveraged.\n  * [Expressive C++ Coding Challenge Results](https://www.bfilipek.com/2017/10/expressive-cpp17-results.html)\n\n#### 2. I will teach the core concepts and values of C++\n* Value semantics.\n  * Especially over object semantics of languages such as Java / C#.\n  * Prefer automatic storage to dynamic storage (stack variables over `new` / `shared_ptr` / `unique_ptr` whenever possible).\n* Const-correctness.\n* Ownership and [RAII][RAII], resource management.\n* Zero-cost abstractions.\n* Generic programming and how to leverage the type system to provide maximal compile-time guarantees on your program.\n  * In particular, not doing at run-time what can be done at compile time.\n\n#### 3. I will refer to and keep up-to-date with current best practices\n* C++ authors and designers have created the [C++ Core Guidelines][cppcoreguidelines], in order to show what is the best practice, in a language with 40 years of legacy baggage.\n* [Collaborative Collection of C++ Best Practices](https://github.com/lefticus/cppbestpractices)\n\n#### 4. I will not teach using outdated revisions of the C++ standard.\n* ISO rules mandata that the *only* valid standard at a given point in time is the last one. We don't build new houses with electric plugs from 50 years ago.\n* C++ has a three years release cadence : by the time the students are on the job market, what was considered avant-garde during their classes will be mainstream.\n* It is not necessary to use non-released standards, but it can be interesting to at least look at them - that's the standards which will be in effect when the students are out of school ! \n\n#### 5. I will not use outdated tooling to teach my students\n* Windows : use msys2 with the latest clang, gcc, or an MSVC recent enough to support motion 4. \n* Ubuntu or Debian : if a recent distribution is not available, use the packages from https://apt.llvm.org/\n* Mac : use a recent macOS with the latest Xcode, or install the latest gcc or llvm from [*Homebrew*][homebrew] if macOS cannot be upgraded.\n\n#### 6. I will not teach C++ as an object-oriented language\n* Because it is not. By the own word of its creator, it is a multi-paradigm language. \n* Fun fact : C++ is a fairly advanced functional language, thanks to type-level computations and some level of dependent typing (non-type template parameters).\n* C++ can be leveraged to study almost the whole history of programming, so let's leverage that and provide nice examples to our students.\n\n#### 7. I will not teach dialectal or platform-specific C++\n* No \"C/C++\" : https://www.youtube.com/watch?v=YnWhqhNdYyk\n* No C-with-classes : just teach C or Java if you really want to do that.\n* No \"Java/C++\". Hint : if you are writing `new std::string`, there is something wrong.\n* No `-fno-exceptions` : exceptions are a core part of C++. They give all their meaning to [RAII][RAII], and except on 32-bit Windows are faster on the happy path than error codes.\n  * It's easier to learn to not use exceptions if you already know them, than to learn to use exceptions if you don't.\n* No `conio.h` / `iostream.h` / `graphics.h` / whatever DOS-era API you can find.\n\n#### 8. I will not teach outdated software development patterns\n* Multiple classical development patterns were over the years integrated in various programming language, either as language or library features.\n* [Closed polymorphism][open_closed_principle] : [visitor pattern][visitor_pattern] -\u003e now can be done with std::variant\n* [Strategy pattern][strategy] : std::function\n\n#### 9. I will not teach volatile as a multithread synchronization mechanism\n* Long story short : it does not work in the general case.\n* [is `volatile` useful with threads ?](http://cxx.isvolatileusefulwiththreads.com/)\n* Use atomics.\n\n[cppcoreguidelines]: https://github.com/isocpp/CppCoreGuidelines\n[homebrew]: https://brew.sh/\n[open_closed_principle]: https://en.wikipedia.org/wiki/Open%E2%80%93closed_principle\n[RAII]: https://en.wikipedia.org/wiki/Resource_acquisition_is_initialization\n[strategy]: https://en.wikipedia.org/wiki/Strategy\n[visitor_pattern]: https://en.wikipedia.org/wiki/Visitor_Pattern\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjcelerier%2Fcpp-teaching-manifesto","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjcelerier%2Fcpp-teaching-manifesto","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjcelerier%2Fcpp-teaching-manifesto/lists"}