Archive

Archive for the ‘Computing’ Category

Advertisement!

4.10.2013 Leave a comment

AdBlock is a wonderful little browser plugin. It does not get in the way. If you have it, you may not even know it’s there.

All it does to you is a favor. By blocking the ads, it removes all the unnecessary bling bling from your view. The result is that the websites that you are browsing contain only what you are interested in.

The functionality of AdBlock should really be part of browsers. Obviously Google would shoot themselves in the foot if they added it in Chrome. I suppose other browsers are trying to be politically correct by not including similar functionality.

There is a group of people who are against using AdBlock, because it strips them from potential income by preventing visitors from clicking on ads on their websites.

But I like AdBlock a lot, you wanna know why?

Let’s take Facebook, which is one of the most popular websites. It started off as a website who helped people get back together. Had a friend in school? Now it’s easy to reconnect! But Facebook accumulated a lot of users who upload a lot of information about themselves. It turned out to be a great source of information for which many companies pay prime money. After cashing on selling information about their users, Facebook also started serving ads to their users. Double win!

But I am not really against Facebook, I only don’t like their clunky web UI. If you are using Facebook, do you check out the things your friends post? So sometimes they post links to videos on YouTube. Unfortunately lots of YouTube videos are censored in many countries. Germany, for instance, is one of the countries leading in Internet censorship (among other countries). People from certain countries may in fact find it ironic!

So here are the two biggest problems the Internet has in this day and age:

  1. People are the product. We, the users of the Internet, anything we produce and any information available about us are being traded.
  2. Censorship is gaining strength, even in “highly developed” countries.

To me, AdBlock is our little means of getting back at them, a way of getting censorship onto our side.

Advertisements
Categories: Computing

Rest in peace, Steve

22.09.2013 1 comment

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.

Categories: Computing

new is abomination

20.09.2013 Leave a comment

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.

Categories: Computing

Mutex vs. binary semaphore

28.05.2013 8 comments

Mutices and semaphores are among the most basic tools in multithreaded programming. However most people I asked do not know what is the difference between them. So please let me introduce you to them.

Consider a resource which is shared between multiple threads. For example a container. You don’t want to have multiple threads modifying the container simultaneously, or one thread modifying the container while other threads are reading from it, otherwise you will end up with classical race conditions and unpredictable things will happen.

To guard a resource from other threads while you are accessing it, you use a synchronization primitive, which you conceptually associate with the guarded resource. Threads can lock the synchronization primitive when they need to access the resource. Then they can release the primitive after they are finished with accessing the resource. When the synchronization primitive is already locked, a thread trying to lock it will wait/stall until the other thread who locked it – unlocks it.

At the first glance, both mutex and binary semaphore fit the description of the above synchronization primitive. Well, not quite. Using binary semaphore in place of a mutex is a bad idea.

Conceptually a semaphore is like an integer. You can increment it and you can decrement it. If the semaphore’s value is 0, the thread trying to decrement it will wait/stall until somebody else increments it. This way, the semaphore never has a negative value.

A binary semaphore is just a semaphore capped at one, i.e. it’s value cannot exceed one. You can treat the decrement operation as “lock” and the increment operation as “unlock”.

The problem with the semaphore is that any thread can increment it or decrement it. In particular, if the semaphore’s value is 0 (“locked”), another thread can increment it (“unlock”), even if this is not the thread which locked it! It takes more discipline to write code which correctly uses binary semaphores for locking and there is still a potential for error.

Another problem is that most semaphore implementations allow sharing semaphores between processes. This makes them much heavier than e.g. POSIX mutices or critical sections on Windows, which are lightweight, because they only work within one process and don’t require calling into kernel space in most cases.

Unlike binary semaphores,mutices may also have another interesting property, depending on an implementation, i.e. they can be recursive. A recursive mutex can be locked twice from the same thread. This allows you to write an accessor function and not have to care whether the mutex is already locked by the current thread or not. However it is generally not recommended to use recursive mutices, the necessity for recursive mutices is a sign of a bad design and indicates that there may be potential problems with the interfaces or even hidden multithreading bugs.

In general mutices (or critical sections on Windows) are typically recommended over binary semaphores as synchronization primitives between multiple threads in the same process.

Categories: Computing

RIP, MacBook White

13.04.2013 Leave a comment

We got the MacBook White over 5.5 years ago. It withstood the trial of time. A year after we got it, it survived a spill of tea, which killed the IR sensor for the remote. Two years later the inverter cable went flaky – the backlight became intermittent, so we stopped closing the lid, otherwise it was difficult to restore the backlight. Then the fan started being loud. I replaced the fan with a new one. Then I upgraded the memory to 4GB and upgraded the OS. A year ago the battery died, so I replaced it. A few days ago the kids inadvertently pushed it off from the coffee table and a day later the hard drive died.

That’s it, I will stop trying to keep it alive and I will let it die.

Until its last minutes, the MacBook White worked very well, almost the same like when it was new. The only reason to ever reinstall the OS was to upgrade it. After the memory upgrade it was able to even run Lion without any problems.

I expect the new generations of MacBooks sold today to be even better.

  • The very nice looking plastic of which MacBook White was made was nevertheless – plastic. There were tiny cracks here and there and tiny pieces chipped off on the edges of the keyboard. All current MacBooks are made of aluminium and are not susceptible to this kind of damage as easily.
  • The lid hinges in the aluminium MacBooks feel much more solid, not sure if his is because the hinges are better, but I have no problems whatsoever with the one I’ve been using for over 3 years now.
  • The latest generations of MacBooks don’t have hard drives. Hard drives are delicate. Some people rightfully call them the spinning discs of rust. The latest MacBooks have flash-based non-volatile memory instead of hard drives, which should theoretically have longer average life time and is more reliable than mechanical hard drives.

Apple’s MacOSX integrates really well with the hardware. But one can also run Linux or Windows just fine on MacBooks, either in a virtual machine or natively. It’s certainly a piece of hardware worth recommending. It is expensive, but it is worth every penny spent on it.

Categories: Computing

Android calendar idea

3.02.2013 Leave a comment

I have an idea for an Android device which I want to share with you.

At some point in my life I started using calendars on portable devices, first on Palm Z22, then on iPod touch. Whenever I am I can always turn on the device and check if I have anything to do this day or the next day, so I can plan ahead. There is so much going on that it’s hard to remember all the things I have to do, let alone things planned months ahead, such as dentist appointments for example.

But when I am home, the problem is I have to walk to the place where I put my device, unlock it, then open the calendar app. This costs time.

This is easily solvable by having a calendar hanging on the wall in the central place of the house such as the kitchen. Another good place is the door of the fridge. But a static, paper calendar can only be looked up where it is placed. I cannot check it when I am away from home.

Android to the rescue! I’ve seen people using their Android tablets as picture frames. Why not use an Android tablet as a calendar? There could even be a device especially suited for this task. The nice thing about Google calendar is that you can share it with other people, so you could have a common family account and all members of the family would share their calendars with it (you can have multiple calendars with your Google account).

The device I am looking for could be described as follows:

  • It is an Android tablet.
  • It is very thin and very light.
  • It has an e-ink screen so it does not consume much energy. The screen will display the last image even if the battery is discharged.
  • It has a low power CPU. The CPU can be slow, it does not matter for this purpose.
  • It does not need to have any connectors.
  • It has WiFi.
  • It has a solar cell with which it charges its battery. No charger necessary.
  • It has a touch screen as an input device.
  • No other gimmicks necessary, no Bluetooth, no camera.
  • It can be hung on the wall, it can stand on the shelf or it can be attached to the fridge door using magnets on its back.
  • It has no unlock screen. In the default mode it displays the calendar app.
  • It is cheap. The upper limit would be $50, but $25 price tag would be perfect. There are e-ink readers which cost less than this (although they are subsidized). Some printed calendars cost this much.

I would certainly purchase such device if it was available. So far I failed to find one. If you find a similar device, let me know.

Categories: Computing

Game consoles

2.02.2013 Leave a comment

High-end game consoles are past their best days. The top consoles from Microsoft and Sony haven’t been refreshed in 6-7 years. Meanwhile the PC platform kept improvements coming and Nintendo has shown with Wii that a console doesn’t need top hardware to be popular. In the recent years console manufacturers faced a new challenge – iOS and Android platforms introduced casual gaming and started eroding the console market.

The nice thing about iOS and Android is that the games for these platforms are super cheap. Spending a few bucks a month for a few games is not a big deal, home budged will certainly not notice that. More sophisticated games cost $5+ which is still not a big deal. For a small portion of a cost of one console game one can purchase several good quality games and play them anywhere, not attached to a TV.

Nintendo has already released a new version of their console – Wii U. However it seems that their new console doesn’t sell as good as they anticipated. Sony and Microsoft are expected to release new versions of their consoles later this year. Will they enjoy better sales, or will they face similar problems to Nintendo’s?

Well, the Android ecosystem isn’t sleeping either. Ouya is one example of an Android-based console, which was an overwhelming success on Kickstarter last year, confirming that this is what the users want. Ouya will certainly steal more market share from the big guns.

I anticipate that Sony’s, Microsoft’s and Nintendo’s consoles will face a really touch competition. My advice for them is to jump on the Android bandwagon, otherwise they will share the same fate as Nokia.

Do you think the high-end consoles will survive?

Categories: Computing