Sunday, May 11, 2003



Right tools for the right job





Copyright Notice

Copyright:Ramesh Ananthakrishnan 11th May 2003

Pilfer at your own Peril







  
First, a few words about tools.
Basically, a tool is an object that enables you to take advantage of the
laws of physics and mechanics in such a way that you can seriously injure
yourself.

         
----- Dave Barry in the Miami Herald.



Enginners are like painters. They bring your imagination into reality.
Nothing less, nothing more.

         
----- Scotty [stardate 98613.45765.4.21]





Tools about the house

    
You everyday use around a hundred tools. Starting from toothbrushes, to knifes, and paintbrushes
to pens, there are millions of tools that you use everyday. In fact, you are very particular
about the tools that you use. No more would you brush your teeth with your paintbrush, than
paint your flat with your toothbrush. Somethings aren't just done. Then why is it that, most
IT proffesionals know abt. just two-three languages when they graduate. In fact, they attempt
to implement all sorts of projects with just these three four languages. In fact, they hardly
even use other tools to improvise productivity. No more is this more evident than in the project
that they take up during their final sems.
Let me count as a mere exercise
the number of languages that they know.(NOTE: IT'S WHAT THEY KNOW. NOT WHAT THEY ARE TAUGHT)



1. C (good)

2. C++ (o.k.)

3. VB (excellent)

4. Java (bad)

5. Assembly

6. Cobol (gone the way of all mortal things)

7. Pascal (gah...)


Seven languages!!!! that's it? Most of these languages have been around since
the 1960's, and the only one that has a form of garbage collection and dated post
1980's is Java.GREAT!!!
And the only interpreted language is assembly. Great!!!! Since this is
what most students are taught, and since none of them is even taught to link against
a library they certainlly come up with a very warped idea of what CS is all about. They
think interpreted languages are slow, everything can be done if you know only C, VB is
the only way to draw Windows, and then spend three months trying to make an OS on a disk
and 6hrs. before project submission are still wondering why their string library is leaking
memory. Sheesh!!!





Programming in the Real World

    
Programming in the real world is all about using the right tools. Nobody cares if you
are a gung ho C expert. You can't even get code to work on unless you know how to use
some basic tools like CVS, diff, grep & perl. Yes! And if your project grows really big
nobody is going to give you credits for having done parts of it in deadly Object Oriented
C++ or Java. The trick is to see the larger problem and think about finishing the project
and not get bogged down in using all the finer aspects of the language. In fact, programming
in the real world is about making the right design choices from using the right
language, to the right object designs. For your own sake do not reinvent every bloddy
technology you encounter in C and don't think C is the only language around.
Some of the language, tools, and technologies encountered in the real world are:

1. COM/Corba XPCOM

2. XML

3. SQL and varieties

4. Perl

5. Python & Jython

6. Ruby

7. Swig

8. PHP Meerkat

9. Javascript

10. Lisp (CL, Scheme, guile)

11. Qt Gtk, KDE, Gnome, Tk and XUI

12. Rose suite, Unit testers

13. TCL

14. OML, caML

15. MatLab's M scripts. Ocatve, shell scripting.


But there are a lot of myths about some of these technologies. In fact, they are now
more urban legends. So let me dispel the myth for you and hope to convince you to use
the right tools in the real world.





Myth 1: You can do everything in/using C

Nope you can't. Even for programming in C you end up using a lot of tools that were
written in C. Like your editor and compiler. You don't start writing a C program,
by composing an editor in assembly first, and then making a C compiler in assembly.
You use the tools as is, and that's right. Other tools like PHP , Perl are tools
written in C, to do a set of jobs elegantly. In which way they are just like your text
editor. They do the job they were meant to beautifully well. Which should reveal a truth
about C to you. It's like the scaffolding outside used to construct a building. You cannot
construct the building without the scaffolding. But neither can you use the scaffolding for
everyday living, or build a building from scratch everyday. Tools are like that. They
are prebuilt and meant to ease life for you in certain particular areas. There's a more
philosophical note there but I'll leave it to you to explore it.





Myth 2: You can't do major stuff using some of these tools

Really?

TRUE FACT: Two friends of mine tried to write a program to solve a linear equation.
They took 6 days and at the end of that time were still struggling to make sure that the
strings grew dynamically. In Perl the entire script was 6 lines, and that includes comments,
and other features they acknowledge they could never have completed.

Yea! Yea! I know the argument. But I know only C! you say. Ever thought of learning Perl. It's
easy, comes with it's own documentation and other goodies, and can completely be learnt in a day.
I agree with Spolsky, that learning a new language is an investment of time, but that's time
well spent. I'd rather spend one day learning Perl and writing 6 lines of Perl code
to do stuff, than write 200 lines of C to do the same, and wondering where the memory leaked.
Here again use your discretion. If C is your forte, and you usually run up a pretty good
kernel before lunch, use C. However if you are having problems with pointers and lot,
shift to Perl. You are not going to be any the worse off. In all cases use your common sense.





Myth 3: Some of these languages are interpreted and we know interpreted=slow

ROT!!! Everytime I hear that I'd like to tell you people that the end result of compilation
is interpretation at the assembly level.
Sure interpreted languages compile and parse your program every time it's
executed, but the general structure of the language is so much better that somedays C compilation
seems to take eons compared to the time it takes to run a Perl script. In fact, interpretation is
so neat and just in time, that I frequently write programs that correct themselves. And some
interpreted languages are tuned for some jobs that really there is no way to match their speed
even using C.

e.g.: for searching patterns in a file, a C program and a Perl script were compared. Total
execution time for C program 25 seconds.
Perl code did the
same job in 2 seconds. The C code was hand tuned for speed. If that's the best the proffesionals
could do I wonder how much faster you can make your C code. And why do you need the speed,
are you doing Kernel programming? Remember, good algorithms and thought can make your programs
fast. If your algorithm is lousy there is no use blaming Perl. Your program wouldn't do well even
in C.





Myth 3: Only Java has a GC,references, VM, cross platform,security,netowrking


Java though nice is a pretty new language. In fact, it borrowed the concepts
of GC, references, platform portable, networking all from other languages. In fact,
there is nothing that cannot be done in Perl or Python or Ruby in a easier fashion
than is possible in Java. In fact, Java is mightily slow compared to languages like Perl
and Python. Both Perl and Python have GC's and references. They also have their own
virtual machines and can do windowing code both in Linux and Windows and MacOS with the
same functions. They are platform compatible, generate bytcode and don't stuff OO down
your throat. They also are extremely robust and don't hog memory like the JVM.
In fact 90% of the networking code on the Internet is written in Perl. Sys admins trust it.
8 years after Java's introduction to the world it has yet to account for even 2% of the world's
networking code.
DNS run on Perl. I have yet to see one that works on Java or a sysadministrator who trusts
a Java program to do his work.





Myth 4:Some of these languages aren't OO

OO is like colour. Even though a paper is black and white it's easy to splash it with
colour. If its necessary you do it. Java forces OO down your throat, and needlessly puts OO
in places where it isn't wanted. In fact, like C++ Java evolved with OO as a retrofit. Plus
like C++, Java has a ridiculous type mechanism. With the result, most times you waste time
getting the program to pass the compiler. If you want real solid OO try Ruby, or Jython. Both
do what Java does only better. Perl does OO, and it's non paranoid OO. This means lots
of saved effort. 90% of the time your project just works.... And anyway OO is a concept.
Sometimes it's needed, sometimes it isn't. A project should use OO only if it's necessary,
not as a boast.





Myth 5: BUT COMPANIES HIRE YOU ONLY IF YOU HAVE DONE C/C++/JAVA PROJECTS

If you check the Hindu ads, over the past one month you'll find that 50% of the jobs are
for guys who have knowledge of financial packages that are beyond the reach of students.
e.g.: Siebel, SAP,...
Of the remaining a large part of the skillsets are C, but other langauges you should know
include Perl, Python. The toolkits you should know include MFC, Qt. But you are in great
demand if you know Linux Kernel Programming.
Jobs are available for EJB, Java, Swing guys but these are available only in the finance
sector. Since, many many people know Java, it would be nice to differentiate your resume
from the hoi polloi by including another language or tool to your resume.





Myth 6:But most of these technologies are on Linux, and that's hard to learn

Heh! All these technologies are also available for Windows. In fact, unlike Windows
technologies all Linux ones are almost platform agnostic. And dear me bhoy, you'd better
atleast know Linux if you forsee any scope in continuing in this field. And forget abt. it
being difficult to learn. In fact, Linux (o.k. Linux is used here to denote Unix variants) is
much better logically organized than all of windows.... Yes! it's difficult to find people
who know beans abt. Linux. But that's good. If you know beans about Linux while nobody
else has a clue that means you've specialized man... Join your nearest Linux user's group
and learn Linux.








Myth 7: But these tools cost money

No they don't
    
Most times Windows comes up with a new technology, it's proven pretty expensive. When VC 5.0
came out I thought I'd buy the VC compiler and the suite. Wow!!! I found out it would cost
me a cool 1.5 lakhs. So I dropped that and installed a pirated copy. The problem was a complete
lack of documentation. So I tried purchasing a MFC for Windows book (Cost:1600Rs/). It didn't
tell me how to animate the wallpapers. So I bought Advanced MFC (Cost:2600 Rs/). Advanced MFC
said the answer would be in Win32 API and why don't I go look there. So I borrowed Win32 API
from the library. Searched it for a whole month. Didn't have a clue, though it asked me to look up
the call in MSDN (late fee: 160 Rs/). MSDN CD costs (Rs:400/). And even then I didn't have a clue.
Great!!! So I switched to Linux and believe me the sweetest thing was that the documentation
comes along with the system. I have learnt PHP, Perl and Python on my own and the total amount I
spent was nil. (Hint: I borrowed the Linux CD from my neighbour.) And don't worry. The Linux
philosophy is sharing. So you need not be concerned about copying software. In fact,
Linux enncourages it.





Myth 8: But all the hot projects are in Windows

No way!! Almost, all research takes place on Linux systems. Other than IIT maggots who use
Windows, and have hardly done any research, you can find a lot of cool cool projects in Linux.
Check out slashdot and other tech sites to learn abt. the
cool cool projects you can contribute to. Also remember that most of these projects are
international, and are recognized throughout the world, and the only admission requirement
is that you can code well. Think about it! You can participate in a high level
international research project for absolute peanuts
Isn't that something that would
look nice on your resume?






Myth 9: But there's nothing like VB in Linux

Heh!! In fact there are too many VB's in Linux. There is wxpython and wxperl and tk and tcl
and you even have a C# compiler and .Net libraries in Linux. Check out some of these
tools, they infact work better than even VB.





Myth 10: But C has excellent library support. Do these tools?

Yes they do. In fact, the amount of support they have is fascinating. In fact, it's easy
to find libraries to do whatever you want to in Perl and Python. They are neatly packaged
and are easy to install whatever be the platform or machine you are using. The packages
themselves easily take care of dependencies and all. Try doing that in C!





In fact, using some of these tools can really improve your chances of being hired, besides
improving your knowledge of computing in general. Don't hesitate.. Pick a new tool today.





0 Comments:

Post a Comment

<< Home