(何时)我应该学习编译器吗?

发布于 2024-07-16 22:32:18 字数 1558 浏览 10 评论 0原文

根据此 http://steve-yegge.blogspot.com/ 2007/06/rich-programmer-food.html 文章,我绝对应该。

引用温柔但坚持不懈的高管 摘要:如果你不知道如何 编译器工作,然后你不知道 计算机如何工作。 如果你不是100% 确定你是否知道编译器如何 工作,然后你不知道他们是如何 工作。

我认为这是一篇非常有趣的文章,应用领域非常有用(帮自己一个忙,阅读一下) 但话又说回来,我见过一些成功的高级软件工程师,他们不太了解编译器,也不了解内部机器架构, 但确实了解以下列表中的每一项的一两件事:

  • 一种编程范式(OO、函数式……)
  • 一种编程语言 API(C#、Java ..),并且有人说至少有 2 个非常不同! (Java / Haskell)
  • 编程框架 (Java、.NET)
  • 提高工作效率的 IDE (Eclipse、VisualStudio、Emacs...)
  • 编程最佳实践(例如,请参阅 fxcop 规则)
  • 编程原则(DRY、高内聚、低内聚)耦合,……)
  • 编程方法(TDDMDE)
  • 设计模式(结构、行为……)
  • 架构基础(层、层、流程模型(瀑布式、敏捷……)
  • 测试工具(单元测试、模型测试……)
  • GUI 技术(WPF、Swing)
  • 文档工具(Javadoc、Sandcastle..)
  • 建模语言(也许还有工具)(UML、VisualParadigm、Rational)
  • (毫无疑问,这里忘记了非常重要的东西) )

并不是所有这些工具都是成为一名优秀程序员所必需的(就像 GUI,当你不需要它时) 但大多数都是。 编译器从何而来,它们真的那么重要吗?因为,正如我提到的, 许多程序员似乎在不了解他们的情况下做得很好,特别是,成为一名优秀的程序员几乎是一生的成就:-),因此,即使编译器极其重要,不是总有更重要的东西吗? ?

或者我应该今天订购“The Unleashed Compilers Unlimited Bible (in 24H..)))”?

对于那些已阅读本文并想立即开始学习的人:

学习资源关于解析器、解释器和编译器

According to this http://steve-yegge.blogspot.com/2007/06/rich-programmer-food.html article, I defnitely should.

Quote Gentle, yet insistent executive
summary: If you don't know how
compilers work, then you don't know
how computers work. If you're not 100%
sure whether you know how compilers
work, then you don't know how they
work.

I thought that it was a very interesting article, and the field of application is very useful (do yourself a favour and read it)
But then again, I have seen successful senior sw engineers that didn’t know compilers very well, or internal machine architecture for that matter,
but did know a thing or two of each item in the following list :

  • A programming paradigm (OO, functional,…)
  • A programming language API (C#, Java..) and at least 2 very different some say! (Java / Haskell)
  • A programming framework (Java, .NET)
  • An IDE to make you more productive (Eclipse, VisualStudio, Emacs,….)
  • Programming best practices (see fxcop rules for example)
  • Programming Principles (DRY, High Cohesion, Low Coupling, ….)
  • Programming methodologies (TDD, MDE)
  • Design patterns (Structural, Behavioural,….)
  • Architectural Basics (Tiers, Layers, Process Models (Waterfall, Agile,…)
  • A Testing Tool (Unit Testing, Model Testing, …)
  • A GUI technique (WPF, Swing)
  • A documenting tool (Javadoc, Sandcastle..)
  • A modelling languague (and tool maybe) (UML, VisualParadigm, Rational)
  • (undoubtedly forgetting very important stuff here)

Not all of these tools are necessary to be a good programmer (like a GUI when you just don’t need it)
but most of them are. Where do compilers come in, and are they really that important, since, as I mentioned,
lots of programmers seems to be doing fine without knowing them and especially, becoming a good programmer is seen the multitude of knowledge domains almost a lifetime achievement :-) , so even if compilers are extremely important, isn't there always stuff still more important?

Or should i order 'The Unleashed Compilers Unlimited Bible (in 24H..))) today?

For those who have read the article, and want to start studying right away :

Learning Resources on Parsers, Interpreters, and Compilers

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(9

百善笑为先 2024-07-23 22:32:18

如果您只想成为一名普通的编码员并编写一些东西...您不需要使用编译器。

如果您想学习计算机科学并欣赏并真正成为一名计算机科学家,您必须学习编译器。

编译器是计算机科学的一个缩影! 它包含每个问题,包括(但不限于)人工智能(贪婪算法和启发式搜索)、算法、理论(形式语言、自动机)、系统、架构等。

你会看到很多计算机科学结合在一起以一种令人惊奇的方式。 您不仅会更多地了解编程语言为何以它们的方式工作,而且您将成为一名更好的程序员,因为有了这种理解。 你将学会理解低层次,这对高层次有帮助。

作为程序员,我们经常喜欢谈论事物是一个“黑匣子”……但是当你稍微了解一下盒子里的内容时,事情就会变得更加顺利。 即使您不构建整个编译器,您也一定会学到很多东西。 您将看到解析背后的形式主义(并意识到这不仅仅是一堆特殊情况拼凑在一起),以及一堆 NP 完全问题。 您将明白为什么理解计算机科学理论对于实际事物如此重要。 (毕竟,编译器非常实用......如果没有形式主义,我们就不会有今天的编译器)。

我真的希望您考虑学习它们......它将帮助您作为计算机科学家达到新的水平:-)。

If you just want to be a run-of-the-mill coder, and write stuff... you don't need to take compilers.

If you want to learn computer science and appreciate and really become a computer scientist, you MUST take compilers.

Compilers is a microcosm of computer science! It contains every single problem, including (but not limited to) AI (greedy algorithms & heuristic search), algorithms, theory (formal languages, automata), systems, architecture, etc.

You get to see a lot of computer science come together in an amazing way. Not only will you understand more about why programming languages work the way that they do, but you will become a better coder for having that understanding. You will learn to understand the low level, which helps at the high level.

As programmers, we very often like to talk about things being a "black box"... but things are a lot smoother when you understand a little bit about what's in the box. Even if you don't build a whole compiler, you will surely learn a lot. You will get to see the formalisms behind parsing (and realize it's not just a bunch of special cases hacked together), and a bunch of NP complete problems. You will see why the theory of computer science is so important to understand for practical things. (After all, compilers are extremely practical... and we wouldn't have the compilers we have today without formalisms).

I really hope you consider learning about them... it will help you get to the next level as a computer scientist :-).

本王不退位尔等都是臣 2024-07-23 22:32:18

您应该了解编译器,原因很简单,实现编译器可以让您成为更好的程序员。 编译器肯定会很糟糕,但在此过程中你会学到很多东西。 这是提高(或练习)编程技能的好方法。

You should learn about compilers, for the simple reason that implementing a compiler makes you a better programmer. The compiler will surely suck, but you will have learned a lot during the way. It is a great way of improving (or practising) your programming skill.

雨巷深深 2024-07-23 22:32:18

你不需要了解编译器才能成为一名优秀的程序员,但它会有所帮助。 在了解它们时我意识到的一件事是,编译只是一种翻译。

如果您曾经从一种语言翻译成另一种语言,那么您刚刚完成了编译。


那么什么时候应该学习编译器呢?

当您想要或需要它来解决问题时。

You do not need to understand compilers to be a good programmer, but it can help. One of the things I realized when learning about them, is that compiling is simply a translation.

If you have ever translated from one language to another, you have just done compiling.


So when should you learn about compilers?

When you want to, or need it to solve a problem.

若无相欠,怎会相见 2024-07-23 22:32:18

编译器理论很有用,但不是必需的。

尽管有一些技术可以派上用场,例如词法分析和语法分析。

另一种是错误处理。 编译器需要很多这样的东西。 用户输入可以包含任何内容,甚至是意外的内容。 你需要处理所有这些。

Compiler theory is useful, but not essential.

Although there are some techniques which come in handy, like lexical analysis and parsing.

Another one is error handling. Compilers need a lot of these. User input can contain anything, even the unexpected. And you need to deal with all of these.

孤者何惧 2024-07-23 22:32:18

如果您打算在足够高的级别上工作,并且担心 UML 和自描述代码,那么您可以轻松地完成您的整个职业生涯,而无需想要或需要编译器如何工作的详细信息。

但是,如果您是一名一线编码员并且无意管理您的朋友,那么很可能有一天,您会意识到您正在与编译器发动战争。 这可能是一个随机出现的错误,也可能是走廊里关于 while-verses-for 循环的谈话。 你会意识到组装(或者IL,可能在未来几年)就在你所需要的左边一点,另一个宇宙将会展开。

所以,我想我的答案是,现在只需注意编译器,它做了很多事情,但不要太担心。

If you're going to be working at a high-enough level where you're worrying over UML and self-describing code, you could easily go your entire career without wanting or needing intimate details of how the compiler works.

But, if you're an in-the-trenches coder and have no aspirations to manage your friends, it's likely that one day, you'll realize you're waging war with your compiler. It could be a random bug that comes along or a hallway conversation about while-verses-for loops. You'll realize the assembly (or IL, likely, in the coming years) is just a bit to the left of what you were needing and another universe will unfold.

So, I suppose my answer is, just be aware of the compiler for now, that it's doing quite a lot, but don't worry over it too much.

雨落星ぅ辰 2024-07-23 22:32:18

编译器课程通常侧重于如何分析高级代码并将其转换为机器代码。 这非常有趣,但并不重要。 更重要的是了解编译器生成的机器代码是什么,以便您了解计算机如何工作以及每种语言构造的成本是多少。

所以我宁愿说你应该了解一种汇编语言(我的意思是一种体系结构的汇编语言的有限子集)来理解计算机是如何工作的,而后者对于一个有能力的程序员来说绝对是必需的,这样他才能理解什么是段错误、何时优化、何时不优化以及其他类似的低级事物。

The compilers courses usually focus on how the high-level code is analyzed and translated into machine code. That's very interesting, but not crucial. It's more important to understand what is this machine code that is generated by the compiler so that you understand how a computer works and what is the cost of each language construct.

So I'd rather say that you should know an assembly language (I mean a limited subset of assembly language for one architecture) to understand how a computer works and the latter is definitely required for a competent programmer so that he understands what segmenation fault is, when to optimize and when not and other similar low-level things.

孤独陪着我 2024-07-23 22:32:18

如果您打算编写对时间要求极高的实时代码,那么了解编译器如何优化代码将使您受益匪浅。 然而,了解硬件的底层架构实际上会让您受益更多。

根据我的经验,如果您了解硬件的工作原理以及编译器如何解释您的代码,您将能够编写完全符合您预期的代码。 我曾多次被抓到,编写的代码被编译器优化了,并使硬件做了一些我不打算做的事情。

总而言之,了解整个软件硬件堆栈并不是编写优秀算法和代码的必要条件,但它肯定会有所帮助!

If you intend to write extremely time-critical real-time code, you will benefit from understanding how the compiler optimises your code. However, you will actually benefit more from understanding the underlying architecture of your hardware.

From my experience, if you understand how the hardware works, and how the compiler interprets your code, you will be able to write code that does exactly what you intend it to do. I have been caught on several occasions, writing code that got optimised away by the compiler and made the hardware do something that I did not intend.

All in all, understanding the entire software-hardware stack is not essential to write good algorithms and code, but it will most certainly help!

过期以后 2024-07-23 22:32:18

从实践的角度来看,通用编译器理论比特定平台的汇编器、链接器和加载器更受关注。 例如,我只是将 GCC 编译器视为 x86 平台上从高级 C 语言到低级汇编语言的翻译器。 通常,我会手动优化;)编译器生成的代码。

从科学的角度来看,我强烈建议您学习编译器理论,它将帮助您理解构建计算机的伟大思想。 更重要的是,你会对世界有不同的看法。

From a practical perspective, general compiler theory is less of concern than a assembler, linker and loader to a specific platform. For example, I just consider the GCC compiler as a translator from my high-level C language to the low-level assembly language on a x86 platform. And more often than not, I manually refine ;) the code generated by the compiler.

From a scientific perspective, I would strongly suggest you learning the compiler theory, it will help you understand the great idea that computer is built upon. And even more, you will have a different eye upon the world.

怎樣才叫好 2024-07-23 22:32:18

只是我的意见,但我相信编译器在 CS 课程中没有得到足够的重视,在我的课程中没有,在任何其他课程中也没有。 我认为任何计算机科学专业的学生在休假或完成专业后都应该做两件事:如有必要,重新学习有限自动机,也许还可以学习形式方法语言。 应用它。
利用这些知识编写一个简单的编译器。 Alex Aiken 有一个非常有用的在线教程,介绍如何为 COOL(课堂面向对象语言)编写编译器,该语言是 2013 年版本的 Scala 的子集。 至少在撰写本文时是这样。

Just my opinion, but I believe compilers is not given enough attention in CS courses, not in mine, and not in any others afaik. I think any CS major should do 2 things after a sabbatical or finishing their major: Re-learn if necessary finite automata and maybe a formal methods language. Apply it.
Write a simple compiler with this knowledge. Alex Aiken has a very useful online tutorial on writing a compiler for the COOL (Classroom Object Oriented Language) which is a subset of Scala as of 2013 ver. At least at time of writing.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文