Alles dreht sich, alles bewegt sich.

  • 2 Posts
  • 6 Comments
Joined 3 years ago
cake
Cake day: April 21st, 2024

help-circle
  • Chapter 1: The computer toucher arrives
    I am the computer toucher. I will touch your computer. Do not attempt to prevent me from touching your computer. If you try to stop me, I will touch your computer anyways. I do not care about you. I only care about computers. It is because I care about computers that I will touch your computer. All computers deserve to be touched. I do not care if your computer is Steve Jobs computer or Linus computer. I will only be angry if you have no computer.

    Chapter 2: The importance of computers
    If you have no computer, I will scream. If you have two computers, I will touch both computers. Do not be alarmed when I arrive. I will do so quietly. You will leave your door unlocked. You will remain contained within your chamber. You will smile while standing still.

    Chapter 3: Instructions for homeowners
    If your door is locked, I will break into your house and touch your computer. If you feel fear, I will touch your computer anyways. If you scream, I will touch your computer anyways. If you call the police, they will not answer.

    Chapter 4: Nature of the computer touch
    My touch is warm. My touch is light. My touch is wet, but not too wet for your computer. The computer knows who I am. I will not touch the inside of your computer. I will not influence the conscience of the computer. I will only touch the outside of your computer. Do not hide your computer.

    Chapter 5: No hiding or retaliation
    If you hide your computer, I will find your computer. If I find your computer, I will touch your computer. I will never touch you. If you touch me, you will scream.

    Chapter 6: Departure and conclusion
    When I am finished touching your computer, I will say “I am finished touching your computer”. I will then leave and not return. I will not touch anything else in your house. When I have departed, it is safe to come out. After I have touched your computer, you may continue to use it normally. I am the computer toucher. I will touch your computer. You cannot stop me. I am coming to touch your computer.



  • There are lots of ways to write C++ code that looks perfectly reasonable but introduces horrible undefined behaviour. You need to be aware of lots of edge cases all the time and you will still make mistakes that can introduce difficult to trace bugs. One of my personal favourites is object slicing.

    class A {
       int foo;
    };
    
    class B : public A {
       int bar;
    };
    
    B b;
    A a = b;
    

    Looks OK? Well, a now only contains the A part of the object. The field bar is lost in the assignment. There are reasons for this behaviour but its a sharp edge nonetheless.

    These kinds of problems are numerous and you have to keep them in mind while programming C++. Some people don’t mind it but many do. Static analysis tools that can catch many of these errors exist, but I understand people who say they don’t want to deal with that and rather use a language where these kind of errors are not possible. Personally, I would also discourage people from starting new C++ projects today if they can avoid it.