Writing Software – Part 3

I worked in Motorola for two years. I enjoyed working there very much, but decided to leave and look for a job in Linux and for a smaller company. I got tired of big companies and I also wanted some experience on Linux. The problem is that once you start working on one operating system (or technology) you pretty much get stuck with it, unless you get a chance to switch. I got a chance simply because there was enough demand and not enough Linux programmers to supply it.

So these days I work for Diligent on Linux. Programming on Linux brought me closer to what I learned in the university. The operating system itself has a very small collection of functions you can use (unlike Windows) and you have to work your way up from there using the huge collection of available libraries. For a Windows programmer like me it seems strange that there is no CopyFile(source, destination) function in Linux (which is part of the Windows API since the beginning of time). Also, some functions simply don’t implement all their advertised interfaces, like getting a process’s memory usage with getrusage(). What’s great about Linux is that you can see the implementation of the function, for example in the Linux Cross Reference. Also, in Linux, if you complain about something they will simply tell you: go and implement it yourself.

So this is my experience so far. I admit that I thought this series would be longer and maybe include more of what experience taught me over the years. However, when it comes to software engineering, there are so many gurus sharing their experience, code and their processes in a much more coherent way than I can, that it seems pointless to reiterate things. As an example, here’s Coding Horror’s top 6 list of programming top 10 lists post. I might start posting short “lessons I’ve learned” posts on this blog in the future.

Why and how I started working out

I get a lot of positive reaction for the work I do at the gym. I take it for granted now, but I’m also always afraid that one day I might just quit. So far I’ve been doing OK :)

Anyway, I wanted to tell you why and how I started working out:
While working for Motorola, I tried to maintain a diet that would keep me more or less in the same weight. The problem was that it didn’t work. Even when I tried eating healthier – I quit eating sweets, candy or any kind of snacks years ago, so by healthier I mean less fat and less carbs – it didn’t help. I turned from being a little chubby to being fat. My colleagues at work commented on it and that made me feel more uncomfortable.

Obviously, I knew about the option of going to the gym, but my opinion was that I don’t want to try anything I wouldn’t continue doing after a while. I just wasn’t ready for another disappointment – I was thin before and turned fat and then thin again (thanks to a diet) and then fat again. So for me, going to the gym would mean a long-term obligation which I wasn’t ready for.

Eventually, though, I decided to go. A colleague offered that I try the gym that was inside Motorola. It was free for employees, and while it wasn’t so glamorous, it had all the basics you would expect from a gym. I didn’t want to tell too many people about it, and I didn’t, because I thought that it will be shameful if I stopped going after a while.

Luckily, on the day I went to the gym for the first time, the gym instructor was the best one Motorola had at the time. After asking me what my expectations were (losing weight, more or less) he drew up for me a workout schedule. It included mostly aerobics – I was to walk at 5.5-6.0 km/h for 45 minutes or more. I did that the first day and it was pretty easy. I mean, I was sweating at the end and my legs weren’t used to it, but it wasn’t hard.

“If that’s called going to the gym, I can do this every day”, I remember thinking. And that’s what I did. I went every day, 6 days a week, for almost a year and a half. The results were great. On the Internet you can find many websites that will tell you the benefits of working out, but here’s what I felt:

  • Everyday activities are easier, and I don’t mean things like the fact that it’s easier to walk around, or being less lazy in general. Even stuff like that feeling you have after lunch, that you want to go to sleep, is almost completely gone.
  • I definitely look better. After just 2 months I looked considerably better. Consequently, my confidence level is higher.
  • I sleep deeper at night.
  • Sex is better. Much better.
  • My immune system functions much better than before. Previously, whenever the seasons changed, I used to get the flu or a cold. This year, for example, I was around sick people for days at work and didn’t need to take even one sick day myself. There were days when I felt a little sick, but the feeling passed as quickly as it came.

And these are just off the top of my head. Anyway, the workouts became more and more intense – first I increased the slope on the treadmill and later on I increased the speed, until I had to start running. And when I did start running, something I was somewhat afraid of, I found out that it wasn’t so bad. Then I started using the elliptical, which I now prefer a little over running, and… well, readers of this blog know the story from there… I work out 4 days a week now, every workout is 2 hours long (including the shower), I look better, I feel great and I hope to keep it up.

Ace Learned To Come Back Home. I’m Very Proud

Once I had Ace spayed, I couldn’t resist letting her go outside and enjoy some freedom. On many websites it says that cats feel perfectly fine being at home and there is no need to let them out, but Ace, being a domestic short-haired cat (Wikipedia definition) has always been interested in the outside and I can tell she likes going out.

On the last Thursday and Friday nights, when I got back home, Ace was outside. She either jumped from or fell off the edge of the window, where she likes to walk around and monitor what’s going on in the street. This has happened before, and when it happens, she is always happy to follow me back home (probably being tired, thirsty and hungry). This is very unlike the times when I let her out – then I’d have to either tempt her to come to me with treats or simply chase her and take her home myself.

On Saturday, though, she made me really proud – I let her outside and she came back herself and started meowing near the door until I heard her and let her in. This goes to show, again, that she’s a very smart cat. Her vet told me that when he heard about some of her behavior even when she was a few months old.

And by the way, according to her estimated age, Ace will soon turn 1. I’ll probably post some pictures.

Loading Different Shared Libraries In GDB When Analyzing a Core Dump

Today I’m starting something new on this blog. Whenever I find a solution to a software development problem I encounter and believe it’s worth telling, I’ll write it here.

This time – loading different shared libraries when analyzing a core dump in GDB on Linux. By “different” I mean “not the libraries that GDB finds and uses when the core dump is loaded”. The motivation to do this is, for example, if you have libraries on the computer you’re using to analyze the core dump that are different from the libraries which were used while the application ran. If you have the latter in some directory, say in the path /tmp/core/libs, then the way to redirect GDB to them is:

(gdb) set solib-absolute-prefix /dev/null/
(gdb) nosharedlibrary
(gdb) set solib-search-path /tmp/core/libs

Note that /tmp/core/libs must be a full path, without using ~ or anything. It doesn’t work. My guess is that this is unacceptable by the loader, which loads the libraries starting from the specified path.

Changing My Workouts A Bit

I noticed yesterday that I’ve been working out with the same schedule for exactly one year (here’s my detailed workout schedule). With the weights I’ve been slowly pushing harder and harder, but aerobics-wise I think my body has adjusted and I gained some weight. It doesn’t bother me too much but it’s always a good idea to change the workouts if you feel that your body adjusted.

The change is not too big: in 2 out of my 4 workout days I’m going to just run at moderate speed for 45+ minutes. Currently I do 25 very intense minutes on the elliptical and then another 20 (moderately intense) minutes on the treadmill. Anyway, in the other 2 days I’m going to work out exactly the same as I do today, because I like being able to reach high heart rates and it would be a shame to lose what I gained so far.

So today I ran at 10 km/h for an entire hour. It was very easy – my heart rate didn’t go over 160 (in my intense aerobic workout it can go above 175). My legs felt a little stiff at the end, but everything was normal after a few minutes of cool down. So I guess I’m going to give this new workout schedule a try for a while and see if there are any results.

Wish me luck :)