Is it beneficial for a programmer to learn how to

2020-05-31 00:23发布

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 compiler programming be, or not be, needed?

17条回答
别忘想泡老子
2楼-- · 2020-05-31 00:47

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.

查看更多
Ridiculous、
3楼-- · 2020-05-31 00:50

I've up-voted most of these answers.

I think compiler work gives you important ways of thinking about programming in general.

Whenever you write any program you are, in a sense, defining a language, and every program is, at some level, a language processor.

It makes you think about the best way to represent information, and understand that information can be encoded many different ways, not just as data structure and lots of classes.

Once you know that every problem has multiple valid solutions, with pros and cons, you can usually choose a much better solution than with the old data-centered one-size-fits-all paradigm.

查看更多
倾城 Initia
4楼-- · 2020-05-31 00:52

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.

查看更多
Juvenile、少年°
5楼-- · 2020-05-31 00:55

Compiler programming is multi-faceted since it includes parsing of code into logical trees and then translating code into another form of code. And potentially analyzing the input once its in trees for optimizations.

So in a round about way it will help every programmer, because you know how statements can be interpreted faster, or how to write a precompiler to make macros for your language of choice. Or even just how to parse that flat file better than your colleague.

For most script based languages, which don't have a compiler, you won't be able to optimize your day to day work flow much with learning how to make a compiler. But you will still understand parsing.

查看更多
Luminary・发光体
6楼-- · 2020-05-31 00:55

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...

查看更多
登录 后发表回答