Saturday, December 29, 2007

Rusting Knowledge

Over a period of time, it seems like a layer of dust covers your deep understanding and knowledge of a subject matter, where in once I was considered an expert. My knowledge is rusting and it's time to re-read some old classics and books I used to learn the subject matter from.

I've been trying to learn C#, Python, etc, but I realize that I need to revisit my C skills and my C99 knowledge base again. In summary, knowledge rusts over a period of time, specially the items not practiced very often.

Get ready to clear away the dust from your rusting areas as well, as I explore well known areas and newer areas with a "I used to know, but forgot" perspective.

Monday, December 24, 2007

Digging out of history (longjmp is bad)

I had this program written out a long time back, it shows why some constructs are valid, but do not apply well today. In the evolution of C++, we've left behind some holes


 1 #include <stdio.h>
 2 #include <setjmp.h>
 3 #include <string.h>
 4
 5 class C {
 6 private:
 7         char *ptr;
 8 public:
 9         C (const char *name) {
10                 ptr = new char[strlen(name)+1];
11                 printf("constructed C\n");
12         }
13
14         ~C () {
15                 delete [] ptr;
16                 printf("destroyed C\n");
17         }
18 };
19
20 void funfunction(jmp_buf env)
21 {
22         C c("Hello");
23         /*
24          * Do something, at the end expect destructor to be
25          * called
26          */
27         longjmp(env, 1);
28 }
29
30 int main(void)
31 {
32         jmp_buf env;
33         int ret;
34
35         ret = setjmp(env);
36         if (ret) {
37                 printf("Looks like we jumped a long way\n");
38                 return ret;
39         }
40
41         funfunction(env);
42         return 0;
43 }


See if you can find the obvious problem with this code

Saturday, December 22, 2007

Sounds in my life

The gentle and shrill sounds in my everyday life, call my attention to them. In earlier days, the only sound that one would hear is of people talking to them, children playing on the street or a baby calling for Mama's attention.

Compare and contrast that with what we hear today; the sound of the TV, the microwave, radio, music player, sound of vehicles zooming on the street, vehicles blowing horns, the telephone, the cell phone trying to tell you someone wants to talk to you (even when you are in the restroom), this someone could be a pre-recorded sales call; the computer buzzing to tell you that someone is trying to reach you through instant chat, the courier person ringing the doorbell, the alarm-clock ringing on my cell phone

How am I supposed to listen to myself and others around me; with these distracting sounds calling for my attention. We have moved into a new era, where we need more sounds to tell us, that we are needed elsewhere. I need to filter these sounds, so that I can hear my heart-beat, the pin-drop and my those around me giggle and laugh.