Wednesday, December 3, 2008

Learning the Language

Today we have a plethora of computer languages, mostly open source, to pick from to suit our needs. For example, for simple web applications, there is PHP, for programming dealing with heavy math calculations, we can use Fortran and so on and so forth. Coming to my mother tongue, Java; it is a boon for large enterprise level applications. The advantages that distinguish Java from other languages are 1. Object Oriented paradigm, 2. Automatic memory allocation and garbage collection, 3. Enterprise level support, 4. The number of java professionals available, 5. Enterprise security and many more.....
Through this post, I want to express the problems I faced while understanding the language. When I first heard the name, I didn't know that there are language paradigms like object oriented, procedural etc. A language is a set of instructions given to the computer, that's all I knew from my minuscule experience with Fortran and C. But here I was determined the learn the omnipotent language.
The first day of training was exciting with the trainer promising big. The second day he started with a comparison between procedural and OO concepts. We were told to imagine everything as object. "The chairs, tables etc are all objects, and java works with objects", he said. So far so good, but nothing related to coding, I thought. Then we started with the core OO concepts like Polymorphism, Encapsulation etc. As examples, the trainer was writing some rough code on the writing board, but hey, I don't know the Java syntax at all. What I found was that I was somehow trying to relate the concepts with the syntax, which was totally foreign to me. How exactly the Car extends the Vehicle, and how does java fit in, was the question I was repeatedly and compellingly asking myself.
So the first problem which I faced while learning java was a desperate need to at least have a basic understanding of java syntax and code structure; the knowledge that java does not start with a #include, or that java code can be distributed through different files, that there are packages, or that java code is written inside a class(!!! Yeah, most of us didn't know even that), or that Class actually means something to the language, etc. It was almost like the package and class code was something by default that the code puts in. Days went by and I was still imagining how can java make a horse a 'type of' Animal, and how a Car 'has a' engine (I was quick in figuring out the grammatical exception there ).
From my experience, the approach that I would prefer as a trainer would be to first make the trainees write a java code to print out 'Hello World!'. This would at least give them a rough structure of java syntax. So that when I tell them that class Car implements the method drive( ), they understand that I am not talking about putting engineering flow charts into the method. This should be followed by the OO concepts and so on and so forth.
The most celebrated book among java newbies, the Head First Java, follows the same approach.