dexteryy对《编程人生》的笔记(1)

编程人生
  • 书名: 编程人生
  • 作者: Peter Seibel
  • 副标题: 15位软件先驱访谈录
  • 页数: 473
  • 出版社: 人民邮电出版社
  • 出版年: 2011-1-1
  • 第111页

    JavaScript用户的斯德哥尔摩综合症:微软不想改进,所以这语言也就这样了,用lambda代码来实现所有东西是一个优势,干嘛还要更好的语法

    Oh, it only does what it does because Microsoft stopped letting it improve, so why should we want better syntax; it’s actually a virtue to go lambda-code everything.
    引自第111页

    Eich认为现在是程序语言发展的第二个黄金时代,应该重视语言本身的改进,不能止步不前,由于web重视兼容性,所以JS止步的太久,但不能以此为借口拒绝改进。 关于为什么要改进 跟Doug Crockford相反,Eich认为JS不能过于精简化、子集化,不能只保持de-sugar之后的几个原始特性(比如lambda),因为:

    It’s very reductionistic and it’s not for everybody. Subsetting is powerful. But to say everyone has to program in this sort of minuscule subset, that’s not usable. tries to make everybody into an expert and it will not work on the large number of programmers out there who have been mistrained in these Java schools.
    引自第111页

    当初不把JS设计成一个纯粹的lambda x86语言的理由也是一样:不是每个人都想成为superhacker,程序员中也有一个金字塔。 lambda是JS的理论优势,但Eich认为要让JS兼具理论和实用的优势,就不能仅仅为了纯洁性而放弃好用的功能。 Doug等人传播了一些模式去解决JS的问题,某种程度上来说很成功,让普通开发者们在patterny level上了解到很多函数式编程的概念和惯用法,但Eich更同意Peter Norvig的观点:模式反映出程序语言本身存在某种缺陷。这些模式不是免费的午餐。 另一个改进的理由是,尽管程序员们可以通过写抽象库,自己解决很多问题(而且Eich非常欣赏一些JS库,认为它们令人振奋,反映了人们是何等聪明,能用非常小的工具集做出非常合理非常方便的抽象),但这种抽象能力在现有的语言中还是受到了很大限制,所以语言本身需要扩展。 关于如何作改进 除了Eich的blog连发的三篇文章里提到过的重大改进(比如proxy和for-in语法),这篇采访里还反映出他本来早就想引入macro,因为担心这个过程耗时很长研究性质很强,没办法吸引到微软,所以暂时搁置了,但他们一直在确保现有的和即将加入的语法糖能随时转化成宏:

    we do make sure we can recast all of the sugar as macros when we have macros.
    引自第111页

    当Seibel询问对Knuth的文学化编程(literate programming)的看法时,Eich提到他对于doc comments和doc strings的兴趣,认为缺乏自动从注释里提取信息转化成可读文字和自动检查的手段,literate programming包含了整合测试和注释的含义。他们曾在ES4里做过尝试(AS3的metadata算么):

    We tried to add doc comments of some sort to ES4 with first-class metadata hooks or reflection hooks and it was just impossible to get everybody to agree.
    引自第111页

    此外Eich对静态语法分析有极大的兴趣(他的blog里也有相关的文章),他提到这是他们希望JS具备可选类型的原因之一:

    That was one of the reasons why in JavaScript we were interested in optional typing and we still are, though it’s controversial in the committee. There’s still a strong chance we’ll get some kind of hybrid type system into a future version of JavaScript.
    引自第111页

    嗯嗯其实我想说的是……以上三点(宏、文档注释、静态分析)正好都包含在我去年开发的JS预处理器的愿景之中呀~木哈哈哈哈,所见略同所见略同~ 好罢这其实是111页的前后几页的笔记……不过都是同一个话题…… P.S. 学到一个新的骂人话:Java是一种“blue-collar language”(中文版翻译成“IT民工语言”) 再P.S. 全篇都充斥着Eich和Doug的基情口牙~~提到Doug的次数太多了~比如:

    Seibel: Was the ES4 proposal your chance to show the world that, “Look, I’m a really smart guy and JavaScript is a really a good language”? Eich: No, I don’t think so. I know Doug may think that. I don’t think Doug knows me that well, but the thing is, I’m not really looking for respect, especially from the Java-heads or the trailing edge.
    引自第111页

    2011-07-04 15:17:52 6人喜欢 1回应