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 生成,可能有误。

    编程与软件工程maryrosecook.com

    函数式编程实用入门

    A practical introduction to functional programming (2013)

    2次上首页
    1年跨度
    559累计得分
    213条评论

    2015 — 2016,它一次次回到首页

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

    导读

    这是一篇面向实践的函数式编程入门,用具体示例讲解函数式代码的核心特征:避免副作用、不修改外部状态,并借助 map、reduce、高阶函数等工具显式处理循环与状态。文章强调判断一段代码是否“函数式”,关键不在语法,而在于能否仅凭输入和输出推理函数行为。

    为什么经久不衰:它把抽象概念落到可运行的小例子上,帮助读者理解函数式编程“为什么”有效,而不只是记住 map/reduce 的写法,因此多年后仍是很好的入门材料。

    关键词 函数式编程副作用不可变性入门

    HN 评论精选

    Rust 的借用检查在非函数式语言里提供了类似函数式的可推理性和大部分好处。

    稍微跑题到 Rust:我一直在思考文章提到的函数式编程有趣之处,尤其是不可变性如何让人只通过输入和输出就能轻松推理函数。我觉得 Rust 的内存模型(单个可变引用或无限制不可变引用)加上安全代码中没有可变全局变量,使系统更容易推理:根据输入输出我知道什么可能被修改,而且只有一个可变引用,容易追踪。感觉它获得了函数式编程的绝大部分好处,又不牺牲我们习惯的性能和可预测性。

    vvanders查看英文原文

    This is a slight Rust tangent but I've been thinking a lot about the properties that make functional programming interesting and are called out in the article. Specifically the immutability providing an easy way to reason about functions via only inputs and outputs. I feel the the memory model of Rust(single mutable ref or unlimited non-mutable refs) combined with the fact that there are no mutable globals(inside safe code) gives you a much easier system to reason about. I know based on inputs and outputs what could be mutated and since I know there's only one mutable reference I can trace that single ref easily. It really feels like getting a large majority of the benefits of functional programming without sacrificing the performance and predictability we've all become accustomed to in non-functional languages.

    命令式语言能表达函数式写法,但有状态迭代用循环更自然。

    函数式语言的问题在于:大多数命令式语言可以“做函数式的事”,反过来不行。很多算法用递归表达很美(如斐波那契),几乎所有语言都允许递归;但很多算法用 for 循环更优雅。比如需要遍历行并维护状态时,一个跳过以 'a' 开头行后一行的循环,看起来比等价的函数式写法更清晰。

    dispose13432查看英文原文

    The thing with functional languages is that most imperative languages can "do functional things", but not vice versa. For example, many algorithms are beautiful when expressed in a recursive manner (Fibonacci, for example) , and pretty much all languages permit one to do recursion (even old fashioned C). But many algorithms are much more elegant when expressed through for loops. For example, if one needs to iterate through lines keeping state into account, a for (int i =0;i<len;i++){ if(lines[i] == "a"){ i+=2; } } seems much cleaner than an equivalently functional algorithm. ----- EDIT. I (purposefully) left out the "main" logic (as it's not really relevant to the post). Of course in a "real" example, the code would look like: for (int i =0;i<len;i++){ if(lines[i] == "a"){ i+=2; } else{ parseLine(lines[i]); } } The goal is to skip the line after a line starting with the letter "a".

    纯函数不能依赖随机数等隐藏状态,否则输入输出不再可预测。

    如果同一个函数对相同输入给出不同输出,那你就处在“非函数式世界”。所以别把 random() 放进你所谓的纯函数中间。文章“Remove state”部分的赛车代码仍然在函数体里调用了 random()。

    etaty查看英文原文

    If your function for the same input give you a different output, then you are in dysfunctional world. Hence don't put random() in the middle of your supposed pure function. Remove state This is a functional version of the car race code: from random import random def move_cars(car_positions): return map(lambda x: x + 1 if random() > 0.3 else x, car_positions)

    无副作用/无变量是核心,高阶函数等只是配套便利。

    > 忽略那些。函数式代码的特征只有一点:没有副作用。它不依赖函数外部的数据,也不修改函数外部的数据。其他所有“函数式”的东西都可以从这一点推导出来。 这条太对了。我甚至想说,函数式编程就像命令式编程但没有变量(作为参数传入的除外)。其余的一等/高阶函数、map/reduce、管道、递归、柯里化等,只是让函数式语言更方便地处理“没有变量”。函数式编程的关键成就是提供专门工具,帮助程序员为任务选对工具。

    rsp1984查看英文原文

    > Ignore all that. Functional code is characterised by one thing: the absence of side effects. It doesn’t rely on data outside the current function, and it doesn’t change data that exists outside the current function. Every other “functional” thing can be derived from this property. This. So much this. I'd go even further and say functional programming is just like imperative programming but without variables (except for those passed in as arguments). This has always struck me as the key difference between the two. The rest (first class / higher order functions, mapping, reducing, pipelining, recursing, currying etc) in my opinion is just making things more convenient in functional languages, dealing with this absence of variables. The key achievement of functional programming in my opinion is then the provision of special tools (see above) that help programmers solve particular problems in particular efficient ways, that programmers would have solved by using variables in a possibly less efficient way in an imperative language. In short functional programming forces the user to pick the right tool for the task.

    历次讨论

    同类还值得读

    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

    关注向阳乔木

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

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

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