Compilers v/s Interpreters
Compilers v/s Interpreters
Do you know that I can talk to my computers? Well, don't be surprised, it is not that difficult; Most of the high school students and developers do that daily. Moreover, the better you talk the better you are paid. Now, before you start dreaming of gunny bags loaded with cash, you need to understand that to talk to computers, you need to know their languages. Once you master this art, you can make it serve you better and then resume surfing through your dreams.
Just like the homo-sapiens (human beings), you can talk to your computer using various languages. The core of your computer understands only one language - the machine code. But, some smart engineers have built tools like compilers and interpreters that can convert our instructions (technically called high level source code or just code) written in programming languages like C++, JAVA, Python, C#, etc. to the machine understandable format. Let us first understand the above mentioned two tools:
Compilers: When your script (code) is translated by the compiler, it is always translated as a whole. The compiler then generates an independent file called as the executable file with .exe extension (in case of Windows OS). This executable file is then directly executed by the OS to generate the output as per your code. Since, the code is already optimized and presented as machine understandable format in the executable file, it is fast in execution. C++ uses compilers and this is the reason why you see an executable file in your workspace when you run a .cpp code.
Interpreters: Interpreters play a little safe here. They have a different approach where they translate the user written code line by line into machine understandable format. Though the process is a bit slower than a compiler, it makes debugging easy and helps us detect the exact lines of code where debugging is needed.
This does not end here. Just like while learning any language we learn the alphabets, phonetics, spellings, etc., while learning programming languages we mainly focus on the syntax of the language and the data types and then to enhance our understanding and proficiency, we learn the data structures and algorithms that can be implemented using the language. This is where the real game begins and exactly what major firms look for in your resume before on-boarding you.
To learn any programming language, the strategy is simple. You just need to practice consistently and look for optimizations in your code. You need to optimize your code in such a way that it achieves the desired result in the fastest possible way, utilizing minimum possible disc space. Once you are able to do that, you are already among the league of coders who can actually write "good code". And trust me, that's rare...