Friday, August 12, 2005

Opera 8 now

I use Opera once in a while. Some of the stuff is really good.

  1. Mouse Gestures
  2. Unix Like Browsing
  3. Voice Support
  4. Many more

but what I found very useful for my blogging is image scaling. Scaling down of images is much much better than IE or Firefox.



Image rendered by Opera 8




Image rendered by Firefox




Image rendered by Internet Explorer

Thursday, August 11, 2005

Compile Time Assertions

A friend and I got into a discussion in coffee day last night about a review he was busy with. The code he was reviewing converts an integer to string. The author was taking the value of the integer, calculating log10 of the number and adding 2 to it to calculate the length of the array for storing the converted string.

This array would then be malloc'ed to store the string.

There are obvious deficiencies in this code

It is slow (due to the log10 calculation and malloc)

on the other hand

This code would scale better than any other code, for example if the integer size of the platform changed.

I suggested that the author do the following

1. Calculate the maximum array size for an int of 4 bytes (remember to include space for a possible "-"). Currently (11+1(possible "-")+1 ('\0' character)) bytes for a 4 byte integer.
2. Use compile time assertion to assert the size of the integer being converted.

If you are wondering what compile time assertions do, look at the code below

1 #define CT_ASSERT(cond, msg) \
2 typedef char msg[(cond) ? 1 : -1]
3
4 int
5 main(void)
6 {
7 int i = 10;
8
9 CT_ASSERT(sizeof(i) == 4, size_must_be_4);
10
11 }

Compile time assertions try to use the preprocessor and create situations that are illegal. The "C" compiler cannot compile the preprocessed code, if the assertion fails. See the example above.

On a platform where this condition fails, the output would be

cassert.c: In function `main':
cassert.c:9: size of array `size_must_be_4' is negative

This ensures that there is no runtime overhead of catching assertions and yet the code is fast and will break if the size of the integer changes.

Other sources of information
  1. Catching errors early with compile-time assertions
  2. Compile Time Assertions in C

Monday, August 08, 2005

Netscape 8 is such a joy

After all the controversy surrounding Netscape 8. I decided to install an upgraded/fixed version of Netscape 8. I found it amazing, you can switch between the IE and Firefox rendering engines so easily. I think this a big boon for web developers who are faced with the difficult task of testing pages with both browsers.

In the screen shots below look at the icon at the bottom left of the screen, they show the icon with which the page has been rendered. I think this a giant step for web developers and a good move by Netscape.


Netscape rendering using Firefox Posted by Picasa

Netscape rendering using IE Posted by Picasa

Netscape used to be the only browser for Linux, but unfortunately they have decided not to release Netscape 8 for Linux. I would be happy even if they released with a firefox engine, atleast I would use the same browser across platforms.

Sunday, August 07, 2005

Celebopedia

Do you enjoy wikipedia? Well there is a good celebopedia web site now. Each celebrity is listed with news, biography, stats, media and some extras. So will celebopedia become a standard like imdb.

I still love imdb and I think its much ahead of celebopedia.

Friday, August 05, 2005

An unexpected visit

On one of my posts, I found a post from two people who decided to visit other blogs and leave behind a visit me message. I think that's cool, but where does one draw the line?

Well, to be fair, I visited their web site from home and found out something about them. Blog's are multi-dimensional (people might not be willing to show all aspects of themselves completely). Some blogs are personal, some are political, some are technical, etc. Some blogs have mixed content.

I use the blog's I read column to link to my friends, but I might start indicating what kind of blogs I would like my blog to be linked with. The blogosphere is similar to a biological system. Wikipedia's definition of Blogosphere is very interesting.

Wikipedia states

Blogosphere (alternate: blogsphere) is the collective term encompassing all weblogs or blogs as a community or social network. Many weblogs are densely interconnected; bloggers read others' blogs, link to them, reference them in their own writing, and post comments on each others' blogs. Because of this, the interconnected blogs have grown their own culture.

Blogosphere is an essential concept for blogs. Blogs themselves are just web formats, whereas the blogosphere is a social phenomenon. What really differentiates blogs from webpages, forums, or chatrooms is that blogs can be part of that shifting Internet-wide social network.

Like biological systems, the blogosphere demonstrates all the classic ecological patterns: predators and prey, evolution and emergence, natural selection and adaptation. The number of links obtained by a blog, is frequently related to the quality and quantity of information presented by that blog. That means, the most popular blogs have the highest link level, the worst blogs have the lowest link level. The blog ecosystem has its own selection and adaptation mechanism. The good tends to become better, the bad tends to disappear.

Through links and commentaries, the blogosphere with its self-perfecting mechanism, converts itself from a personal publishing system into a collaborative publishing system.


I don't want to disappear, please help me survive :-)

Thursday, August 04, 2005

Can you recognize this person? -- Answered



Here is the answer to Can you recognize this person?. The name of the person is Lena.

See this expert from an email response

Subject: Lena (parting words) (longish)
Date: 21 Feb 1996 13:33:20 GMT
From: dobelman@dfw.dfw.net (John Dobelman)
Organization: DFW Internet Services - DFWNet: 800-2-DFWNet
Newsgroups: sci.image.processing

If Dr. Munson and the Transactions can forgive the copyright infringment, the departing Editor-in-chief's comments on the Lena deal are too good not to share with the group.

IEEE TRANSACTIONS ON IMAGE PROCESSING. VOL. 5. NO. 1. JANUARY 1996

A Note on Lena

During my term as Editor-in-Chief, I was approached a number of times with the suggestion that the IEEE TRANSACTIONS ON IMAGE PROCESSING should consider banning the use of the image of Lena. For those of you who are uninitiated in this brouhaha, let me provide a few facts. The original Lena image was a photograph of a Swedish woman named Lena Sjooblom, which appeared in the November 1972 issue of Playboy Magazine. (In English, Lena is sometimes spelled Lenna, to encourage proper pronunciation.) The image was later digitized at the University of Southern California as one of many possible images for use by the research community. I think it is safe to assume that the Lena image became a standard in our "industry" for two reasons. First, the image contains a nice mixture of detail, flat regions, shading, and texture that do a good job of testing various image processing algorithms. It is a good test image! Second, the Lena image is a picture of an attractive woman. It is not surprising that the (mostly male) image processing research community gravitated toward an image that they found attractive

An interesting link is http://www.lenna.org/

Wednesday, August 03, 2005

Rock star INXS

Do you guys watch the show on Star World! Well, I love the show.

  1. http://rockstar.msn.com/
  2. http://www.cbs.com/primetime/rock_star/




I love Jessica's attitude and singing. But my picks for the top three are

The photographs have been taken from rockstar.msn.com

What to Lock (Locking Design part IV)

To discuss this, we first need to look at what kind of system architecture is being used. There are two special types of locking primitives, they are described below.

  • Semaphore

    A semaphore is used to denote a locking primitive in which we relinquish the CPU if we do not get the lock. In the examples used in the previous article, down, down_write and down_interruptible are semaphores. The pseudo code for a typical semaphore implementation is given below.


    \begin{algorithm} % latex2html id marker 53\caption{Psuedo code for a semaphor... ... queue} \STATE return with the lock held \ENDIF \end{algorithmic}\end{algorithm}


  • Spinlock

    A spinlock is used in a multiprocessor environment. There might be cases when one cannot go to sleep waiting for a lock. Consider for example an interrupt handler in a Symmetric Multi Processing environment (here after referred to as SMP). All the CPUs may receive an interrupt from any device. If a device interrupted the system twice, lets say one interrupt goes to CPU 1 and the other to CPU 2. Both of them execute the same interrupt handler for the device. They will need mutual exclusion to avoid the kind of races or unexpected results. It would be very bad for a CPU to go to sleep in an interrupt handler, because an interrupt handler is running at a very high priority, preempting everything else, we should deal with it quickly or the system will perform very badly. So what do we do, we spin on the lock being held by the other CPU (assuming that the other CPU will not hold the lock for long). Once we get it, we finish with the interrupt handler and continue (NOTE: The assumption here is that interrupt handlers run fast, otherwise the spinlock will spin for a long time).


    \begin{algorithm} % latex2html id marker 63\caption{Psuedo code for a spinlock... ...TATE return with the lock held \ENDIF \ENDWHILE \end{algorithmic}\end{algorithm}


Now that we have looked at kinds of locking primitives, let us discuss when we need to lock data. First of all remember that we need to lock only global variables and structures, since only they are prone to races. Local variables reside on the stack and since each process on each processor has its own stack, there are no race conditions with local variables. We will consider the following cases


Rules Of Locking (locking design part III)

The rules are listed below

  • Lock only data, not code.
  • Lock only what you want to protect, not everything around it. Use locking optimally.

Surprisingly enough, there are only two small rules for locking. These rules are definitely not exhaustive, they are rules of thumb and form the basis of this article. From these rules we will draw more and try to use real world examples to illustrate the various rules. Lets now see what each rule means.

     /* Find the cache in the chain of caches. */
down(&cache_chain_sem);
/* the chain is never empty, cache_cache
is never destroyed */
if (clock_searchp == cachep)
clock_searchp =
list_entry(cachep->next.next,
kmem_cache_t, next);
list_del(&cachep->next);
up(&cache_chain_sem);

if (__kmem_cache_shrink(cachep)) {
printk(KERN_ERR "kmem_cache_destroy:
Can't free all objects %p\n", cachep);
down(&cache_chain_sem);
list_add(&cachep->next,&cache_chain);
up(&cache_chain_sem);
return 1;
}

In the example above, we grab the cache_chain_sem lock twice. We release the lock before calling __kmem_cache_shrink() and grab it again if necessary i.e, if __kmem_cache_shrink() returns a value greater than zero. We could have held the lock for the entire duration and freed it at the end, but it would conflict with the rules we stated above.

We would be protecting code and not data, we need to protect the cachep list, so we use the lock only to protect the contents of that list from changing. What if we held the lock and __kmem_cache_shrink() turned out to be an extremely long function? Other routines waiting for that lock would really starve, especially if __kmem_cache_shrink() does not change the cachep list. It would even be unfair to hold the lock and make merry while others are waiting for the lock.

This brings us to some important questions

  1. When do I need to implement locking into my code?
  2. How do I design my code to in corporate locking into it?

These questions are answered in the articles to follow.

Monday, August 01, 2005

Pages related to OSX86

Apple has decided to move to the intel platform. Here are some links related to their effort

  1. http://www.osx86.classicbeta.com/wiki/index.php/Main_Page
  2. http://maconintel.com/
  3. http://www.appleinsider.com/article.php?id=1175
  4. http://www.macsimumnews.com/index.php/archive/
    possible_mactel_chips_part_1_a_look_at_yonah
  5. http://buildyourownmac.com/
  6. http://www.jbnahan.net/en/
They are all unofficial, but they are fun to read. I can't wait for my own copy of MAC-OS-X on Intel or to buy one of those cool boxes. I hope they use a processor with 64 bit extensions and hyper-threading support

Saturday, July 30, 2005

Foveon X3 Technology

If you are interested in digital photography, please read the Digital Camera FAQ. One very interesting feature is the Foveon X3 Technology.

Here are some images to show you the distinction, they have been taken from the Foveon site.





Mosaic Capture
Foveon X3 Capture


Sharpness

Mosaic

[Larger View]

Foveon X3


Color Detail

Mosaic

[Larger View]

Foveon X3


Artifacts

Mosaic

[Larger View]

Foveon X3

Can you recognize this person?



She is very popular and you will find her in a lot of image processing books. There is a very interesting story and background about this person and her photograph. Can you figure it out? If you can't, please wait for the answer or ask for it

Migrate apps from Internet Explorer to Mozilla

IBM is running an article on Migrating Internet applications to Mozilla.


Figure 3. Mozilla's JavaScript debugger

I found it very interesting as I try to learn more about where the web has gone since the CGI days. I love XML, its a big relief from SGML.

Wednesday, July 27, 2005

Open Solaris



I am very excited about open Solaris. With the Apple folks also deciding to move to an Intel platform, Intel users would have access to

  1. Linux
  2. FreeBSD/NetBSD/(other BSD clones)
  3. Solaris
  4. MAC-OS X (derived from darwin - open darwin)
  5. Windows
The exciting thing is that sources for the first four can be easily obtained. Its fun to see gcc ported to all these platforms. All these are encouraging trends, the base support software is getting free, so will the other support tools in time to come. What will the software industry pay for then?

Lets see where the future takes us.

Monday, July 25, 2005

Conspiracy Theory - Did we land on the Moon?

Star world ran this program on Saturday 9:00 PM. It almost made me believe we did not land on the moon. Then I saw the http://www.braeunig.us/space/hoax.htm and I am a bit confused now by both claims.

NASA also has an interesting site http://science.nasa.gov/headlines/y2001/ast23feb_2.htm?list45245. I think I am going to believe again that we landed on the Moon until the next space vehicle to orbit the moon finds/proves that we did not go to the moon.

What I have found so far is that people believe strongly. A believer is not open to changing his mind and vice-versa.

Friday, July 22, 2005

Deterministic problem solving

Have you come across a problem that makes you want to wonder as to how long it will be before the problem will be solved. There are many good books out there on debugging and many many interesting discussions on weird problems and their solutions.

The question for today is

  1. Can we come up with techniques to convert the solution time non-deterministic to deterministic?
  2. How would be verify that these techniques do that effectively?

Tuesday, July 19, 2005

1970 and 1979 Editions of "How it works, the computer"



Interesting book and its online now. I like the size of the computers. Slashdot also has this story here

The Image Drawing Dilemma

Good posts demand good illustration. That is true for all topics but especially true for technical content (I know I promised more non-technical content, I have quite a bit of it, but it needs to be organized and reviewed).

I have been evaluating the following options for illustrating

  1. Hand drawn (I have a scanner)
  2. Using a tool like VISIO (openoffice has a decent tool too)
  3. Using my favourite MetaPost/LaTeX/pdfLaTeX/MetaFun
  4. Using PIC
  5. Using Graphviz

In this post, lets look at hand drawn images. Here are two hand drawn and scanned images - what do you make of them?


Monday, July 18, 2005

Are you a computer engineer?

Do you recognize these symbols?


If you don't, I suggest you refresh your knowlegde again.

Sunday, July 17, 2005

The latest review


I just got an email from William Stallings telling me that the book is published. Since I am one of the technical reviewers of the book (single chapter), I am expecting my free copy soon.

I like books by Stallings, they are well written and well illustrated. This is one of my last reviews this year.

Experiments with syntax highlighting

I have been posting code for a while now, I want to try and post good looking code - which is syntax highlighted.

Here is the first attempt


/*
* Simple program to parse regular expressions
* (C) Balbir Singh
* Permission to copy the program if and only if the (C) is
* maintained.
*/

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <errno.h>
#include <bitset>
#include <iostream>
#include <queue>
using namespace std;

static bool status = true;

#ifdef DEBUG
#define debug(x...) {\
printf("%s:%d ", __FUNCTION__, __LINE__); \
printf(x); \
}
#else
#define debug(x...)
#endif

#define pcr debug("current token is %c\n", s[idx]);
#define perr {\
fprintf(stderr, "%s:%d parse error at token is %c\n", \
__PRETTY_FUNCTION__, __LINE__, s[idx-1]); \
status = false; \
};

Saturday, July 16, 2005

Thursday, July 14, 2005

Locking Design in many parts

A paper I wrote on locking several years ago. I reproduce it here in parts.

Elements of locking

Abstract:
In this paper we discuss the various aspects of locking, including designing code which would be considered safe. By safe, we mean free of unexpected side effects. These side effects are commonly known as race conditions in the literature of operating systems and computer architecture. Although a lot has been written on this subject, we will look at it from a different angle. Several examples have been used to illustrate the contents of this paper, the reader is not expected to understand the code listings and what the code does. The code should be viewed from the point of view of locking. The term locking has been used here to mean methods of protecting critical section of the code. It is assumed that the reader is familiar to some extent with the concept of critical section. Most of the examples and treatment of this subject is with respect to a operating system kernel concept, but the principles discussed here even apply to a multi-process or a multi-threaded user application. All the discussion applies to non-preemptive kernels only.

The Need For Locking

The need for locking is simple and a lot has been written about it. We will use a pratical example of a race condition often seen in an operating system environment. We will take an example from fork.c in Linux, it is a small and good example.

down_write(&oldmm->mmap_sem);
retval = dup_mmap(mm);
up_write(&oldmm->mmap_sem);


The fork system call in Linux and other Unix variants does the following

img1


img2
Figure 1: The fork() system call



Now consider what could happen if we did not lock the address space of the parent using down_write(&oldmm->mmap_sem), the address space (see figure 1) of the parent could change and what we set out to do i.e, Ensure that parent and child have the same address space at the end of fork, would never be accomplished. The dup_mmap(mm) function duplicates the address space. The deletion of a single page could affect the system call if proper locking is not used. We call the data and code protected by the locks as critical section. In our case the data used by dup_mmap(mm) that is mm is our critical section.

A fundamental assumption of locking is - once we get the lock it is ok for us to go ahead and modify/use the data protected by the lock.

NOTE: Most of the new hardware and software developments demand more concurrency, as we head towards concurrency at various levels of hardware and software, the need for locking and sound locking design principles become more accute.

Saturday, July 09, 2005

First Letter to Stroustrup

Hello, Bjarne,

I have been reading "The C++ Programming language, third edition (special edition)". Reading through section 11.3.2 made me realize that user defined types could use another feature like "type promotion" to get closer to types supported by the language. To support Mixed mode arithmetic the number of operators defined is 5 in section 11.3.2.

I was wondering if we have a promotion operator.

For example, lets say we have a reserved keyword promotion and we could do the following

Complex& operator promotion(double d)
{
this->im = 0;
this->re = d;
return *this;
}

The promotion operator could be invoked whenever we encounter a type in an operator that is not of the same class as the operator.

For example

2 + c // where c is complex

Could invoke a promotion operator with a new temporary created by the compiler

In effect, it would be equal to

t = new Complex();
c.operator+(t.operator promotion(2), c)

I think this would simpifly the permutations, combinations needed to develop a good usable user defined type.

Comments?

Balbir

Friday, July 08, 2005

Compilers - where are they going?

Reading through some of my books, I came across two concepts that I think are the biggest things that compilers support today

  1. Templates or Generics
  2. Reflection



The diagram below depicts the following facts

  1. Reflection is getting us closer to the compiler internals. They help us with how types are organized and to help us probe for more compiler details. Reflection is helping the user get more information about compiler internals.
  2. Templates are taking us towards implementing our own primitives. We are so close to doing code generation using techniques like meta template programming.

The day is not far when templates and reflection techniques will merge at some point giving the user full control from compiler internals to using the compiler interface.

Thursday, July 07, 2005

Effective C++, Second Edition


If you have read Effective C++, Second Edition, I hope you enjoyed reading it. I have started reading it and found some interesting things, I reported them to Scott Meyers. He updated them at Effective C++, Second Edition, Errata Web site. My code name is bxs.

You can find what I said and some really interesting stuff that others have said at the above web site.

Tuesday, July 05, 2005

Whom should we encourage to become our next generation leaders?

I have been thinking about this issue for a while. Who would make a good leader in the Indian democracy? What background should they come from? Well, here are my thoughts so far

Lal Bahadur Shastry ji used the following slogan (Jai is a praise, kisan is a farmer, jawan is a soldier and vigyan is science)

Jai Jawan, Jai Kisan

to which Atal Bihari Vajpayee added

Jai Vigyan

I feel we need people from the defense in our parliament. America has had the tradition of having people serving in the military become their presidents. I feel we should have

  1. Kisans (farmers) at the grass root level of politics
  2. Vigyanis (Scientists) be involved as Members of Rajya Sabha (as already dictated by our constitution)
  3. Jawans (Soldiers) at the top most level of leading the country with pride and loyalty.

Thursday, June 30, 2005

Predicting the implementation by looking at the UI behaviour

I found some interesting things by looking at the UI of various applications, I hope you find them amusing too

  1. On my Adobe Acrobat Reader in Linux, when I search for ",", it finds even ";" 's. That makes me wonder if internally, a semicolon is represented as a "." and a "," paired up horizontally?
  2. In Windows, use your "Windows button" + D to see the desktop (Windows button gives you direct access to the "start" tab on pressing it). If you have any modal dialogs open, it fails to show the desktop. I suspect the implementation of "Windows button" + D is to send a minimize event to all windows. If some window has a dialog open, it cannot minimize.
  3. In Windows XP, if your outlook email editor is set to "MS Word". Try the following, have a modal dialog open and try to send a new email. It will prompt you asking you to close the dialog before editing can begin. It goes to show that modal dialogs can be an irritant if applications are shared.

I will try to add more to this list.

You've got anything to share?

Tuesday, June 28, 2005

Prediction for the coming years

I have some thing to predict about the software industry in the coming years. Lets see how true they turn out

  1. The usage of software tools will drop down.
  2. The quality of software will temporarily dip (quite significantly), we will need a drastic changes to the software model at that point. Think of it as a pending software crisis.
  3. Hardware will start eating into software, it will start doing what was done in software earlier.
  4. There will be no new major programming language development.

This list will grow as and when I find/discover new things for myself.

Comments?

Java Language Specification, third edition



JLS, third edition is out and available online at The Java Language Specification Website.

Check it out

Sunday, June 26, 2005

Cheap Edition of Stallings Operating Systems (fifth edition)


The PHI edition is out, I reviewed a chapter for the book. You can find my name in the acknowledgements section. That's the trumpet blowing for the day, back to work now.

1000 + updates

Thanks for visiting my blog, its now been visited at least a 1000 times since march 2005. Even if I do not post anything on my blog, look out for the sidebar, there is usually something new and interesting there - almost always!

Friday, June 24, 2005

Scope of typedefs in a class in C++

I found this in the latest C++ draft specification

Type names obey exactly the same scope rules as other names.In particular, type names defined within a class definition cannot be used outside their class without qualification.

Example:


class X {
public :
typedef int I;
class Y { / . . . / };
I a;
};

I b; // error
Y c; // error
X::Y d; // OK
X::I e; // OK

Thursday, June 23, 2005

Hoare's Law

Inside every large program is a small program struggling to get out

C. A. R. Hoare

Signs that a country is progressing

Here are some signs you notice when a country starts making its mark in the world

  1. The economy improves
  2. GDP and per capita incomes goes up
  3. Manufacturing plants get setup because the labour is still cheap or it becomes an outsourcing hub
  4. The Government starts opening up the economy
  5. It becomes a market for goods, there is an influx of foreign brands
  6. Consumer spending increases
  7. Government announces more projects for infra-structure development
  8. The automotive and airline industry starts booming
  9. The country starts doing well in sports

Can you think of more? Please let me know and I will grow the list. Let me know if you disagree with these observations

Sunday, June 19, 2005

Problems with the Indian Software Industry

Please do not take this personally, but I have compiled a list of problems the Indian Software industry must address. Feel free to comment to get something removed or added

  1. Attrition
  2. Missing Work-Life balance
  3. The nature of work
  4. Un-empowered employees
  5. Reactive Management and short-term management
  6. disproportionate pay scales
  7. Statistically qualified Quality Team but with no software experience

Saturday, June 18, 2005

When everybody knows

Have you come across a situation where some lies, but everyone knows the truth about that person not being honest. You have to tolerate the person more out of compulsion. The persons lie is still accepted as truth.

I have found several such examples in the political and business world.

Why to we tolerate such things? I think we expect things to improve in the future and the person to get better or excuse it as a once in a while thing.

Friday, June 17, 2005

Too technical

I have been recently told by a few friends that my blog is too technical and I agree.

I'll fix it, so watch out, because when I speak non-techy stuff, who knows what might come out?

Wednesday, June 15, 2005

The Auto Rickshaw Rule

I have found that you have a better chance of the auto rickshaw agreeing to were you want to go, if you wait for him to stop completely before telling him your destination

Technical search link

has been around for a long time and is one of favourites.

Tuesday, June 14, 2005

Monday, June 13, 2005

Blog Jockey

Well, to make Radios, Discos, Videos, etc interesting a RJ (Radio Jockey), DJ (Disco Jockey) or Video Jockey (VJ) is employed. I am thinking of coming up with a Blog Jockey (BJ - don't forget you heard it here for the first time!)

Any Ideas?

Online Problem Set


There is a very interesting web site online judge. It is basically a problem set archive, where you can submit code to solve the problems submitted there and be judged. There is also a book Programming Challenges based on the web site. I am planning to get started sometime soon, interested in collaborating?

Drop me an email!

Thursday, June 09, 2005

GUI Question

This question was probably first asked by Jeff Duntemann. Why are most output devices asymmetrical?

Here is what I mean, look at your monitor, its likely to be either (in dimensions)
  1. 1024x768
  2. 800x60
  3. something higher

But the point is that the "x" and "y" dimensions are not the same. Why is it that a pixel is not a 1x1 square? The impact of this is

  1. I usually end up with a vertical scroll bar (rarely a horizontal one)
  2. The scroll wheel on my mouse, scrolls vertically

I think most of us read information top->right->down, so it makes sense to scroll vertically top->down.

Even books seem to have similar kind of dimensions. On an A4 size paper, one of the dimensions is sqrt(2) bigger than the other dimension, but there either of sides can be used as horizontal or vertical.

I think in our natural vision, the horizontal vision is bigger than our vertical one. When we see from the corner of our eye, we usually refer to the horizontal vision

Monday, June 06, 2005

Big Powerful Processors

Intel and AMD seem to be flooding our markets with Dual Core/Hyperthreaded Processors. These processors are so quick that they hide away our programming inefficiencies. Even badly/poorly programmed code works good on them (not always, really really bad code will show). I realized that the same code which worked super fast on one of these processors was snail slow on another. By spending some time tuning up the code, it worked faster as expected.

The point being, on a fast processor, I would have left it as is "inefficient"

Revisit your code under harsher conditions like
  1. Lesser memory
  2. Slower processor

Got Broadband?

Well, I got my BSNL broadband today after registering a lot of complaints with BSNL. The people who came to install were nice, but not as knowledgeable as I expected. It was fun and this is my first post from broadband. I am still confused about the speed, I cannot make out the difference b/w dial up and broadband.

Hopefully, now you will see a lot many posts.

Thursday, June 02, 2005

Regular Expressions

Ever since college my favorite subject was regular expressions. What I really loved was Thompson's Construction, so powerful. Many tools gained from them and became popular due to their support of RE's, for example

  1. SED
  2. AWK
  3. KSH/SH
  4. VI

I implemented an RE engine with the capability to display its internal state as it does string matching.

Here is the output of the RE "a*b" matching the string "ab"


The first image is RE engine representation. In the subsequent images the red lines show the possible paths that can be taken after looking at the current character in the string being matched. All the photos are links, you can finder better sizes by browsing the links, if you so desire

Bad Coding is Infectious

Ever worked in a team where a couple of people are not good at coding or following any good standards for coding or commenting. Imagine if you have to share a source file with them. Seeing them not do so well can infect you as well and you fall to their level of coding and guidelines. After all in a mess, where does one stand in with a flag of hope?

I have seen this happen around me, any similar experiences?

Wednesday, June 01, 2005

Understanding Programs Written By Others

All programmers will at some point find themselves having to depend on other peoples programs for various things

  1. Maintenance
  2. To use as an extension
  3. To use as a starting point

You could find yourself in a situation where somebody else is working on your code.

Believe me, code does not get thrown away that easily.

I have been thinking of ways and means of understanding third party code easily. Here are my first thoughts

If you are the author of new code

  1. Comment it well (its obvious), but revisit your comments and documents you have written
  2. Read the Practice of Programming before you write code
  3. Learn about Literate Programming and try to use it if possible

If you are burdened with somebody else's code

  1. Read the documentation that comes with the code, too bad if it does not come with any documentation. If you do not understand the document, read it several times
  2. Read the test plan document first and see if you understand the test cases
  3. Use a reverse engineering tool like
    • cflow
    • Any commercial tool available
    • codeviz

  4. Get the overall goals of the software - Don't dig into algorithms right away, just understand what the algorithm is trying to achieve
  5. Search on google for understanding the technology and the jargon

privacy

Some of the policy from the app automation refers to https://rclone.org/privacy/ if you are a general blog reader, follow Google's polic...