why companies fail to hire good talent

December 27, 2014 at 6:56 pm | Posted in Programming | 1 Comment
Tags: , , , , ,

Recently Net Cloud Systems, Bangalore (INDIA) approached me for interview. They needed someone specialized in C and UNIX and since my last 5 years of industrial experience is full of C, Linux and UNIX, they must have thought I could be a good fit for the company. Gosh! how wrong they were.

I had to appear for an online test to get recruited. Unfortunately, I did not get any call from them after the test, so I got the point that I did not clear the test. That is fine by me, sometimes you win, sometimes you lose. As a computer programmer, as 24×7 coder, I have learned 2 things: 1st, it is always good to accept your own failures and move on with life by improving upon your skills. 2nd thing is the essence of this blogpost.

Net Cloud Systems had few questions as part of C programming test which actually did not belong to C language. IIRC, there were 2 or more questions not related to C language but they were put in the C test. I wrote an email to them, explained what was wrong and how could they correct the mistake and very politely I said it give would be fair if they could provide 2 marks for those questions. I got a very furious and arrogant reply in return. Down here is the full transcript of the conversation with them:

arnuld uttre 	Tue, Dec 23, 2014 at 7:18 PM
To: hr-necs@netcloudsystems.com
Dear Sirs,

Recently I gave online C test as a part of the selection process by
Net Cloud Systems. I did not get any call after that which means I did
not clear the test and company is not interested in hiring me but that
is not the subject of this email. This email is about incorrect
questions in the C language test. I wrote one mail earlier about the
same issue (to hr-exec@netcloudsystems.com) but no one replied. Hence
you are receiving this email. Here is the technical issue:

I was given 20 questions in C language and only 18 belonged to C
language, other 2 were not. C language is defined by ISO committee
and this committee publishes the definition of the C language. You
can find the official-draft of the standard online here privided by
ISO committee at their site:

http://www.open-std.org/jtc1/sc22/wg14/

According to the definition of C language, C language does not have
any function named gcvt(). gcvt() was asked in one of the two
questions. Perhaps, gcvt() is some compiler-extension know to the
person who created the test but that does not come under C language.
And there are more than a bunch of excellent high-quality compilers,
you can write same C language conforming code in all of them but
different programmers use different compilers and that has nothing to
do with C language itself but the C language test provided by you
seems to confuse between the compiler and the language. Like I said,
I skipped over theses 2 questions. I think examiner should have given
me marks for these 2 questions, else it would be unfair. I am
attaching the PDF of the latest standard for your technical team to
look at themselves.

Now it is not just about me, it is about all the
programmers/developers who appear in interviews of Net Cloud Systems,
it will be same way unfair to all of them, not to mention lack of
knowledge on your part. I hope you will look into it. Thanks for
reading my email.

 Arnuld Uttre


HR-NECS Wed, Dec 24, 2014 at 10:39 AM
To: arnuld uttre
Hi Arnuld,

First of all I would like to say that you could not clear the test.

Their is no mistake in the questions, one should have good and depth knowledge on C and Linux platform only then they can answer the questions.
Please correct your facts first and raise a question. The question that you got in the online test were not repaired by some freshers or 1-2 years of exp person.
So for you knowledge please go through some links below and a attachment.
These type of question in our company are answered by freshers or 1-2 yrs of exp employee.

http://sydney.edu.au/engineering/it/~kev/pp/RESOURCES/cplusplus/ref/cstdlib/gcvt.html
Go to root terminal and type: “man gcvt”

Their are many things that keep coming in C language. It is very vast subject. People who have 10-12 years of exp only on C and Linux platform rate themselves 3.5/5 on C programming. How much would you rate your self ?

Hope you got your answers.
Thank you for reading my mail and thank you for your mail.

Regards,
[NAME OF HR HIDDEN]
HR-NECS


wrote:
> Hi Arnuld,
>
> First of all I would like to say that you could not clear the test.
>
> Their is no mistake in the questions, one should have good and depth
> knowledge on C and Linux platform only then they can answer the questions.
> Please correct your facts first and raise a question.

Oh my dear Vikas….

First of all I did not mean “no disrespect”, I am just trying to tell
you something which is “not correct” about your test but it seems like
you are ready to burn me alive. Please do not let your ego come in
between you and the learning. You can either read my email and do the
search yourself or just simply can get angry and call me a dog:

I got the facts correctly, down here is the proof :

http://sydney.edu.au/engineering/it/~kev/pp/RESOURCES/cplusplus/ref/cstdlib/gcvt.html

You sent me this link. Did you even read that page yourself ? It
says gcvt() is not part of ANSI C:

Portability.
Not defined in ANSI-C, but included in some compilers.

You see the link you sent me itself says, it is not part of C language
but “some compilers” have it and that is what I wrote in my last
email. Hope you trust Microsoft Corporation when it says, gcvt() is
not in C language:

http://msdn.microsoft.com/en-us/library/ms235405.aspx

Here is the code from the same page and output from an ANSI/ISO
conforming C compiler:

[arnuld@arch64 c $] cat gcvt.c
/* gcvt example */
#include
#include

int main (void)
{
char buffer [20];
gcvt (1365.249,6,buffer);
puts (buffer);
gcvt (1365.249,3,buffer);
puts (buffer);
return 0;
}

[arnuld@arch64 c $] gcc -ansi -pedantic -Wall -Wextra gcvt.c -lm
gcvt.c: In function ‘main’:
gcvt.c:8:3: warning: implicit declaration of function ‘gcvt’
[-Wimplicit-function-declaration]
gcvt (1365.249,6,buffer);
^

[arnuld@arch64 c $] gcc -ansi -pedantic -Wall -Wextra gcvt.c
gcvt.c: In function ‘main’:
gcvt.c:8:3: warning: implicit declaration of function ‘gcvt’
[-Wimplicit-function-declaration]
gcvt (1365.249,6,buffer);
^
[arnuld@arch64 c $]

> Go to root terminal and type: “man gcvt”

I did dear before you even sent a reply, and it says “LEGACY function,
removed. Please use sprintpf() instead”. It was a POSIX function, it
IS not a POSIX or C function, it WAS a POSIX fumction and It has been
removed back in 2008, just like K&R C is deprecated where we never use
to include any information about function arguments.

> Their are many things that keep coming in C language. It is very vast
> subject. People who have 10-12 years of exp only on C and Linux platform
> rate themselves 3.5/5 on C programming. How much would you rate your self ?

I leave that rating factor upto you now since you can figure it
yourself whether gcvt() is a part of C language or not. You told me
explicitly that test was not created by some freshers. I can agree to
that because in 5 years I have met only 2 programmers who really knew
C language and they were not much experienced but very good at C and
programming in general, better than me. Majority of the software
engineers in India, with many years of experience, do not know much
about basics of C because they learned from college and college books
are just the worse part of the story of C learning. Most never
learned C after college because C is not of much help in
employability. It ain’t their fault, it is the Indian education system
and the industry requirements.

You took it personal than keeping an open mind to understand the
difference between a language, compiler and the environment in which
both language and compiler exist.

> Hope you got your answers.

I hope you got yours. I already had this answered from students of
Late Dennis M Ritchie. draft of ISO Standard is attached with this
email just like my earlier email, please do read it. Thanks for your
time.

P.S. Software is not just about coding, it is about understanding
people first, almost half of good habits/practices of software
development/engineering are built on understanding people. Listen to
Google I/0 2009 talk on The Myth of Genius Programmer. May God bless
you

Arnuld


HR-NECS Wed, Dec 24, 2014 at 12:59 PM
To: arnuld uttre
Hi,

Lets not take this further.

Thank you for the mail and the valuable information.

Thanks and Regards,
[NAME OF HR HIDDEN]

Well I did exaggerate a bit that I got answer from Late Great Dennis Ritchie‘s students 😉 . Personally, I don’t  know any of Ritchie’s students. I sure as hell learned good amount of programming from great programmers including those who have worked with Dennis Ritchie. I would not have become good at C without their mentoring. One day after this happened, I watched “the myth of genius programmer” talk given in Google I/O 2009 by 2 Google developers: Brian Fitzpatrick and Ben Collins-Sussman. They have talked one very important thing related to the great programmers around the world. They talk about how much important it is be humble, flexible and devoid of ego to become a great (or genius as they call it) programmer. How much it is important to respect your peers and their advice and suggestions when they just walk through your code. It is called peer-review and it is one of the pillars of GNU, Linux, BSD and all Open-Source software communities and they mentioned explicitly in their talk that peer-review happens in google all the time. peer-review is one of the greatest strengths behind the better quality of Open-Source software compared to proprietary software. I never had big ego, on the contrary I have always seen myself as a kind of small and short being and I have listened to knowledgeable programmers half my age. In WIPRO I was on the ODC of MasterCard and I learned more qualities there, I learned being humble, soft and and became more flexible. Not only my teammates but my team manager and project manager were great people too and I think I worked with one of the best people in my professional experience.

Completely opposite to WIPRO, do you see the ego coming out of the email from Net Cloud Systems HRD, and dancing in front of your face. Rather than looking for the facts, this HR person totally closed his mind to new information, the information which could have corrected not only their test questions but could have saved them from future embarrassment from some talented programmer. Arrogance instead of improvement. With this kind of mindset, no company can hire good talent. If a company can not understand that a programmer who knows about the cons-correctness, why int main(void) is better than void main(), is better than an ordinary programmer then you should never work for such company. I thank God I did not clear the test and they did not give me those marks I asked. Otherwise, if they have this much of attitude before hiring I wonder what would happen after one joins the company and gives some different but creative programming idea to solve some serious software problem. A good and talented programmer can not stop the flow of creativity, he would suffocate and die a slow death at a workplace where his ideas are suppressed. In 5 years, I have heard of some companies like this, companies who pay much less amount of money to programmers (freshers mostly) and kill their creative mind by bureaucracy but I never had personal experience with them, now I do. I watched Google I/O talk just next day. I thought it was just a co-incidence but now I think, it was God’s guiding hand telling me to apply for better companies, to look for places where problems are solved with different ideas than egos and where creativity flourishes. You should watch Google Talk, Brian and Ben gave a great talk, it is available at youtube. Programming is about passion and interest. Don’t work for those who can not grasp this, if you want to be a happy-coder.

The Myth of genius Programmer

Copyright © 2014 Arnuld Uttre, Hyderabd, Telangana – 500017 (INDIA)
Licensed Under Creative Commons Attribution-NoDerivs 3.0 license (a.k.a. CC BY-ND)

C++ new() operator

June 28, 2012 at 7:17 pm | Posted in C++, Programming | Leave a comment
Tags: , , ,

I was working on adding some features to a software written as a mixture of C and C++ and I came to realize many C++ programmers write C in C++. Take a look at this:

#include <iostream>
#include <new>

int main()
{
  char * t = new char[1];

  if(!t) 
    {
      printf("Memory Exhausted\n");
      exit(EXIT_FAILURE);
    }

  t[0] = 'A';

  printf("t[0] = %c\n", t[0]);
  return 0;
}

Everything looks fine and g++ (on RHEL 5) even compiles/runs with flags (-ansi -pedantic -Wall -Wextra) and without any warning/error. Program just seems to be technically correct (which it is seems like but isn’t) and prints the value inside array as expected. Now let us take a more basic look at this. Why we are using printf() in a C++ program when C++ has its own standard library ? The program we have writen is actually C in C++. It is like using a powerful mechanism and throwing all the powerful tools/methods away because you don’t want to know about them. Many industrial programmers don’t want to know about it because life goes on fine without knowing about it and they are still earning much higer salaries without knowing it (and they will keep on increasing their monthly income by impressing HR guys with a bag of languages and big projects on their Resumes). Hence Why bother ? Wrong reasons. If you are really looking for laziness then find it elsewhere because laziness equals to the amount of bugs in programming. Rewrite it the C++ way:

#include <iostream>
#include <new>

int main()
{
  char * t = new char[1];

  if(!t) 
    {
      std::cerr << "Memory Exhausted" << std::endl;
      exit(EXIT_FAILURE);
    }

  t[0] = 'A';
  std::cerr << "t[0] = " << t[0] << std::endl;

  return 0;
}

It is still not C++. What we call it now is a mixture of C and C++ provided the programmer does not know about C++ much. He was basically a C programmer and was either forced to use C++ compiler or was too lazy to know C++. Again it compiles/runs fine as it looks technically correct. check out new operator in section 18.6.1 of current C++ standard (you can check out draft of the standard, just google for N3337.pdf). new does not return NULL, hence the check is wrong. new throws bad_alloc() if it can’t allocate memory. Hence the technically correct version looks like this:

#include <iostream>
#include <new>

int main()
{
  char * t;

  try { t = new char[1]; }
  catch(bad_alloc)
    {
      std::cerr << "Memory Exhausted" << std::endl;
      exit(EXIT_FAILURE);
    }
  
  return 0;
}

This will never compile. Why ? Because you did not mention where bad_alloc is coming from. It is in standard library, hence you need to use std::bad_alloc. If you think you simply dump the whole standard namespac by using using namespace std in there, then you really need to read C++ FAQs before writing C++ programs any further. You need to think why I am writing std::cout instead of usual cout used by typical Indian programmers. Let us try one more time:

#include <iostream>
#include <new>

int main()
{
  char * t;

  try { t = new char[1]; }
  catch(std::bad_alloc)
    {
      std::cerr << "Memory Exhausted" << std::endl;
      exit(EXIT_FAILURE);
    }

  t[0] = 'A';
  std::cout << "t[0] = " << t[0] << std::endl;

  return 0;
}

This seems like pure C++. Yes, it is. Sure ? We still have one general programmig problem remaining to be solved. If you call exit() then you are not being practical, e.g. you wrote a client which connects to a server. One of the users of your software is connected and suddenly he is out of memory, then you program will just disconnect without saying a bye. Server will not like it and may log it as an error or will wait for an automatic timeout.

That was a general exmaple, let us look at more technical example. When a game adjusts your resolution to 640×480 and resets it back to normal (say 1280×1024), it will call destructor on 640×480 in resetting but it will not do so because exit() will not call the destructor, you will get stuck in a low resolution screen. It happens when some games crash without throwing an exception and rolling back the stack. So what do you do ? Let us try one last time to write pure C++ code 🙂

#include <iostream>
#include <new>

int main()
{
  char * t;

  try { t = new char[1]; }
  catch(std::bad_alloc)
    {
      std::cerr << "Memory Exhausted" << std::endl;
      return EXIT_FAILURE;
    }

  t[0] = 'A';
  std::cout << "t[0] = " << t[0] << std::endl;

  return 0;
}

NOTE: There is still a way if you want to check for NULL (instead of catch()ing an exception). You can use the nothrow version of new operator which returns a NULL pointer instead of throwing an exception but you have to mention it explicitly.

 


Copyright © 2012 Arnuld Uttre, Village – Patti, P.O – Manakpur, Tehsil – Nangal, Distt. – Ropar, Punjab (INDIA)

Verbatim copying and distribution of this entire article are permitted worldwide, without royalty, in any medium, provided this notice, and the copyright notice, are preserved.

Bitwise-Shifting in C

December 1, 2011 at 12:11 pm | Posted in Uncategorized | Leave a comment
Tags: , , , ,

In my two and a half years stint with C, I was never able to comprehend what bitwise operator do. A few days back I was searching for top C interview questions and I came across this piece of code:

#include <stdio.h>

int main(void)
{
  printf("%x\n", -1<<4);

  return 0;

}

=============== OUTPUT ====================
/home/arnuld/programs/C $ gcc -ansi -pedantic -Wall -Wextra interview-2.c
/home/arnuld/programs/C $ ./a.out
fffffff0
/home/arnuld/programs/C $

If you change %x to %d, you will get -16 as result, fffffff0 is just hexadecimal representation of it. You see that I am using strict ANSI mode and there are no warnings, program compiles fine and gives output as fine as input. Did you notice something wrong ?

Google for n1256.pdf, draft of the ANSI standard and it will be sufficient for your needs if your need is to become a C programmer following ANSI standard and this is what I do. n1256.pdf in Section 6.5.7 (4) states:

The result of E1 << E2 is E1 left shifted E2 bit positions; vacated bits are filled with zeroes. If E1 has unsigned type, the result is E1x2^E2, reduced modulo one more than the maximum value representable in the result type. If E1 has a signed type and nonnegative value, and E1x2^E2 is representable in the result type, then that is resulting value; otherwise , the behavior is undefined.

If you pick up a copy of C – A Reference manual by Harbison and Steele 5th editon, lovingly known as H&S5, you will see section 7.6.3 states:

  1. Applying the shift operator >> is not portable when the left operand is negative, signed value and the right operand is nonzero.
  2. The result value of shift operator is undefined if the value of right operand is negative. The result value is also undefined if the valu eof right operand is greater than or equal to the width (in bits) of the value of the converted left operand.
  3. The right operand may be zero, in which case no shift occurs and result value is identical to the value of the left operand
  4. Each operand must be an integral type. The usual unary conversions are performed on each operand and the result is the converted left operand. The result is not an lvalue.

Did you notice how many things you learned by oberving simple one line program ? Almost 5 basic distinctions before you start using bit-shifting in production environment. I have seen programmers in India (both CS engineering students and professionals doing C programming for almost a decade) always trying to srtive for writing bigger and complex programs and almost always avoiding all these small details of how any one of the C’s basic data structues or operators work. They almost hate going into basics. At the same time I observed masters and C experts writing small, terse, succinct and simpler programmes. I follow the masters. Who does not want to become a good C programmer ?

It is proved that this interview code has undefined behavior. (unfortunately it was a MCQ (Multiple Choice Question) and undefined behavior was not one of the options. You can Google for this question and see the answers for yourself ).

The above problem is just half of the story. Ben Bacarisse on comp.lang.c told me the other half of the story. The “%x” inside printf() expects an unisgned int argument but interview questions is passing it a signed value hence causing Undefined Behavior (UB in short). Hence above interview code is broken 2 times. Replacing that printf with printf(“%x\n”, (unsigned)-1<<4); would have fixed both problems. You can see the original discussion at Google groups and Rhinocerus forums and Velocity Reviews Forums using your web browser. Once again they all represent web-inerface to Usenet newsgroup comp.lang.c. I use PAN for reading comp.lang.c. Google for the list of news readeing softwares.

In fact, this another program is god for understanding how bit shifting works. Again I got it from comp.lang.c discussions:

#include <stdio.h>

enum { LIMIT = 16 };

int main(void)
{
  int i;

  for(i = 0; i <= LIMIT; ++i)
    {
      printf("%d is shifted left by %d bits, place %s = %d\n", 100, i, i==1?"":"s", 100<<i);
    }

  return 0;
}

===================== OUTPUT =====================
[arnuld@dune C]$ gcc -ansi -pedantic -Wall -Wextra bitshift.c
[arnuld@dune C]$ ./a.out
100 is shifted left by 0 bits, place s = 100
100 is shifted left by 1 bits, place = 200
100 is shifted left by 2 bits, place s = 400
100 is shifted left by 3 bits, place s = 800
100 is shifted left by 4 bits, place s = 1600
100 is shifted left by 5 bits, place s = 3200
100 is shifted left by 6 bits, place s = 6400
100 is shifted left by 7 bits, place s = 12800
100 is shifted left by 8 bits, place s = 25600
100 is shifted left by 9 bits, place s = 51200
100 is shifted left by 10 bits, place s = 102400
100 is shifted left by 11 bits, place s = 204800
100 is shifted left by 12 bits, place s = 409600
100 is shifted left by 13 bits, place s = 819200
100 is shifted left by 14 bits, place s = 1638400
100 is shifted left by 15 bits, place s = 3276800
100 is shifted left by 16 bits, place s = 6553600
[arnuld@dune C]$

You will see everytime you shift a bit left, result is as if input (100) multiplied by 2. Hence if you shift 2 bits, the output is 100 * 2^2 = 400 which gives you precise idea of what the output will be without even writing a program 🙂 . Now ask yourself (without modifying the program) what right shifting will result in ?


Copyright © 2011 Arnuld Uttre, Village – Patti, P.O – Manakpur, Tehsil – Nangal, Distt. – Ropar, Punjab (INDIA)

Verbatim copying and distribution of this entire article are permitted worldwide, without royalty, in any medium, provided this notice, and the copyright notice, are preserved.

Create a free website or blog at WordPress.com.
Entries and comments feeds.