Computer Science, asked by mashukameghna9798, 7 months ago

As a software developer, why should I learn about compilers?
Is it applicable on the job at a mobile app shop or internet startup?

Answers

Answered by Prabhas24423
2

Answer ⤵️

The answer to your first question is yes. If you have a good grasp of how compilers and interpreters work, it helps you a lot in *quickly* learning new languages and debugging code written by you or others. Before I elaborate, let me answer the second one too. Even if you do not write or maintain full fledged compilers for a living, both the theory and the tools you learn when studying compilers, turn out to be very helpful in a lot of situations. I try to explain these points below.

A very important and certainly one of the most time consuming part of software development is debugging. Whether it is a compilation error or a malfunction of your code at run time, understanding of compilers helps narrow down erring code much more easily.

Compilation errors are almost always cryptic and generally get reported somewhere other than their point of origin. Very often programmers, unable to reason about the cause of a compilation error, start making random changes to their code which wastes time and make their understanding of the language shaky. This problem is specially acute when you are learning a new language or paradigm. For example many C compilers would complain about missing braces or semicolons as "Unexpected end of file." Most people learn about these errors the hard way, by grappling with them and trying a number of arbitrary hacks elsewhere in the code. However, if you know a thing or two about error recovery in compilers, it is much less painful hunting down the culprit piece of code.

Perhaps the biggest impetus for learning compilers is the understanding you gain about how disparate programming languages are built atop the same binary code(s) and how different language features actually work, why these features are not present in some languages and why some things are very easily done in one language but very difficult or impossible to achieve in a different one. For example many programmers know that in Java and many others modern languages strings can be concatenated with the '+' operator, but most are clueless about why this is not possible in C, or that in Java it is possible to change the code at run time (called reflection ) but not in, say, C++ (well, at least, not in native C++) . Most programmers think that particular features are magically present in certain languages. Armed with an understanding of compilers it is easy to comprehend these features and their powers and to reason about their presence or absence in different languages.

Understanding compilers lets you grasp new languages and paradigms swiftly. Whether you are learning a new language for full time programming or just trying to figure out why a piece of glue logic, written in a scripting language unknown to you, keeps failing, knowledge of compilers comes in handy. For example with a compilers course under your belt it is easy to understand how pointers work, so that you do not have to memorize rules for using pointers, pointers to pointers, pointers to pointers to pointers and things like that. Similarly you are able to understand why a seemingly innocuous shell script throws several pages of errors e.g. .

Finally, with your knowledge of regular and non-regular languages you gain insight about how regex matchers, lexer and parser generators like grep, lex, yacc work and you can correctly identify the correct tool(s) to use in a given situation. See for example . Programmers often have to write small snippets of code for reading and validating input from files. Knowledge of language processing helps immensely in writing neatly structured code.

Similar questions