编程与软件工程slideshare.net
深入 C 语言
Deep C
2011 — 2013,它一次次回到首页
黑点是上首页(≥ 50 分)的那次投稿,空心点是没冲上去的投稿,点越大分数越高。
导读
《Deep C》是 Olve Maudal 的著名幻灯片,通过一场虚构的 C/C++ 面试对话,展示同一段代码在浅层理解与深入理解语言标准、编译器行为的人眼中截然不同的解读,涵盖未定义行为、序列点、静态变量等大量细节。它既是趣味测验,也引发了对“深度语言知识是否等于好程序员”的争论。
为什么经久不衰:它用具体代码例子揭示了 C/C++ 中大量反直觉的规范细节,多年后仍是检验和拓展语言理解的经典材料。
HN 评论精选
这些例子有趣但作为面试题很糟糕,考察标准细节不如考察写出好代码的能力
了解标准确实能让你成为更好的程序员,但写隐晦难懂的代码仍是坏习惯。我认为男孩最初那句“我绝不会写这样的代码”说得很对。这些是相当糟糕的面试题:它们考的是标准和冷门行为的知识,但更重要的是看一个人能写出什么样的代码(可读、明确、可维护、简单、有架构、有注释、高性能、无 bug 等)。现实中男孩可能是更好的程序员。例子很有趣,但除非面试编译器岗位,我不会在面试中问这些。
Maro查看英文原文
While knowing the standards makes you a better programmer, it's still bad programming practice to write non-excplicit, cryptic code. I think the boy's initial "I would never write code like this" response is spot on. I also agree with the boy's implied annoyance and "who cares what this badly written program actually does" stance. These are fairly terrible interview questions. They test knowledge of standards and various obscure behaviour, but it's far more important what kind of code (readable, explicit, maintainable, simple, architected, commented, performant, bug-free, etc.) the person writes. In real life, the boy may actually be a better programmer than the girl. It's just not a good, comprehensive test. Nevertheless the examples are fun, but I would never ask them in an interview. Interview time is precious and not to be wasted on stuff like this, unless you're interviewing for a compiler job... EDIT: Most of the above applies to the first, C part of the interview. In the second, C++ part, the stuff the girl says is mostly basic knowledge that is useful on a daily basis.
幻灯片设定是伪二分法;真正重要的能力是像计算机一样思考和排查问题,而非背诵规范
这在我看来是个伪二分法。“浅层”角色对计算机科学基础一无所知,而“深层”角色对每份 C 规范和编译器实现都了如指掌——有多少面试者真的属于这两类?我对 C 并不精通,但因为知道 C 大致直接编译成机器指令、了解计算机的工作原理,我大部分题都答对了。C 并不难,难的是像计算机一样思考。比预测代码行为更重要的能力,是出错时搞清楚到底发生了什么。“我不知道答案但给我一秒我能弄明白”比直接背出答案更令人印象深刻。
Cushman查看英文原文
This seems like a false dichotomy to me. The "shallow" character seems completely uninformed about the basics of computer science, maybe having worked through a C tutorial or two, while the "deep" character seems to have an encyclopedic knowledge of every C spec and compiler implementation that's ever been written. How many interview candidates really fall into one of those camps? I don't really know C that well -- certainly nothing spec- or compiler-specific -- but I got "deep" answers for most of the questions just because I know that generally C compiles straight to machine instructions, and I know how computers work. (I got 5/5 on the little quiz, and the tutorial on sequence points was completely new to me.) C isn't hard. Thinking like a computer, in any language, is hard. The ability to predict what code will do, while important, is less crucial than the ability to figure out what's really going on when you get one wrong. I feel like calling that ability "deep knowledge" is putting the cart before the horse. To put it another way, "I don't know the answer to that question, but here's a guess" and "I know the answer to that question, here it is" are both less impressive answers than "I don't know the answer, but give me a second and I'll figure it out for you." Or maybe I'm missing the point.
这份演讲引导读者深入语言规范,精通一两门语言到规范层面是值得的追求
我很喜欢这个演讲,它引导我去读 Peter Van Der Linden 的《Expert C Programming》,读完之后我对 C 的理解大幅提升。即使你不是 C 程序员,我也推荐这本书,光那些轶事就值得一读。我逐渐相信,阅读规范并具备钻研这类细节、提出正确问题的专注力,对精通一门技艺很重要。深入学习一到两门语言到这个程度是值得的,其余都只是皮毛。
agentultra查看英文原文
I love this presentation. It led me to read Expert C Programming [1] by Peter Van Der Linden. My knowledge of C had vastly improved after reading that book (and subsequently C++). Even if you're not a C programmer I would recommend the book as the anecdotes alone are worth reading for the questions that it encourages you to ask. I've since come to believe that reading the specifications and having the attention necessary to delve into these kinds of details and ask the right questions is important for mastery. It seems to me that learning 1 - 2 languages to this level of detail is worthwhile. I've been thinking of cutting back the number of languages I, "know," down to just those for which I am familiar with the specifications and how they're compiled, assembled, etc. Everything else is superficial. Sometimes all you need is just a cursory knowledge to get something done and the ends justify those means. However if you really love your craft then mastery should be the goal, no? It seems to be the difference between, "getting something working," and, "pushing the boundaries of what is possible." [1] http://www.amazon.ca/Expert-Programming-Peter-van-Linden/dp/0131774298
C/C++ 的难点在于海量刁钻概念的堆积,且编译器对未定义行为不报警,学习全靠踩坑
这与其说是理解力问题,不如说是记忆力问题。让人在 C 和 C++ 中溺水的是语言逻辑之外的大量刁钻概念和纯粹的信息堆积(规范篇幅就是体现)。而且各种未指定行为、实现相关行为往往不会触发警告,编译器完全不帮你强化学习;你可能已在未定义行为的荒原上走了多年,直到有人用 PPT 嘲讽你是白痴。
nraynaud查看英文原文
this has nothing to do with understanding but more with memory. What's drowning people in C and even more in C++ is not the logic of the language, but the sheer number of tricky concepts and the pure accumulation of information (it is reflected on the size of the specs). There is also the fact that very often non-specified behavior, or implementation dependent or everything else that is not cool does not lead to a warning, so the learning is absolutely not reinforced by the compiler. Whereas a warning/error leads to questions that leads to google and some learning; you can be stepping far in the Pampa of undefined behavior for years when someone comes with a superior attitude in your company detects it and calls you a moron in a powerpoint. And this also leads to very hard to write code sometimes, if you want to do some serious IEEE754 in C/C++ you will basically be pitting the spec of the language against the spec of numerical computation in a ring.
历次讨论
同类还值得读
开源应用架构
The Architecture of Open Source Applications
《开源软件架构》(AOSA)是一本在线免费书,邀请知名开源项目的作者亲自剖析其内部设计,涵盖 SQLAlchemy、LLVM、Audacity、Apache、Bash 等系统。
编程与软件工程上首页 9 次 · 2011–2024aosabook.org编辑精选编程语言简史:简短、不完整且多半错误
A Brief, Incomplete, and Mostly Wrong History of Programming Languages
一篇以戏谑、故意不准确的方式回顾编程语言史的博客文章,用夸张轶事和讽刺定义串起 Lisp、C、C++、Java、JavaScript、PHP 等语言。
编程与软件工程上首页 8 次 · 2009–2021james-iry.blogspot.comSQLite 是如何测试的
How SQLite is tested
SQLite 官方文档页,系统介绍 SQLite 的测试体系:多种测试方法(TCL 测试、模糊测试、回归测试、静态分析等)和海量测试用例,展示了这个小型开源项目如何靠极致测试获得…
编程与软件工程上首页 8 次 · 2009–2025sqlite.org编辑精选高级编程语言(2009)
Advanced programming languages (2009)
Matt Might 的经典文章,按用途推荐“高级编程语言”:如果追求就业就选主流语言,如果追求表达力、学术研究或创业,则推荐 Haskell、OCaml、Scala 等函数式语…
编程与软件工程上首页 8 次 · 2009–2022matt.might.net我的 Forth 与栈机器经历
Yosefk - My history with Forth & stack machines
作者以亲身经历回顾了使用 Forth 语言和栈式机器的历程:既赞叹其简洁优雅、代码量小、可自举的优点,也坦率指出栈操作在实际编程中的痛苦,以及 Forth 社区文化中的问题。
编程与软件工程上首页 8 次 · 2010–2024yosefk.com编辑精选