7 Things You Need To Know about Programming: The Art of Programming
|courtesy of SafeTrac|
Is it enough to learn a single programming language and live with it?
Like working in a single language for the entire life? Oh C’mon
My answer is big NO. I mean not at all. A single language can work pretty much everywhere but one language that performs well somewhere does not mean that it will perform that much good elsewhere. There is always a better choice available.
To get your hands on a well-paid job, or to make an attractive freelance profile or to pursue further studies in computer you should master one and get familiar with at least 3 languages.
Let’s throw the blue collars, white collars, t-shirts and whatever out of the scope of this article and focus on students only.
If you have read my previous post, if you haven’t then I would recommend you read it first, then you should have got the idea that it is pretty handy to end up with many choices. But in terms of programming, how could someone manage all the stuff? How to switch to a new language? Does it take as much long as it took to learn the first language?
No, it is easier than you think.
How? We cheat.
If you can work in a single programming language it means that you can work in other languages too. It will take you approximately 2 weeks or so to learn a new language but there is a learning approach which helps to achieve such an amazing result.
Without any further ado, let’s dive in.
In order to increase your learning curve exponentially, you should know the fact that there are many things common in almost all programming languages. Learn one and master all. I will list a few here:
- Data structures
- Conditional statements
- Iterators / Loops
- Class and Object
In all enlisted terms above, the common thing is the concept and the difference is the syntax. To build a program you will need to make an algorithm and to create an algorithm you will use pseudo code which has no syntax but concepts. Google can surely tell us syntax for all languages, then why we would waste our own natural storage? And believe me nobody remembers syntax. If you don’t believe me then go and watch live programming sessions. You will get your answer.
It’s time to work with the list.
1. Data structures
2. Conditional Statement
The switch statement, if and nested if else structure are conditional operator are conditional statements. The common thing is the overall structure. They all have a test condition, a true block and a false block. If the condition is true, true block runs and if the condition is false, the false block runs. The difference is their syntax.
3. Iterators / Loops
Every language that I have ever SEEN uses loops for repeated execution of a block of code. You will never see a loop used for something else. All you need is to feed this to your mind that anywhere you need some repetitive execution, the choice is loop. Whether you are working in java or python or a super complex alien computer language.
Functions, methods, procedures or whatever you call it is a way to avoid writing some code again and again and again. The purpose of functions is to save you time, space and money. Functions save money? It does not make any sense.
Time is money.
Jokes apart. Functions have 4 things in common. A name, input parameters, return data and a call to the function. That’s it. Although different languages have different rules for naming functions but almost in all languages functions do the same job.
5. Class and Objects
If we go with the traditional boring definitions then class is a blue print and an object is an instance of class. Class have methods and variables and we need to create object to use the class members, excluding static members.
You will have to create objects if you need to use the functionality provided by the class whether you are working in CPP or Java or whatever else Object Oriented language. This is the common thing.
The difference is in the syntax. Like new keyword is used to create object in Java while in CPP new isn’t needed.
Where there is a will there is a way and where there is OOP there is inheritance. The parent child business.
Inheritance is a common concept of OOP where a child class inherits some properties or behavior from another parent class. The story is the same everywhere, a child parent relation. The difference is in the syntax. Also, some languages allow one type of inheritance while others allow the other type.
For instance, C++ allow single, multiple and multi-level inheritance and Java does not allow its users to use multiple inheritance. Although Java developers cheat with java for multiple inheritance but this is off the topic.
Polymorphism means many forms. In OOP, a function have the same name but different implementations. It sounds like function/method overloading but it has nothing to do with function overloading.
Overloaded functions belong to the same class, having the same name but different parameters. Polymorphic functions belong to different classes. To achieve polymorphism, it is necessary to have more than one classes while for method overloading a single class is necessary.
Above theory is common in all object oriented languages. The difference is the way how polymorphism is used.
In C++, virtual keyword is used in combination with inheritance (inheritance is necessary) however in JAVA, you do not necessarily need to use inheritance. Interface is enough.
Finally, we are at the end. I tried to be specific, to the point. I will write in details about each of above. To summarize, invest more of your time in understanding the concepts of programming rather than the syntax of a language. Once you master all these, it will take you less than a month to learn a new language.
The above list is not complete. I mean we can add more things but for brevity, I picked these few very basic building blocks of programming.