Chinaunix首页 | 论坛 | 博客
  • 博客访问: 157292
  • 博文数量: 22
  • 博客积分: 828
  • 博客等级: 上士
  • 技术积分: 290
  • 用 户 组: 普通用户
  • 注册时间: 2012-05-01 18:16
文章分类

全部博文(22)

文章存档

2012年(22)

分类: C/C++

2012-05-16 20:40:51

C语言,美丽的语言

人们说足球是一种优美的体育运动,而当我们在绿茵场上看到罗纳尔多那行云流水的带球动作时,我们不能不承认这种说法。

然而,对于我来说,这种运动之所以如此的赏心悦目,跟那些乖张的天才球星们关系并不是那么大,更多的原因是这让人心跳的比赛本身。它那缓慢的,常规的节奏间时不时来几个沸点。那大潮般的活力推着一个球队冲着对方的阵地蜂拥而去,对等的、强大的反制力量也从对面扑面而来。

观看一场精彩的比赛,我能领悟到一些道理:赛事的魅力就在于它本身 —— 运动员只是媒介。足球很简单。一个球,44英尺,2个球门,草坪。没有任何东西妨碍它向我们展现它那充满生机的精神灵魂。我们看到了这些,感觉到了这些,我们(至少是我)所以说它是一种美丽的体育运动。

当我浏览C语言代码时,我也感觉到了相同的美。

在不忙的日子里,我会随意的查看C语言的内核,sched.c, page_alloc.c 等等。它让我感觉我正在欣赏一种很有生命力的东西。我能看到这些代码指引着程序的执行,逻辑指令管控制程序能量的分派使用。虽然我不是内核的开发者,但我完全能捕捉到眼前代码的脉络 —— 只是通过观看这些代码的“运动”。

在其它语言里,各种的抽象、甜腻的语法呵护着你的代码,让你看不到它的心跳。但C语言里,就像是足球,在场地上奔跑移动。简单的语法,浅显的关键词,这是对通用冯·诺伊曼,约翰机器最精彩的描述。C语言里,程序的灵魂直接向我们开放。我们看到了、感觉到了,所以我说 ——

C语言,美丽的语言。

[本文英文原文链接: ]

C, THE BEAUTIFUL LANGUAGE

They call soccer the beautiful game, and when we watch  doing things on the pitch that no earthly being should be allowed to, we understand why.

And yet, to me, it's not so much the ungodly talent of the superstars that makes the sport such a pleasure to watch, but more the beating heart of the match itself. The slow, ordinary rhythms that come between the highlight plays. The tidal, life-like forces that propel a team toward its goal and the equally strong counter-forces that prevail from the opposite direction.

Watching a good match, I get the sense that the gameplay exists unto itself -- that the players are merely agents to it. Soccer is a simple sport. One ball, forty-four feet, two goals, and grass. There's nothing preventing the living soul of the game from speaking to us directly. We see this and feel this, and we (or at least I) say soccer is the beautiful sport.

When I look at good C code, I feel the same way.

On slow days, I'll poke around the kernel, sched.c, page_alloc.c, etc., and it very much feels like I'm peering in on a living thing. I can see the code steering the execution, the logic funneling the energy of the program, and even though I'm not a kernel hacker, I can almost get the gist of what I'm looking at simply by watching the way the code "moves".

In other languages, the abstractions and sweet (if helpful) syntactic sugar that attend the code conceal the heartbeat. But in C, as in soccer, the quickening happens on the ground. A simple syntax, a smattering of keywords, an almost perfect description of a general Von Neumann machine. In C, the spirit of the program speaks to us directly. We see this and feel this, and we say --

C, the beautiful language.

阅读(5123) | 评论(6) | 转发(0) |
给主人留下些什么吧!~~

niao59292012-05-18 11:58:48

软件世界里坐着两个神,一端是C,另一端是LISP。呵呵。好好学习就能窥见软件世界的全部。