HackerURLs

一次又一次被重新发现的经典。

同一个链接,相隔一年以上,一次又一次被人重新发现、再次冲上 Hacker News 首页。能经受住这种时间检验的,大多是值得一读再读的文章。每篇附中文标题,讨论最热的那些再加上中文导读和高赞评论翻译。

从名人堂开始
  • 4,700+篇经过时间检验的经典

Hall of fame

名人堂

在经典库里看全部精选

上首页次数最多、而且有中文导读的 30 篇。时间轴上每个黑点是一次上首页,空心点是一次没冲上去的投稿。

  1. 正在载入经典…

Archive

经典库

按第一次上首页的年份分布,点柱子筛选。

排序

    About

    这些经典是怎么挑出来的

    1. 01

      合并同一个链接

      读取 Hacker News 自 2006 年以来的全部链接投稿,把 http/https、www、跟踪参数等写法不同的同一篇文章合并成一条。

    2. 02

      只留经得起时间的

      同一链接至少两次拿到 50 分以上(约等于上首页),而且两次相隔一年以上;再由 AI 剔除状态页、产品首页和新闻事件。

    3. 03

      写导读、译评论

      上首页次数最多的 2,000 篇配上中文导读、"为什么经久不衰",并精选翻译 HN 高赞评论。导读由 AI 生成,可能有误。

    编程与软件工程gamasutra.com

    C++ 中的函数式编程(2012)

    Functional programming in C++ (2012)

    3次上首页
    6年跨度
    572累计得分
    250条评论

    2014 — 2020,它一次次回到首页

    黑点是上首页(≥ 50 分)的那次投稿,空心点是没冲上去的投稿,点越大分数越高。

    导读

    这是 John Carmack 2012 年发表的长文,探讨如何在 C++ 中采用函数式编程风格。他结合游戏开发经验指出,大量软件缺陷源于程序员未能完全理解代码可能处于的所有状态,而函数式风格让状态显式化、更易推理,在纯函数系统中甚至能消除线程竞态。他建议无论用什么语言,只要方便就应尽量以函数式风格编程。

    为什么经久不衰:Carmack 把函数式编程从语言之争中剥离出来,落到多线程与状态管理的实际工程问题上,这篇经验之谈至今仍是理解该话题的最佳入门之一。

    关键词 John Carmack函数式编程C++软件工程

    HN 评论精选

    概括了 Carmack 的核心论点:显式化状态、便于推理、消除竞态

    他提出的核心观点:软件开发中很大一部分缺陷源于程序员没有完全理解代码可能执行到的所有状态;在多线程环境下,这种理解缺失及其带来的问题会被急剧放大。以函数式风格编程能让代码面对的状态显式化,从而更容易推理,在完全纯函数的系统中甚至使线程竞态成为不可能。无论你用什么语言,函数式风格都有好处,方便时就该用,不方便时也应认真权衡。

    pmarreck查看英文原文

    The key points he makes: "My pragmatic summary: A large fraction of the flaws in software development are due to programmers not fully understanding all the possible states their code may execute in. In a multithreaded environment, the lack of understanding and the resulting problems are greatly amplified, almost to the point of panic if you are paying attention. Programming in a functional style makes the state presented to your code explicit, which makes it much easier to reason about, and, in a completely pure system, makes thread race conditions impossible. "No matter what language you work in, programming in a functional style provides benefits. You should do it whenever it is convenient, and you should think hard about the decision when it isn't convenient."

    函数式语言的简洁性来自语法特性而非纯函数本身;C++ 缺少函数式数据结构是痛点

    函数式语言程序有时更简洁的那些因素——垃圾回收、强大的内置类型、模式匹配、列表推导、函数组合、各种语法糖等——与纯函数的使用基本无关。这些'缩减代码量的因素'大多与函数式无关,在一些命令式语言里也能找到。我认为函数式编程新手会被这一点搞糊涂,而一些老牌拥护者则把这些因素当成了函数式定义的一部分。另外:C++ 有广泛可用的函数式数据结构吗?没有它们的话,函数式编程代价很高——Clojure 若没有采用 Bagwell 的数据结构思想,也不会那么有吸引力。

    FPGAhacker查看英文原文

    Quote > The factors that allow programs in functional languages to sometimes be more concise than imperative implementations are pretty much orthogonal to the use of pure functions — garbage collection, powerful built-in types, pattern matching, list comprehensions, function composition, various bits of syntactic sugar, etc. For the most part, these size reducers don't have much to do with being functional, and can also be found in some imperative languages. — Amen. I think people new to functional programming are thrown by this, and I think some long time adherents of functional programming have adopted these “factors” as part of the definition. Definitions change, that’s fine, but the confusion of ideas isn’t good. Anyway, are there functional data structures widely available to c++? I assume there are. Without them, functional programming has a heavy cost. Clojure, for one, would not be very attractive without having adopted Bagwell’s data structure concepts.

    纯函数只是抽象,执行仍有成本,React 滥用纯渲染函数就是反面教材

    纯函数只看传入的参数,只返回基于参数计算出的值,没有逻辑上的副作用——这当然是一种抽象;每个函数在 CPU 层面都有副作用,大多数在堆层面也有,但这个抽象仍然有价值。重读多次后,这次让我印象最深的就是这段,尤其是后半句。现实中不存在真正的'纯'函数,因为执行总要付出代价。某些函数式程序员把这个概念曲解成纯函数是免费的、可以无限次执行。这种极端想法的一个后果就是如今的 React.js:大多数 React 应用病态地过度执行我们用来定义组件的'纯'渲染函数,导致性能下降、GC 压力增大。能多次调用纯函数不代表你应该这么做。

    bikeshaving查看英文原文

    > A pure function only looks at the parameters passed in to it, and all it does is return one or more computed values based on the parameters. It has no logical side effects. This is an abstraction of course; every function has side effects at the CPU level, and most at the heap level, but the abstraction is still valuable. Rereading this for the umpteenth time, this is the paragraph which sticks out to me this time around, and a point which I think most people miss, specifically the latter part about “pure” functions consuming CPU and memory. The reality is that there is no such thing as a “pure” function, insofar as execution of that function costs something. Certain functional programmers corrupted this idea to somehow mean pure functions are free; that these functions can be executed one to infinity times and the result is the same. For instance, this idea taken to an extreme has resulted in the current situation with React.js, where most React applications pathologically over-execute the “pure” rendering functions which we use to define components, resulting in degraded performance, increased GC pressure, and a lack of understanding of how our code executes. Just because you can call a pure function many times doesn’t mean you should.

    这句话在 OOP 和微服务时代更加切中要害

    '软件开发中很大一部分缺陷源于程序员没有完全理解代码可能执行到的所有状态'——我在日常编程中经常想起这句话。面向对象编程充满了有状态的对象,程序员很容易给各种事件挂监听器;如今云端还有这么多微服务和触发函数,小小的改动就可能引发级联后果。

    seanalltogether查看英文原文

    > A large fraction of the flaws in software development are due to programmers not fully understanding all the possible states their code may execute in. I think about this quote often in my day to day programming. Object oriented programming is so full of stateful objects and it's easy for programmers to add listeners to all sorts of events. Even on the cloud side now you have all these micro services and trigger functions and small changes can have cascading consequences.

    历次讨论

    同类还值得读

    1. 开源应用架构

      The Architecture of Open Source Applications

      《开源软件架构》(AOSA)是一本在线免费书,邀请知名开源项目的作者亲自剖析其内部设计,涵盖 SQLAlchemy、LLVM、Audacity、Apache、Bash 等系统。

      编程与软件工程上首页 9 次 · 2011–2024aosabook.org编辑精选
    2. 编程语言简史:简短、不完整且多半错误

      A Brief, Incomplete, and Mostly Wrong History of Programming Languages

      一篇以戏谑、故意不准确的方式回顾编程语言史的博客文章,用夸张轶事和讽刺定义串起 Lisp、C、C++、Java、JavaScript、PHP 等语言。

      编程与软件工程上首页 8 次 · 2009–2021james-iry.blogspot.com
    3. SQLite 是如何测试的

      How SQLite is tested

      SQLite 官方文档页,系统介绍 SQLite 的测试体系:多种测试方法(TCL 测试、模糊测试、回归测试、静态分析等)和海量测试用例,展示了这个小型开源项目如何靠极致测试获得…

      编程与软件工程上首页 8 次 · 2009–2025sqlite.org编辑精选
    4. 高级编程语言(2009)

      Advanced programming languages (2009)

      Matt Might 的经典文章,按用途推荐“高级编程语言”:如果追求就业就选主流语言,如果追求表达力、学术研究或创业,则推荐 Haskell、OCaml、Scala 等函数式语…

      编程与软件工程上首页 8 次 · 2009–2022matt.might.net
    5. 我的 Forth 与栈机器经历

      Yosefk - My history with Forth & stack machines

      作者以亲身经历回顾了使用 Forth 语言和栈式机器的历程:既赞叹其简洁优雅、代码量小、可自举的优点,也坦率指出栈操作在实际编程中的痛苦,以及 Forth 社区文化中的问题。

      编程与软件工程上首页 8 次 · 2010–2024yosefk.com编辑精选

    打赏支持

    打赏二维码

    觉得有用,请作者喝杯咖啡。

    WeChat

    关注向阳乔木

    微信公众号「向阳乔木推荐看」

    微信公众号「向阳乔木推荐看」二维码

    微信扫一扫;在微信里打开本页时,长按二维码识别。