按年被提到
20142014 · 8 次2026
开源书›软件工程·No.70·简称 500L

500 Lines or Less

五百行代码以内
Michael DiBernardo (ed.)

用不到 500 行代码实现真实软件,逐章拆解设计取舍

免费阅读 ↗
被推荐 · 27 人首次 2014-04-17 · 最近 2022-05-31许可证 CC BY 3.0
27不同的人
20活跃月份
11有推荐的月份
26讨论串

这是一本由多位作者分章撰写的文集,每章用不超过 500 行代码实现一个真实可运行的程序,并讲解其中的设计思路和取舍。内容涉及多种类型的软件,不少章节用 Python 实现,包括 Guido van Rossum 写的基于 asyncio 的网络爬虫。和只讲架构概念的书不同,这本书让读者直接读完整的小型代码库,适合当作读源码的练习。

HN 为什么推荐它

HN 上的人把它当作读真实代码的入门材料推荐:项目小、不吓人,每章还配有分析,既能学 Python 也能看到不同类型软件的核心实现;也常拿 Guido 的 asyncio 爬虫章节举例。

难度 3 / 5约 30 小时开放许可
适合谁

想通过读小型真实代码学设计的中级开发者

读之前最好知道
1Python 基础
2基本数据结构与算法

怎么读

由 Claude 根据这本书和 HN 上的说法整理,可能有错
  1. 1先看目录,挑自己熟悉或感兴趣的一章读,不必按顺序
  2. 2读完设计讲解后,把代码下载下来运行并改一改
  3. 3Guido 的爬虫一章适合想学 asyncio 的人先读
  4. 4可与 The Architecture of Open Source Applications 配合着读

HN 书评

推荐在前,同类按时间 · 每本最多保留 20 条,统计用全部提及 · 作者本人贴的不算
强烈推荐elorm · 2017-06

“I just can't recommend it enough.”

极力推荐,书中剖析开源程序及其设计取舍
Ask HN: What code samples should programmers read?原评论 ↗
推荐dmunoz · 2014-04

“a fourth is being worked on which is very relevant to this posts query. There isn't much too it yet, but its working title is 500 Lines or Less”

提到正在编写的 500 Lines or Less,适合研读源码
Ask HN: What source code is worth studying? 原评论 ↗
推荐nikhilalmeida · 2014-07

“This is a repo of smaller real world applications that are 500 lines or less in length, so as not to be overwhelming to novice / intermediate programmers.”

介绍它是 500 行以内的小型真实应用,适合初中级程序员
Ask HN: How best to learn software design principles?原评论 ↗
推荐nikhilalmeida · 2014-08

“This is a collection of real applications that are written in 500 lines or less. The goal is to teach python through real projects that are not too complicated to understand.”

介绍它用 500 行内的真实项目教 Python
Python Practice Book原评论 ↗
推荐abecedarius · 2014-11

“500 Lines or Less and I'm looking forward to reading it too.:)”

期待这本书
C4 – C in 4 functions原评论 ↗
推荐nikhilalmeida · 2014-12

“The goal was to be a resource for intermediate python developers to be able to look at real world applications. Hope this helps.”

说明它让中级 Python 开发者读真实应用
Free Python Books原评论 ↗
看全部 20 条 →
推荐Jugurtha · 2015-07

“There's also "500 Lines or Less" which is a part of the effort:”

提到它是该计划的一部分
Ask HN: As a junior developer, how do I learn to better architect software?原评论 ↗
推荐mkolodny · 2015-07

“It's especially interesting because it takes advantage of new Python features like asyncio.”

称它用了 asyncio 等新特性,是值得读的 Python 代码
Ask HN: Good Python codebases to read?原评论 ↗
推荐jasim · 2016-06

“The best I have so far come across in a book is "Coders At Work". 500 Lines or Less promises to be another.”

称 Coders At Work 是最好的一本,这本有望成为另一本
Mastering Programming: An Outline原评论 ↗
推荐bordercases · 2016-06

“Maybe starting with a project like this would help? 500 Lines or Less”

建议从这类项目入手,跨领域读代码
Ask HN: What is your best advice for a developer to write better code?原评论 ↗
推荐sitkack · 2018-01

“Often they are pedagogical in purpose, but sometimes on accident due to ruthless factoring.”

指出这类代码库小而易读,因极致拆分而适合学习
Great things and people that I discovered, learned, read, met, etc in 2017原评论 ↗
推荐faizshah · 2020-05

“Same, I really like the book 500 Lines or Less for this as well:”

同样喜欢,认为它用极少代码展示事物如何运作
Linux containers in a few lines of code原评论 ↗
推荐ranuzz · 2021-06

“If you are looking for inspiration try '500 Lines or Less' [0]. It includes in-depth analysis of projects at hand and implementation.”

学新语言找灵感时推荐,含项目分析与实现
Ask HN: Projects for learning a language?原评论 ↗
推荐jamessb · 2022-05

“500 Lines or less [1,2] might be of interest: it doesn't build up a single complex project from scratch, but it several show the core implementation of various complex types of software.”

推荐它展示各类复杂软件的核心实现,而非从零搭一个大项目
Ask HN: Books like “Crafting interpreters” or “The ray tracer challenge”?原评论 ↗
引用bashwork · 2014-07

“Created an account to point out this gem by Guido himself that makes use of this and the fact that python variables are not scoped inside for loops:”

指出 Guido 写的一个例子用到了 Python 的 for-else
The optional “else” in Python loops原评论 ↗
引用fritzo · 2014-12

“A list of classics like the Architecture of Open Source Applications project (链接) to accompany the short stories in 500 Lines or Less”

把它列为配套经典代码集的短篇故事
Great Works in Programming Languages原评论 ↗
引用drincruz · 2015-04

“There are also projects like 500lines where it's a book and you can help out with all types of editorial-type tasks.”

指出它是开放的书项目,可参与编辑工作
Ask HN: How do technical non-developers help with open source projects?原评论 ↗
引用pixelmonkey · 2016-03

“Guido van Rossum, the creator of Python, wrote a web crawler as a motivating example for asyncio. You can find the code for it here:”

指出 Guido 为 asyncio 写了网络爬虫示例
Show HN: Python 3.5 Async Web Crawler Example原评论 ↗
引用eriknstr · 2016-05

“I was able to build the PDF on Fedora 23 [1]. Ended up with no front page but the content is there.”

分享在 Fedora 23 上从源码构建 PDF 的经验,缺封面但内容齐全
500 Lines or Less原评论 ↗
引用simon_acca · 2016-06

“For an example, look at Guido van Rossum's crawler [0].”

拿 Guido 的 asyncio 爬虫当高效并发下载的例子
Replacing Celery with Elixir in a Python Project原评论 ↗