Is it beneficial for a programmer to learn how to build a compiler?

前端 未结 17 1159
难免孤独
难免孤独 2021-02-07 01:10

There is a lot of variety when it comes to the different types of programmers. In general, is beneficial for a programmer to learn how to build a compiler? In what cases would

相关标签:
17条回答
  • 2021-02-07 01:42

    While few programmers will ever end up having to implement a compiler, the earlier stages of compiler building, namely lexing and parsing are something that can come up far more often: Who hasn't had to write a parser for some strange file format? Usually, those are simple enough to manage without experience in compiler building, but not always.

    0 讨论(0)
  • 2021-02-07 01:44

    In todays' industry, if you can do a compiler, then your like a 3 y/o kid thats' learning how to count (that being the upper limit of my intelligence gives me an IQ of about 18 as far as the field is concerned); and its just as essential too: as quoted in the dragon book, every application with a user interface defines a programming language.

    Furthermore, new programming languages, such as zonnon and composita, use syntax directed protocols for communication between live objects. They define protocol types which specify the interface to a server thread as an EBNF grammar. That makes it impossible to code the message handlers if you havent' written a compiler!

    Syntax directed protocols are the best way to deal with things like web servers that use text-based protocols; so its very possible that this will become the method of choice. However, both languages restrict the protocols to LL(1) grammars (for very obvious reason), and this may prove to be too restrictive.

    While the current implementation of zonnon is still a bit on the glitchy side; and the language definition doesnt' seem to be complete yet either; i will nevertheless be so bold as to venture that zonnon (or something similar) will put C# in the garbage bin where it belongs, if they can get these issues ironed out.

    Composita is an intriguing language; but in the real world, its prolly undesirable to require every object to tbe a live thread and every function call to be a message, since the designers of composita had to override the OS to make it run fast enough.

    That having been said, ill close by repeating myself: if programming server applications does go the way of EBNF protocol types, then you had best learn how to write a compiler.

    0 讨论(0)
  • 2021-02-07 01:45

    I'm a web developer; I spend most of my time in PHP and MySQL. I don't think learning to build a compiler would benefit me much.

    Different types of programmers will get differing amounts of benefit.

    Bit of a non-answer, I know...

    0 讨论(0)
  • 2021-02-07 01:45

    Yes, it is a good idea. Learning how all this stuff works can only benefit the programmer. I've wrote a BASIC compiler in SX ASM and learned a ton from it.

    As someone else mentioned though, there's many degrees of programmers and knowledge. A web dev who is mainly into markup & scripting languages probably wouldn't benefit as much from it as a hardcore C or ASM programmer who writes embeded systems software - that's not to say it wouldn't be useful knowledge though.

    Re-inventing wheels is always useful for educational value.

    0 讨论(0)
  • 2021-02-07 01:49

    Understanding the process of compilation is a general approach to understanding how the computer works, and therefore provides a broad scope of understanding. Many modern programmers work in complex environments that require little of this understanding, at least on basic levels. An example is java, which hides the linking step of compilation from the developer.

    Knowledge is knowledge, it is almost always useful. In my case, I found understanding compilation process exceptionally usefull when doing performance enhancement, which is my job. (I work in a super low latency environment)

    If you do all your work in PHP mySql that is great. Just remember that all technologies get outdated, and you will need to understand the next great thing. Having "general knowledge" like understanding compilation provides a conceptional buffer between you and those shmucks who can't adapt.

    Learn how to learn.

    0 讨论(0)
  • 2021-02-07 01:50

    I am in the process of reading through The Dragon Book (Compilers) and during the beginning of the book you are greeted with the following:

    Although few people are likely to build or even maintain a compiler for a major programming language, the reader can profitably apply the ideas and techniques discussed in this book for general software design. For example, the string matching techniques for building lexical analysers have also been used in text editors, information retrieval systems, and pattern recognition programs. Context-free grammars and syntax-directed definitions have been used to build many little languages such as the typesetting and figure drawing systems that produced this book. The techniques of code optimisation have been used in program verifiers, and in programs that produce "structured" programs from unstructured code.

    In short, you won't just be learning how to build a compiler. You'll be learning many different lower-level techniques along the way to assist you in everyday programming. Although some say it is a dated book I still enjoy it and I would recommend it, even though the reading can get a bit heavy. If you do get it leave a good amount of time to read it and understand it.

    0 讨论(0)
提交回复
热议问题