2
$\begingroup$

I am learning compiler in my Uni. I have been through all major compiler techniques like top-down parsing, bottom-up parsing, Lexical analyzer, Symbol table, etc. I have a good understanding of them, but I am still confused about the course.

What is the point of learning all these things? What are their applications? Where these applications are used? The main point is, if someone asks me, Why Compiler? What is the benefit of taking this course?

$\endgroup$

closed as primarily opinion-based by Derek Elkins, xskxzr, Evil, Discrete lizard May 17 at 5:52

Many good questions generate some degree of opinion based on expert experience, but answers to this question will tend to be almost entirely based on opinions, rather than facts, references, or specific expertise. If this question can be reworded to fit the rules in the help center, please edit the question.

  • 1
    $\begingroup$ I think that historically, compiler design has been a driving force behind a lot of research in math and (theoretical) computer science. Also, it's perhaps a nice example of a challenging program with many non-trivial pieces. The benefits of solving these problems efficiently has considerable practical value as well. $\endgroup$ – Juho May 16 at 19:27
  • 7
    $\begingroup$ Why are you studying in university at all? You could just take a professional course on programming. $\endgroup$ – Yuval Filmus May 16 at 19:30
  • $\begingroup$ Well, I am learning other courses in computer science as well :P $\endgroup$ – AHF May 16 at 19:45
  • 2
    $\begingroup$ Compilers, Context Free Grammars and such are a great example on how you can "understand" the exact meaning of a program, while only knowing the formalism of the language the program is written in, which is its syntax. $\endgroup$ – Emanuele Giona May 16 at 20:16
  • 1
    $\begingroup$ I think that currently, this question is too open ended to only admit focused answers. In particular, you should clarify who "we" is here. It seems you are a computer science student. What is your goal of studying this program? To become a software developever? To do research in the field? Something else? Perhaps you mean what the intention was of the person who designed your study program? For now, I'm closing this question. I think it can be reopened if you clarify this. $\endgroup$ – Discrete lizard May 17 at 5:52
9
$\begingroup$

Let me break up several possible interpretations of your question:

What is the purpose of learning compilation?

There are several possible answers:

  1. So that you know how to build a compiler should you have to. This is not a good answer nowadays.
  2. Part of the goal of the computer science curriculum is to explain to you how a computer works, stopping at the hardware. This includes the operating system, file systems, the compiler, the network stack, and more.
  3. As a programmer, you will be using compilers. Sometimes it will be useful to know what happens under the hood. For example, understanding garbage collection will help you choose which language to use in embedded applications.
  4. Compilation is part of the standard curriculum, so you might get asked about it in interviews.

Why are they teaching me compilation?

Apart from the reasons listed above, there is an additional one: universities are very conservative. In the past it used to be more important to understand how compilers work. Nowadays this is less important, but change is slow, so material that made sense 10 years ago is still being taught today.

That said, some universities might reform their compilation curriculum, for example by de-emphasizing parsing, concentrating on more exciting aspects such as optimization, memory management, dynamic and static analysis, and the like.

Why am I studying compilation?

As an aspiring programmer, your university training contains lots of apparently useless classes, for example calculus. People choose to go to university for various reasons - it's a rite of passage, an opportunity for socialization and finding a partner, and it might help you get a job; or even just family or peer pressure.

Some people do away with university training, preferring other formal training, or even self-training. Some of these people are very successful. For whatever reason, you chose to attend university rather than any of these alternative routes. You should accept that university training is rather theoretical, and try to make the most out of it.

$\endgroup$
6
$\begingroup$

I have stumbled into this question ( and the whole CS site in general ), and I had never actually studied CS officially, but I will try to answer. ( not in order of importance )

General :

  • I am not sure what country / terminology you are from but ( usually outside the US ) university is not a college and a college is not a university. While colleges aim at precise jobs education, university is a broader education that aims at more general understanding and horizons.

  • On the same note, CS is more like Architecture rather than Building Engineering. Architects aim at a broader, "big-picture" education. Building engineering is more about Details in the realization or application of the design.

    • You can learn to pilot an aircraft without knowing the mechanics of how the aircraft works. But never a good pilot, let alone an excellent one. same goes for a F-1 driver ( or any driver / Equipment operator actually).

    • In long terms contributions to society and progress and technology, who will score more : the aircraft pilot / Formula-1 driver or the people who designed the aircraft / car ( engines, aerodynamics, technologies etc ? )

  • Designing a compiler means designing / creating the technology. Using the language / programming / designing the software means creating the application of that technology。

More Specific

  • How do you think new languages / technologies are designed and born ? with old compilers ?

  • similar to above in one (important) word : research. this is where programming languages research is done. Not just a language that is the same in a new packaging. but a really new one.

  • Compiler teaches you how real world applications are working and how to design them.

  • Learning Compilers gives you with both theoretical and practical knowledge that is crucial in order to implement a programming language. It gives you a new level of understanding of a language in order to make better use of the language ( optimization is just one example ).

  • Sometimes just using a compiler is not enough. You need to optimize the compiler itself for your application.

  • There are certain things you can only do at compile time. see JIT as one example.

  • Compilers have a general structure that can be applied in many other applications, from debuggers to simulators to 3D applications to a browser and even a cmd / shell.

  • understanding compilers and how they work makes it super simple to understand all the rest. a bit like a deep understanding of math will help you to understand geometry or physics you can not do physics without the math. not on the same level.

  • Just using something (read: tool, device, software, programming language) is usually enough when everything goes as expected. But if something goes wrong, only a true understanding of the inner workings and details will help to fix it.

Even more specific ( to your concern regarding hiring )

Compilers are super elaborated / sophisticated systems ( architecturally speaking ).If you will say that can or have written a compiler by yourself - there will be no doubt as to your capabilities as a programmer. There is nothing you can not do in the SW realm. Interview over.

Pick your answer.

P.s.

try to change the "we" in your title to "anyone".

"Why would anyone learn compiler" ?

Does this question makes sense in a world that aims at progress ? ( even more - the High-tech world that supposed to lead that progress? )

If your question is aimed at yourself - e.g. why should you learn this subject - no one can really answer that but you. But you must agree that someone should..

.. and that someone will be from the cs field.

$\endgroup$
3
$\begingroup$

Because you are a Computer Science major and you have to deal with all these. A few months ago, I was also having the same question, while studying for the Computer Architecture finals, why am I even dealing with all these root level stuff, assembly code, optimizations while my friends from IT and Software development major learning new programming languages and frameworks which are going to help them in acing the software developer interviews.
Well, Computer Science deals with all that is involved between tiny logical gates to magical modern day software. While Software development is learning how to stay afloat in a vast ocean, Computer Science is advanced scuba diving. As you will go with the courses like, OS, Computer Architecture, Compilers, Theory of computation etc, everything will start making sense to you. I mean, EVERYTHING!

$\endgroup$

Not the answer you're looking for? Browse other questions tagged or ask your own question.