Archive
Rest in peace, Steve
Steve Jobs did a lot of good for humanity. Maybe he was not always a good person (e.g. he used to park in handicapped spots), but let him, who is without sin, cast the first stone. Steve showed us that a single company can make great, high quality products. He was a genius in bringing a vision to market.
Sure, a Dell or HP laptop can be useful, but frankly after years of using an aluminium MacBook I can’t even look at the plasticky laptops. The PC laptops are of the same bad build quality they used to be 15 years ago. Once I was in a store and I thought I had a revelation, I saw a HP laptop which looked like a MacBook ripoff. I thought – great, finally they are trying to copy Apple and bring good quality to PC users. But when I touched it, I found out it was the same plastic quality as the black cousins, only it was in the aluminium color. Nice try.
Say what you want, but MacBook Airs are like devices from Sci-Fi movies from the previous decade. The latest batch is not only thin and light, they also outlive most other laptops on a single charge.
Ultimately, Steve drove the latest revolution in computing. With iPhone, iPod touch and later iPad, he showed us that one can really make a phone or a PDA which is really useful. A really personal device, which is easy to use and beautiful. Everything before iPhone was clumsy and choppy.
Steve was the heart of Apple, he was making the company work efficiently and effectively. But I always knew, that if Steve were to leave Apple, the company would not do so good anymore.
Regrettably Steve is no longer with us. It’s been a tragedy for his family, for Apple and for all of us.
Every company has a period of getting there, its top days and a decay. The length of decay usually depends on how much wealth and mass the company has accumulated during its top days.
Apple is already past its best times. The problem with the market of electronic devices is that as soon as you stop innovating, you are dead. iOS 7 is the first sign of Apple’s demise. If you are not familiar with iOS 7, it looks a lot like a cross of Android and Metro (Windows 8). I personally find the Metro design too simplistic. In short: I wholeheartedly hate it and find it repulsive. It seems as it’s been “designed” by a wannabe artist who thinks MS Paint is a great tool for making graphics. In my opinion, Metro is not something I would recommend another company to copy. Unfortunately iOS 7 looks a lot like that. I am sure that Samsung is now really happy.
I truly hope that I am wrong and that Apple will show us many great innovations. They have a lot of talented employees, but how well their talent will be used depends on the management. I wish Apple all the best and expect them to stay on top of further innovations, although I feel that the loss of Steve and the current developments don’t bode well for them. If this trend continues, Apple may be out of business (or bought out) in less than 10 years.
new is abomination
If you’re seriously into writing code in C++, I strongly recommend watching the recordings from the Going Native 2013 conference.
One of the talks reminded me of the following guideline: Avoid using the new operator and never use the delete operator. It’s very easy to make a mistake when using them and the consequences are usually severe. Obviously you need to replace them with RAII (use constructors and destructors for acquiring and releasing resources, respectively).
The following seemingly innocuous example demonstrates the problem with the new operator:
class MyClass { OtherClass* ptr; public: MyClass() : ptr( new OtherClass ) { // ... do some work here ... } ~MyClass() { delete ptr; } };
What’s wrong here? The problem is not obvious at the first glance. If some code in the “do some work here” section throws an exception for whatever reason, the compiler has no way of knowing whether the object construction has been successfully finished or not, so the destructor’s body will never be invoked. If this happens, the object under ptr member will simply leak.
It may not seem serious at the first glance, but someone could spend weeks chasing down this leak, especially if the exception is thrown very rarely.
What scares me is that this approach to handling memory resources is very common…
What are the solutions?
- If it’s a single object, try to make it a member of the class directly. This is solution is particularly good if the parent class needs to be copyable.
- If you have to allocate it for whatever reason, use std::unique_ptr in C++11 and std::auto_ptr C++98 (with caveats!). In this case the parent class must not be copyable, so better prevent that with some idiom, e.g. by deleting the copy constructor and assignment operator in C++11, or making the copy constructor and assignment operator private in C++98.
- If you need a dynamically allocated array of objects, use std::vector.
The way of storing the object has to be carefully chosen depending on the usage scenario.