user: My reflection.md should answer these questions:
- What did you learn in the lab tasks this week? (incl. explanation)
- How well did I learn it?
- How does my solution compare with the official solution?
- How can I extend the concepts used in the tasks to form a new project?
Can you write it for me, based on the following braindump/rough ideas?
ai: Of course! Please provide your braindump or rough ideas, and I’ll help you craft a reflection.md based on that information.
user: I learned about output streams, i.e. that they work by declaring console output with cout
and then inserting data into this with the insertion operator <<
. This is because c++ doesn’t come with standard commands like print
does with Python to make it more lightweight and efficient/quick because it lower-level (right above assembly) and you don’t always need a command-line interface, so don’t always need console output. This is also why we need to use the line #include <iostream>
as this is the c++ equiv to python’s imports, and it then includes the input/output stream commands like cout
(and cin
that I learned about in my extra work this week). Side note on this is that we use the line using namespace std;
so that we can write cout
rather than std::cout
etc., although I’ve learned in my extra work this week that this is bad practice as it can cause conflicts, so is generally recommended to just write std::cout
etc. - most IDEs have command auto-completion anyways, so it just makes it more explicit without much of a time trade off writing it out. I also learned about special characters in this week’s lab session, both escape characters exist and what special characters I need to escape: \n,\a,\b,\f,\r,\t,\,’,”,?. I also learned about the line terminator endl
, which seems to basically be a command to end the data stream started with cout
, and can be inserted in the same way. Functionally, it acts as the same as the newline character, as far as I can tell so far.
In my extra work outside of the lab sessions, I looked into c++ best practices and different styling documentation (REFERENCE TO GOOGLE STYLE DOCS AND OTHER STYLE DOCS USED LIKE DOXYGEN), learning bits already mentioned as well as things like using the same comment style throughout (I’ve opted for /* … /* and /** … /*). I also looked more into functions, best practices with using void
, why we return 0 at the end of the main function (and that it default does it already, but is best practice to explicitly return it too) and hence why it’s int main
not void main
. I also found parallels to javascript where in both you place docstrings before the functions, because in Python (the language I’m most proficient and comfortable in) docstrings are actually part of the function, but in most c-like languages this isn’t the case. As I’ve opted for using VS Code to write the c++, I also looked into different extensions that can help with linting and formatting, although so far this seems less extensive than Python. I’m assuming that we’ll cover more on functions in later sessions, so I won’t explain them here, but I did learn about them. I also learned about for loops, exceptions and handling them, conditional statements, the || operator, the libraries cmath, stdexcept, and iomanip for setw (another thing I learned to control the width of console output), variables (and the strong/static typed nature of c++). More styling that I learned about was that with functions you should write them with the first curly bracket { on the same line as its declaration, contrary to lab examples. Everything I learned in the extra work I did outside of lab, I learned by extending the concept of printing a Pascal’s triangle by, instead of just using hardcoded strings and outputting them, using loops and the other constructs to create a solution to which is comparable to what I’d do in Python and is infinitely extendable with error handling for input.
Everything that I learned, I loved learning, and it was very exciting to properly learn a new programming language that I’ve heard so much about before. The official solutions aren’t out yet, so sadly I can’t compare.
ai: Here’s a structured reflection.md based on your provided ideas:
Feel free to modify any part of this reflection to better match your voice or add any additional thoughts!