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.

For example JavaScript works best in web applications but it won’t work the way Python woks for Data science. I hope you got the point.

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:

  1. Data structures
  2. Conditional statements
  3. Iterators / Loops
  4. Functions
  5. Class and Object
  6. Inheritance
  7. Polymorphism

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

The most common thing is all computer languages is Data Structure. A variable will always be a variable and an array will always be an array, every time, everywhere. What is a variable? A name of memory location. What is does? Stores data. What data? The data you give it. I mean the common thing is its functionality, to store value. The difference is the limitations that different languages impose. For instance, Java does not allow you to put a string data in an integer variable but JavaScript allows. Same is the case with other 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.

4. Functions

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.

6. Inheritance

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.

7. Polymorphism

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.

Conclusion:

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.

Happy coding…

Comments

  1. > you will use _sedo_ code

    Typo: "pseudo".

    > Where there __ a _well_ there is a way

    Word missing: "is".

    Typo: "will".

    > Finally, we are __ the end.

    Word missing: "at".

    ReplyDelete
  2. I liked your article. Would you show the different building blocks in a few different languages like Python, Java, Javascript?

    ReplyDelete
    Replies
    1. Thank you Ikem for the feedback. It really means a lot to me.
      And yes of course, I will write separate post on each point of the list. It is on my schedule.

      Delete

Post a Comment