Archive

Archive for the ‘Other’ Category

C type system strikes back

9.06.2016 Leave a comment

Today is one of those days when C++ surprises me. Here is a snippet:

#include <stdint.h>
#include <stdio.h>

int main()
{
    const int64_t a = 3;
    if (a < -0x80000000)
        printf("%lld is negative\n", a);
    return 0;
}

This time the surprise comes from the intricacies of the C type system.

Hint: -0x80000000 is mathematically INT_MIN.

In case you’re wondering, it is not about improving the above snippet. It is about actually seeing a piece of code like this in the wild. It looks correct. But it is incorrect.

Categories: Other

Learn Polish

1.02.2016 Leave a comment

If you have some spare time and want to learn another language, I recommend Polish. Polish is a lot of fun! For a start, here are a few words in Polish and their meaning in English:

 

Polish word Meaning in English
no yes
do to
to this
go him
pies dog
much flies
bat whip
paw peacock
but shoe
wanna bath tub
pan mister
baby women
was you (plural)
my we
we on (a day)
on he
one they (women)
ten this one
grab hornbeam
bark shoulder
jest is
fart luck

Enjoy!

Categories: Other

New Year’s Resolution

4.01.2016 2 comments

One of my New Year’s resolutions is to keep this blog more active. While my activity has been low during the year 2015, I have not abandoned the blog. I was simply spending most of my free time working on my personal project. In the mean time I’ve gathered several ideas for new posts, it will be great if these posts finally see the daylight this year!

Hopefully my personal project will also reach a publishable state this year. Here’s an interesting detail about this project.

C++ has been the primary programming language for me in my professional career. Over the years, I’ve used many programming paradigms provided by this versatile language. However, to the surprise of many, my new project is currently written in pure C!

Why C? Out of admiration for a coworker, who writes programs in C, which are of high quality, and which are readable, maintainable and extensible. And also as a personal challenge. Writing *good* quality software in C requires more skills than in C++, because the language is much simpler and doesn’t have mechanisms provided by C++, which help avoid certain classes of bugs. To be fair, I’ve seen a lot of bad C++ source code which fails to use these mechanisms, but that’s another story.

So here are my impressions about going back to C so far. First of all, RAII, which is the cornerstone of C++, is not available. This makes cleanup more tedious. Again to be fair, C++98 without lambdas also makes cleanup more tedious by requiring you to write or use classes just for the purpose of cleanup, which makes the code scattered or complicated. Secondly, handling error conditions in C is more tedious. Exceptions in C++ can provide a great way of signaling exceptional errors, if used carefully(!), together with RAII, which makes returning from functions easier without the need to babysit allocated resources. Mildly missed are classes, which can help to logically organize functions, although in many C++ programs they are abused by implementing unnecessary OO designs, which lead to too much boiler plate code and eventually hamper readability. One of the most missed features are container templates, which greatly simplify memory management in C++.

On the bright side, some of the advantages include better portability due to unencumbered linkage. Because the language is so simple, it also leads to simpler code, which can in turn be easier to read, maintain and extend, contingent on the type of program and the way in which it is written, of course!

Surprisingly, it is possible to write readable code in C without drowning it in macros! Many C projects I’ve seen overflow with macros, which impact readability. But this can be said about C++ projects, too.

Now back to the editor. Let us see what the New Year brings!

Categories: Other

Interview question: Which browser do you use?

17.03.2015 Leave a comment

Big Data says, that employees who use a non-default browser, such as Firefox or Chrome, stay with the job 15% longer than those using a default browser, such as IE or Safari.

Well, if Big Data says it, it must be true!

(There – I finally said it. 😉

Categories: Other

Job interview question idea

30.09.2014 Leave a comment

I doubt that everybody realizes, that job interviews are for both the company trying to fill in an open position as well as the potential employee trying to find a job. A usually small, but important part of an interview is when the person being interviewed asks the questions.

This idea is for those who have the chance to speak to their potential future manager. How do you know if a particular manager will be right for you?

The question to ask your future manager is: Do you prefer cats or dogs?

The explanation follows.

Dogs are followers, they need their master to tell them want to do, to give them direction. Cats on the other hand are soloists. They do what they want, whenever they want. If they want to be tapped, they come to you.

Of course, this is an approximation, a generalization.

Similarly, there are two groups of employees. Ones which need to be told what to do, and the others, who don’t need and don’t like encouragement, but rather pursue tasks on their own. This is universal regardless of the job type. Obviously, the first kind can be compared to dogs, while the other to cats.

Before going to a job interview, you need to ask yourself honestly, whether you are a follower and need to be told exactly what to do, or whether you like taking complete control over what you are doing. This has nothing to do with whether to like cats or dogs, it is completely orthogonal.

If you are more like a dog, probably a manager who prefers dogs would be better for you. Similarly, if you are more like a cat, a cat-person would manage you better.

It’s just a theory. As silly as it sounds, I wonder if there exists any statistical data which would help test it.

Categories: Other

Cursing

10.07.2013 Leave a comment

We’re trying to avoid cursing at home as much as possible and so far our children did not pick up any curse words.

But for some time now our three-year old son has been using the word “poop” quite often. He finds it very amusing. I think it all started when our kids were practicing joking and this word was said in an innocuous,  funny context. He picked it up and it stuck.

Now he’s using it often at numerous occasions. Sometimes to get attention. Sometimes to make people laugh. And sometimes when he’s angry. Especially when he has to do something he does not want to or when he’s punished. Then he repeats or exclaims it multiple times, or says “you are a poop!”.

Because he hasn’t been exposed to cursing before, I think he invented cursing on his own. Cursing is apparently natural and as some studies indicate, brings relief in some situations, e.g. reduces pain.

Interestingly we’ve never had such problem with our daughter. This is one of the many examples we’ve noticed of the differences between males and females.

Categories: Other

Bad UI

9.06.2013 1 comment

User interface is the most important feature of all devices (and software). It exposes all device functions to the user. Without user interface, all features of the device would be useless.

Apparently companies who have been around for tens or even hundreds of years are still making mistakes in user interface design. Here are two examples.

The compartment under the center armrest in a very popular car looks like this:

IMG_0964

 

The compartment has two levels. Hence there are two levers under the armrest. One of them opens the top, flat compartment, the other one opens the bottom, big compartment. Unfortunately I am not able to memorize which lever opens which compartment.

I used to keep a box of kleenex/tissue in the bottom compartment. Whenever I wanted to take one tissue out, I had to guess which lever to pull to open the right compartment. And somehow I always guessed wrong. Very annoying, esp. during driving.

Cars are known for very well-thought user interfaces, which don’t get in the way. But in this case – they blew it.

Here is another example of a bad user interface. This company making all kinds of appliances and house equipment has been around for more than 100 years. One of their stoves:

IMG_0945

 

This is a standard piece of equipment and a standard user interface solution. Well – nothing less annoying. The flaw here is almost the same as in the case of the dual compartment above. There are two knobs, one for each burner. Unfortunately the burners are aligned vertically, while the knobs are aligned horizontally, giving you no clue (without taking a closer look) which knob is for which burner.

In order to tell which knob is for which burner, I have to bend. Often I don’t want to bend, I just want to turn the burner on. When I don’t bend and look at the pictures which decipher the knob-to-burner assignment, I always choose the wrong knob and turn the wrong burner on. Like in the dual compartment case, it is not possible to memorize which knob is for which burner. Maybe because the pair of knobs on the other side for the two remaining burners is swapped. Well, at least they left a visual clue for the people who are not too lazy and actually bend or take a step back to determine which knob to turn. Please note, that when you’re close to the stove and e.g. putting a kettle on the back burner, you don’t see the icons over the knobs and you either have to bend down or back or you have to take a step back.

As innocuous as they may seem, these can be quite annoying.

How many broken UI designs can you spot around you?

 

Categories: Other