In this video, I refactor a C function to C++ and then to Rust. I also show the equivalent Haskell code and show a comparison of number of assembly instructions generated at the end.
Links:
CodeAesthetic Video: • Why You Shouldn't Nest Your Code
Slides and Code: https://github.com/codereport/Content...
Godbolt Links: https://github.com/codereport/Content...
Behind the scenes video: • How to Make Beautiful Code Presentations
Chapters:
0:00 Intro
0:25 Motivation
1:19 C Code
2:10 C++ Code 1
2:43 C++ Code 2 - Reformatting
2:53: C++ Code 3 - views::iota
3:36 C++ Code 4 - views::filter
4:14 C++ Code 5 - std::accumulate
5:10 C++ Code 6 - ranges::accumulate
5:54 C++ Code 7 - Ternary Operator
6:50 Rust Code
8:30 Bug in C/C++ Code?
10:23 Haskell Code
11:30 Count of Generated Assembly Instructions Comparison
13:40 Outro
Follow me on Github: https://github.com/codereport
Follow me on Twitter: / code_report
Follow me on LinkedIn: / codereport