注册 登录
中国红客联盟 返回首页

毁灭_perish的个人空间 http://www.cnhonkerarmy.com/?837563 [收藏] [复制] [分享] [RSS]


Programming Languages: More Powerful with Less Freedom?

热度 6已有 1331 次阅读2016-9-4 10:32 | Freedom

in quest for more power, C# has recently been grown with new features and Java might follow soon the same path. While extending the choice of features provides programmer with more freedom, does this necessarily provide more power? And does a language need to offer a lot of freedom and flexibility to be genuinely powerful? 

Reg Braithwaite believes that this is not necessarily true. In response to Azubuko Obele’s statement that “people who argue for languages with more power are actually arguing for less rules”, Braithwaite asserts that there is no causal relationship between power and freedom even though the two are correlated in many languages, e.g. Ruby. According to Reg, Python is “a considerably more powerful language than Java” even though both are “built with the philosophy that removing certain programmer freedoms would produce better programs”. In Python, features were not rejected simply because they could be potentially misused but rather when they were judged unnecessary, either because there were already “a perfectly serviceable way” to achieve the desired outcome or because they concerned things “that don’t matter, like indentation”. And this approach did not prevent from adding new features to the languages if those could “fit within Python’s style and design æsthetic”.  

Some functional languages also impose strict rules, which does not mean they offer less power: 

Haskell is quite possibly the most extremely limiting language in common use: there is one way to do everything, mathematically pure functional programming. You have strong, expressive static typing 


Likewise, the Factor programming language imposes a single, constraining set of rules on the programmer: programmers switching to Factor must relinquish their local variables to gain Factor’s higher-order programming power.

Hence, Reg argues that “languages can provide more power while also providing more rules and, paradoxically, less freedom.” What really matters, according to him, is careful design that follows a guiding philosophy and brings coherence into the language. The languages can then provide more power by letting programmer achieve more with less and it can be grown without “throwing more [often unrelated] features on top of the pile”:

Good design in every field accomplishes the “antigravity” trick of accomplishing more with less. With poor design, adding new power requires adding more check boxes, more features, more ways to do things that interact with each other unexpectedly.

While sharing Braithwaite’s opinion that power and freedom are not necessarily correlated, one of commentators, Daniel, argues that power of a language does not depend on rules it imposes on programmers but on “computer language "theorems" it provides: 

A computer language is not akin to rules, but akin to mathematics. […] So, compare it to algebra. The more theorems you have, the more powerful you are. Are theorems freedom? Not, of course not. Theorems are fundamental truths that can be combined to more easily achieve further results.

According to Daniel, what makes the difference between languages is to which extent theorems they provide are constructs that are easy for human minds to deal with: 

For instance, in machine code there is no "for" loop as most of us would understand them. What you have are conditional jumps based on CPU flags. 

But from that we developed a very useful construct, which is the "for" loop.
Now, even though the "for" loop is a very powerful construct, it is often prone to misuse. Few people can really truly simulate in their minds a "for" loop, so errors in that construct are not uncommon. 

Now, a "foreach" (list iterator or mapper) construct might not be as flexible as a "for" construct, but it is easier for us to understand.

Daniel advocates for using such easy to understand constructs because this limits the risk of misusing them and makes a language more “prone to correct programs”. Even though these constructs can be “powerful and easy to use at the same time”, this is not always the case and some “theorems” prone to be misused are actually more powerful. Hence, not only is there no direct correlation between freedom and power, but one may need to renounce to some power in the name of code quality.  

In spite of underlying conceptual difference, these two approaches don’t oppose each other. Based on arguments of both Reg and Daniel, one could argue that to be genuinely powerful, a language needs to have a carefully conceived design that guarantees the coherence of different features and to offer constructs that make sense for humans in order to limit the risk of misuse and to rise the quality of code.


  Reg Braithwaite深信未必如此。在回应Azubuko Obele的论调“希望语言变得强大的人们实际上是希望有更多的自由”时,Braithwaite声称强大与自由之间根本没有因果关系,即使在很多语言中这两者都是相互关联的,比如Ruby。根据Reg所述,Python是“一个比Java强大的多的语言”,尽管这两者都是“根据如下哲学构建的:适当去除开发者的自由会生成更好的程序”。在Python中,特性之所以被去除不是因为他们可能被误用,而是由于他们被认为是不必要的。这既可能是因为已经存在了“一个完美的方案”来获得期望的结果,也可能是因为这些特性关心的是“不重要”的东西,比如“缩进”。但是如果这些特性能“适合 Python的风格和设计艺术”,这种方式并不会阻止向语言中增加新的特性。








  现在,“foreach”(list iterator或者mapper)结构可能不像“for”结构那样灵活,但它更容易理解。


发表评论 评论 (5 个评论)

回复 风的低语 2017-8-25 10:09
回复 Ariza 2018-3-20 00:07
回复 BLSP 2018-8-20 18:39
回复 沉默的某人 2018-8-20 23:40
Basically,it depends on the programmer,as we are unable to tell or justify by our views.
回复 shizherusifu 2019-9-23 21:59
加油 努力奋斗   这篇英文翻译完毕

facelist doodle 涂鸦板

您需要登录后才可以评论 登录 | 注册


Processed in 0.088202 second(s), 8 queries.

站点统计| 举报| Archiver| 手机版| 黑屋 |   

Powered by HUC © 2001-2017 Comsenz Inc.



Honor accompaniments. theme macfee