Wednesday, March 6, 2013

RTFM

If you're wondering what the title means, it stands for 'Read The F***ing Manual'. It's a pretty popular line in programming circles, and I've been realizing it more often. Latest episode being today when I discovered (unfortunately so late) that atoi() function in C actually accepts partially correct strings (strings containing alphabets and decimals) and produces a result without complaining. I assumed it to return some wrong value or throw some exception, but to my surprise, it didn't. I posted this in Stackoverflow here and got some good responses. And eventually I realized that it was mentioned clearly in the C manual about the behavior. Now why is it that way is something that I did not understand. But I did understand that you need to RTFM!

Now, this happened to me during some pastime activity, but imagine this happening in real production scenario. You end up doing some silly mistake in the code and end up spending a lot of time trying to figure out the problem, only to figure out later that you should have read the manual thoroughly. Most of the times and probably lot of our knowledge on a programming language/framework is obtained through observing others code or by consulting with others. We often don't have enough time to read that specification/ documentation thoroughly before we actually do something in it. And in a way this is good - all study and no practice will not gain you much. May be you'll remember it for a longer time once you actually burn your fingers. But do you really need to burn them? May be a simple look up in the reference should have saved your precious time!

So should you spend days reading the ISO C++ spec? No, just keep it handy and refer to it once in a while. 

Happy coding!

Sunday, March 3, 2013

Weekend learning: LaTeX

I've always been amazed by the type quality of the technical papers like IEEE and ACM. I always wanted to  produce my documents in such high quality. I learned that they were not written in any normal text editor or word processor like MS Word, but were specially type set using a framework called LaTex (pronounced 'lay-tek'). I looked up on the internet and read some articles on LaTeX but found the framework very powerful and intimidating. And so, I put off investing any effort in learning this framework.

Last month, I bought a text book on Compiler theory (the classic red dragon book) and found that the book had been written entirely in LaTeX. I was taken by the beauty of the typesetting in that book. And this triggered the urge in me to learn LaTeX. So I started off my efforts into learning this new tool and downloaded the tools needed from an internet site. It's free of cost and comes with everything you need to produce documents ranging from a simple article to books - compilers, language packs, style packs, text editor, PDF viewer and much more. Now on to more about using LaTeX itself.

LaTeX is a typesetting program originally written by Donald Knuth (yes, 'the Donald Knuth') from a need to produce high quality, standard way of producing technical papers including lot of math symbols. Later it was developed by many people in the open source community and is now a collection of great tools. LaTeX is a very intelligent program that frees you from all the typesetting headaches while you are writing a document. Imagine all the fiddling you need to do with the rulers, sections, etc. in MS Word while trying to write a moderately complex document such as a project report or a thesis. LaTeX allows you to focus on the content leaving all the typesetting headache to it. In a typical scenario, one writes the document and embeds a few 'commands' which direct the LaTeX system to typeset the content. It might be a little confusing at first, but there's great documentation to get started with and also there's a vibrant community to help you.

There's a lot more that you can produce using LaTeX apart from just technical papers. Over the period of time since it's inception, people have extended the capabilities of LaTeX to produce a variety of documents including - articles, letters, flyers, presentations (yes, the Powerpoint ones), mind maps, chemical composition diagrams, etc. At this point, I think I've said enough about LaTeX and I think you should start using it. I've included some references here which contain great information about LaTeX.

Have fun, happy TeXing :)

Resources:

  1. http://www.latex-project.org/ - the main source for everything LaTeX.
  2. http://www.tug.org/protext/ - software for LaTeX in Windows.
  3. http://en.wikibooks.org/wiki/LaTeX - the awesome book!
  4. http://latex-project.org/guides/ - other collection of good documentation.
P.S. I am not propagating against MS Word here, I would still love to write small, regular documents using MS Word. LaTeX can be very time consuming, so I suggest you to go for it only if there's a pressing need.

Monday, January 21, 2013

Poking into unrelated things; organizing things

This happened when I was doing my Masters. Our college had organized an event/seminar for which external scholars were invited. Now I was no where involved in the whole organizing thing and I had no clue of things on that side. I did know that there was an online registration for that event. So on the day of the event, with unnecessary enthusiasm, I volunteered at the reception counter. Interestingly, our guys had kept registration forms for the participants. I believe they were for the people who had not registered themselves online. But somehow our guys started asking all the participants to fill up the forms. Now some people patiently did fill the forms. And then I entered the scene and with utmost decency asked an elderly person, who was accompanied by his wife, to fill up the form. This pissed that man off to no limits. And the conversation between us followed:

Me: "Sir, could you please fill up this form for us?"
Him: "But I registered online"
Me: (Oh shit!) "But sir we need you to register  here once so that we can give you the ID card" (Oh yeah! like he cared!)
Him: "Why should I fill again!"
Me: silence, confused, put up an awkward face.
Him: "Don't become so inefficient from now itself! You should learn how to organize things!"
His wife: "It's OK. Don't mind. Let's go in."
Me: "Sorry sir, we'll note that"

And I learnt something that day: 
  1. Never get into things which are not related to you - especially in between.
  2. Always take care of the redundancy for the user - why do people need to fill again if they had registered online already?
Keep learning!