CS Blog

「离开世界之前 一切都是过程」

把「终端下的 Vim」作为 macOS Finder 的打开方式

Open file with terminal Vim from the macOS Finder

我的日常主力编辑器主要是: (Neo)Vim Spacemacs (via Emacs-plus) Visual Studio Code IntelliJ IDEA 这里面只有 (Neo)Vim 是存活在终端中的(我并不在终端内使用 Emacs),而由于我日常主要是从终端(via iTerm)来使用电脑,所以会把他们都加入到 $PATH 里以方便从终端中唤起,VSCo...

Vim 与中文输入法

Using Vim with non-english input method

Update: 我最后还是放弃把 Vim 作为主要编辑器来输入中文了,整体使用下来 mental model 的 cost 太重了。记笔记时用用中文呀或者改改博客时偶尔用一下还蛮去,这个时候这个功能至少能帮助你 Esc 之后不煞笔,所以也不算完全没有价值吧…… 我相信很多中文世界的 Vimer 都遇到过这个烦恼,在 vim 的 insert 模式时可能突然想输个中文,输完之后会本能的...

Avoiding success at all cost

Watching "Escape from the Ivory Tower: The Haskell Journey"

“Avoiding success at all cost” is the informal motto behinds Haskell. It could be parenthesized in two ways, either “Avoiding (success at all cost)” or “(Avoiding sucess) (at all cost)”. I’m not going to interpret them directly but rather to share some thoughts on “the success vs. costs” basing ...

程序员中的梦想家

Dreamers among programmers

本文首发于我的知乎专栏 The Little Programmer,转载请保留链接 ;) 有一类程序员是 visionary 型的,为了实现一些超前的 idea,绕过某些技术的限制,他们写的 code 晦涩高深得只有他们自己能懂,做出来的 tool 看上去很美好结果处处是坑出了 bug 根本没法查,但正是这类人不断创造出新的东西,在洗礼之后成为一个个 big thing。 我每周...

《PWA 实战》推荐序

「博文视点」邀请我给《PWA实战:面向下一代的Progressive Web APP》 写的推荐序。 Progressive Web App 是继 Ajax、响应式设计、HTML5 之后,web 平台的又一次革命性突破。它在开放 Web 标准的基础之上,突破了以往 Web 应用只能「依赖互联网分发」与「依赖浏览器为入口」的两大桎梏,一下子打开了 Web 应用从性能、架构到用户体验...

如何证明不可计算的函数比可计算的函数多?

Why is there more uncomputable functions?

这篇文章转载自我在知乎上的回答 严谨的证明的话,可以使用「形式语言」(Formal language)来证明: 在可计算理论和计算复杂度理论中,每个「计算问题」都被描述为一个一个「形式语言」,即字符串的集合。比如对于判断一个图是否是无向连通图这个问题:我们可以写为一个描述所有无向连通图的集合: \[A = \{ \langle G \rangle \vert G \text{ ...

如何通俗地解释停机问题?

How to explain the Halting Problem?

这篇文章转载自我在知乎上的回答 我用 Python 伪代码来解释下,我觉得对这个问题有兴趣的应该都是有点编程基础的,所以直接上 code 应该是最容易的。 背景知识 「停机问题」研究的是:是否存在一个「程序」,能够判断另外一个「程序」在特定的「输入」下,是会给出结果(停机),还是会无限执行下去(不停机)。 在下文中,我们用「函数」来表示「程序」,「函数返回」即表示给出了结果。...

为什么 CSS 这么难学?

Why I dislike CSS as a programming language

这篇文章转载自我在知乎上的回答 对我来说,CSS 难学以及烦人是因为它「出乎我意料之外的复杂」且让我觉得「定位矛盾」。 @方应杭 老师的答案我赞了:CSS 的属性互不正交,大量的依赖与耦合难以记忆。 @顾轶灵 @王成 说得也没错:CSS 的很多规则是贯彻整个体系的,而且都记在规范里了,是有规律的,你应该好好读文档而不是去瞎试。 「CSS是一门正儿八经的编程语言,请拿出你学C+...

饿了么的 PWA 升级实践

Upgrading Ele.me to Progressive Web App

很荣幸在今年 2 月到 5 月的时间里,以顾问的身份加入饿了么,参与 PWA 的相关工作。这篇文章其实最初是在以英文写作发表在 medium 上的:Upgrading Ele.me to Progressive Web Apps,获得了一定的关注。所以也决定改写为中文版本再次分享出来,希望能对你有所帮助 ;) 本文首发于 CSDN 与《程序员》2017 年 7...

How does SW-Precache works?

SW-Precache is a great Service Worker tool from Google. It is a node module designed to be integrated into your build process and to generate a service worker for you. Though you can use sw-precache out of the box, you might still wonder what happens under the hood. There you go, this article is ...