On learning C++
"You are number of languages that you know" said one of the quotes attributed to Al-Farabi, which my school teacher used to tell us. Indeed almost all languages describe the same objects: humans, animals, nature and universe in general. However, the way each language does so might differ from another one. This difference makes learning new languages fun. A somewhat similar statement can be said about programming languages. Almost all of them perform some kind of logical and computational transformations on given data, however the ways they do so might significantly differ. Having learnt some Python to play with Machine Learning (ML) algorithms, I wanted to explore other programming languages. The first language which came to mind was C++. It is one of the languages used to code massive and complex software systems. So did I explored using a website https://www.programiz.com/cpp-programming.
How it went
The installation part went easy. The application XCode does a solid job for Mac users. The first surprise came with 'Hello World!' program. In python this program runs with a one line:
However in C++ the 'Hello world!' program looks like this:
Compared to Python's code the above code looks rather long. The main reason for the code to be that long is the need to import all subprograms which ensure work of the main program. This means that as programs gets more complex, the current stark difference in lengths of codes should decrease.
Another surprise has to do with declarations of variables and user-defined functions beforehand. In Python one could use variables without ever declaring them. One could also use functions, provided that function is within the reach of the main program. In C++ one has to do declare variables and functions beforehand. So, if I want to use a variable 'a', I should write 'int a;'. If I want to use a function 'func', I should first declare 'int func(int, int);'. All of this requirements might seem daunting at first. However, they impose certain rigour to the process of coding. On a positive side, all of this rigour is said to pay off with execution time, which is yet to be appreciated.
How it went
The installation part went easy. The application XCode does a solid job for Mac users. The first surprise came with 'Hello World!' program. In python this program runs with a one line:
However in C++ the 'Hello world!' program looks like this:
Compared to Python's code the above code looks rather long. The main reason for the code to be that long is the need to import all subprograms which ensure work of the main program. This means that as programs gets more complex, the current stark difference in lengths of codes should decrease.
Another surprise has to do with declarations of variables and user-defined functions beforehand. In Python one could use variables without ever declaring them. One could also use functions, provided that function is within the reach of the main program. In C++ one has to do declare variables and functions beforehand. So, if I want to use a variable 'a', I should write 'int a;'. If I want to use a function 'func', I should first declare 'int func(int, int);'. All of this requirements might seem daunting at first. However, they impose certain rigour to the process of coding. On a positive side, all of this rigour is said to pay off with execution time, which is yet to be appreciated.
Comments
Post a Comment