Design philosophy

What is UNIX philosophy? This has been explained in detail in Eric Raymond’s book The Art of Unix Programming.

The Unix philosophy (like successful folk traditions in other engineering disciplines) is bottom-up, not top-down. It is pragmatic and grounded in experience. It is not to be found in official methods and standards, but rather in the implicit half-reflexive knowledge, the expertise that the Unix culture transmits. It encourages a sense of proportion and skepticism — and shows both by having a sense of (often subversive) humor The more detailed explanation and views of  Doug McIlory the inventor of unix pipes, Robert Pike, Ken Thompson and others can be found here. 

Here is the classic example of doing things in the Unix way. I read this post of question and answers from page. I am listing the question and answers which will help to appreciate the beauty of unix and getting ourselves to arrive at simple and beautiful solutions for all kind of problems.

Question : We have entered some text .How to find out the frequency of each word entered ? What can be  the various techniques used to tackle this problem. ? Answer 1:  Use hashing to store words..If collission occurs, check for similarity.. If the words are same increment the counter the u should have associated with each word  Answer 2: Can it be done using Trees.I need to know the approach for taht method.Vivek,Can you provide a pseudocode for the method u said. 

Answer 3: Use binary search tree with node structure below
struct node
{
  int count;
  char *word;
  struct node *left;
  struct node *right;
}
and start inserting words as when you entered. if  you hit same word twice just increment the count.
Below I given is just Pseudo code not a rugged onestruct node *insert(struct node *node, char *word)
{
    if(node == null)
    {
      node = malloc(sizeof(struct node));
      node->word=strdup(word);
      node->left=NULL;
      node->right=NULL;
    }else if( strcmp(word, node->word)==0)
            count++;
    else if(strcmp(word, node->word)<0)
          node->left=insert(node->left, word);
    else
          node->right=insert(node->right, word);
    return node;
}
 print(struct node *node)
{
  if(node!=NULL)
  {
    print(node->left)
    if(node->count > 0)
    printf(“%s->%d”, node->word, node->count);
    print(node->right);
  }
} 

Answer 4: Let’s be practical. 

cat file | tr -s ‘ 11’ ‘1212’ | sort | uniq -c | sort -nr
  gives a list of tab or space separated tokens, with their frequencies, sorted in decreasing order of frequency. The last one is the unix way. The solution is clean, simple and beautiful to look at. There is no new code, no pains of testing and debugging the code. The solution is obtained by using the existing set of tools. Nifty! More on Unix Philiosophy

Advertisements

5 Responses to “Design philosophy”


  1. 1 Jesse Grillo September 6, 2017 at 12:21 am

    Spot on with this. Are there other articles you work on? Well written!

  2. 2 Jesse Grillo September 3, 2017 at 7:55 am

    Without proper research, your readers will not be interested and you would lose credibility. This website really sparked my couriousity. I was talking to my mom on Saturday when I heard about your website. My good friend loves your post. Thumbs up!

  3. 3 Sheldon Owen September 1, 2017 at 2:43 pm

    I have added your page to my LinkedIn Try to make the guest blog as amazing as possible by promoting and dropping links. Wow, that is a really great way of thinking about it! I bet you sweat glitter.

  4. 4 tech adviser August 31, 2017 at 9:04 am

    I was looking everywhere and this popped up like nothing! I have learned new things through your posts. Super useful information. A cool article.


  1. 1 Design philosophy « Renaissance Trackback on September 21, 2006 at 12:48 pm

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s




Pages

Thru Lens

Tweets

View Karthikeyan S's profile on LinkedIn
Alltop, confirmation that we kick ass

%d bloggers like this: