程序员一年究竟能有多少代码产量?
前两天在厦门做了个即兴的演讲,我随口说了个数字说我现在大约一年的代码产量是20万行。当时雷军表示不信,下来我们讨论了一下20万行的可能性,雷军的观点是,要保持年产20万行代码,必须每天写 800 多行代码,因为要留出思考的时间,所以代码日产量是远高于这个数字的。所以不太可能。
我今天统计了一下2005年 8 月份到年底的代码量,发现轻易超过了8 万行的产量。8月开始我和同事做的一个主要的项目,目前的统计数字是 9 万余行代码(几乎是用 editplus 手写,无 copy-paste 和机器自动生成代码,甚至都没有用 VC IDE 里的自动完成)这个项目目前留下来的代码是 9 月底开始的,在此之前两个月的东西我们全部重构了,懒的把老版本从仓库里拿出来统计,就算 2 万行吧。那么我个人的代码产量就是 5 万余。
前段时间写了个虚拟机和一个脚本编译器外加测试代码,统计下来是 6000 余行,在此之前用 C 做了一些虚拟机的实现,大约 1500 行。
前段时间要新开一个 2d 游戏的项目,我把 2d engine 用 lua 重新封装了一次,给其他的程序员用。这部分代码 2500 余行。另外作为演示,写了大约 1000 行的 lua 脚本。
另外一些零散写着玩儿的小东西 20 余个,平均每个有代码 500 行左右,按 1 万行计算。
以上没有计算手写 jamfile 和编写 jam 脚本的代码量,还有对以前一些老项目的修补。我是不喜欢写注释的,所有代码中,注释和空白行占的比例是 10% 。
这小半年,我另外做了许多策划以及管理的工作,代码效率大不如上半年,所以我认为年产 20 万行的数据应该没有浮夸。
当时雷军跟我算的时候说,要保证年产 20 万行代码,就要保证每天写 800 多行。我自己除了一下,20w / 365 只有 500 多,这才恍然大悟,原来说的是工作日啊 :) 偶现在是把写程序当作乐趣,所以反而周末的产量比较高了。工作日的杂事很多,很多时间不能去写程序。
记得以前测算过,一般一天下来,接近 2 千有效代码的速度是跟的上的。平时写点小东西玩的话,一个连续的时间片,大约都是四五百行的数量。
当然一个好程序员绝对不应该用代码的绝对行数来衡量水平,甚至我认为越好的程序员应该代码行的产量越低。这两年我的代码产量就明显低于前几年了 :D 那么以后,我应该朝年产10万行代码奋斗了。
Comments
Posted by: ps | (57) July 31, 2015 01:38 PM
Posted by: ohon | (56) May 28, 2015 08:12 AM
Posted by: ohon | (55) May 28, 2015 08:12 AM
Posted by: mimimamadeCode | (54) May 18, 2015 12:29 PM
Posted by: mimimamadeCode | (53) May 18, 2015 12:27 PM
Posted by: box | (52) April 10, 2015 09:34 AM
Posted by: 业务云笔记 | (51) October 10, 2013 10:57 AM
Posted by: victor | (50) October 9, 2013 08:28 PM
Posted by: zj | (49) September 26, 2013 11:00 AM
Posted by: mmzoe | (48) July 10, 2012 04:44 PM
Posted by: Anonymous | (47) June 4, 2012 12:03 AM
Posted by: thorow new error() | (46) July 25, 2011 02:51 PM
Posted by: mike | (45) January 9, 2009 05:59 PM
Posted by: Kinogam | (44) January 4, 2009 03:34 PM
Posted by: Anonymous | (43) January 4, 2009 12:22 AM
Posted by: Sid | (42) May 7, 2008 01:47 PM
Posted by: woolf | (41) January 15, 2008 05:15 PM
Posted by: nothanks | (40) January 15, 2008 04:33 PM
Posted by: Cloud | (39) January 15, 2008 03:30 PM
Posted by: woolf | (38) January 15, 2008 02:23 PM
Posted by: woolf | (37) January 15, 2008 02:15 PM
Posted by: denyspang | (36) June 4, 2007 04:40 PM
Posted by: missdeer | (35) May 16, 2007 07:59 PM
Posted by: 1 | (34) May 16, 2007 01:52 AM
Posted by: tgame | (33) March 26, 2007 08:21 PM
Posted by: sew97 | (32) August 30, 2006 04:45 PM
Posted by: Anonymous | (31) February 26, 2006 02:21 PM
Posted by: Anonymous | (30) February 26, 2006 02:17 PM
Posted by: xue23 | (29) February 24, 2006 11:15 PM
Posted by: Cloud | (28) February 24, 2006 01:29 PM
Posted by: sungrass | (27) February 24, 2006 12:25 PM
Posted by: Cloud | (26) February 13, 2006 01:18 PM
Posted by: 邱海峰 | (25) February 13, 2006 12:28 PM
Posted by: 2002thinking | (24) February 11, 2006 09:00 PM
Posted by: 清风雨 | (23) February 10, 2006 01:41 PM
Posted by: 呵呵哈哈 | (22) January 31, 2006 05:39 PM
Posted by: Cloud | (21) January 22, 2006 08:20 PM
Posted by: ricardo | (20) January 22, 2006 02:14 PM
Posted by: 燕尘 | (19) January 22, 2006 02:46 AM
Posted by: Zelor | (18) January 20, 2006 11:11 PM
Posted by: Cloud | (17) January 20, 2006 04:36 PM
Posted by: yanxm | (16) January 20, 2006 04:14 PM
Posted by: Cloud | (15) January 20, 2006 02:23 PM
Posted by: Anonymous | (14) January 20, 2006 02:04 PM
Posted by: coder | (13) January 19, 2006 10:28 PM
Posted by: Cloud | (12) January 17, 2006 11:49 PM
Posted by: Anonymous | (11) January 17, 2006 10:26 PM
Posted by: Anonymous | (10) January 17, 2006 08:26 PM
Posted by: Cloud | (9) January 17, 2006 07:30 PM
Posted by: Solstice | (8) January 17, 2006 07:01 PM
Posted by: sword007 | (7) January 17, 2006 09:37 AM
Posted by: Cloud | (6) January 16, 2006 04:19 PM
Posted by: Anonymous | (5) January 16, 2006 12:41 PM
Posted by: bad_fish | (4) January 15, 2006 01:09 AM
Posted by: coder | (3) January 14, 2006 09:37 PM
Posted by: sword007 | (2) January 14, 2006 01:24 PM
Posted by: fire | (1) January 14, 2006 12:20 PM