问题描述
什么是计算机语言的表达
20050207,Xah Lee。
在人类或计算机语言中,有一个概念表达性。
英语例如,在表现形式上非常富有表现力,见证所有
诗歌和含义以及典故和内涵以及
dictions。有很多方法可以说一件事,模糊和温暖,以及所有的b $ b。但是,当我们看看它可以说什么,它的意义,或它的效率或精确度的表达能力,我们
发现自然语言无能为力。 />
这些可以通过几种方式看出来。一种可靠的方法是通过逻辑,
语言学,或者所谓的语言哲学。还可以通过
学习人工语言lojban直接收集自然语言的无能力和不足,其中一个人意识到,不仅仅是b $ b自然语言精确度不高,缺乏效率,
但是很多东西几乎不可能通过
来表达。
计算行业中常常被误解的一个问题是
表达性的概念。如果一种语言有一个词汇(微笑,笑,笑,
傻笑,轻笑,笑声,咯咯笑),那么这种语言将不会像
表达,只有语言(严重,轻微,笑,哭)。
前者是富有表现力的在细微差别方面,后者是
表达意义。
同样,在计算机语言中,表现力很重要
尊重语义,而不是语法变异。
通过Perl与Python
语言可以很容易地看出这两个截然不同的想法,并作为一个具体的例子他们的文本模式匹配
功能。
Perl是一种语法杂色的语言。 Python在另一方面
手,甚至不允许更改代码的缩进,但它的表达效率和表达能力相对于语义,
展示了Perl在规范中的贫困。
??版权所有2005年Xah Lee。
Xah
a ??
What is Expresiveness in a Computer Language
20050207, Xah Lee.
In languages human or computer, there''s a notion of expressiveness.
English for example, is very expressive in manifestation, witness all
the poetry and implications and allusions and connotations and
dictions. There are a myriad ways to say one thing, fuzzy and warm and
all. But when we look at what things it can say, its power of
expression with respect to meaning, or its efficiency or precision, we
find natural languages incapable.
These can be seen thru several means. A sure way is thru logic,
linguistics, and or what''s called Philosophy of Languages. One can also
glean directly the incapacity and inadequacy of natural languages by
studying the artificial language lojban, where one realizes, not only
are natural languages incapable in precision and lacking in efficiency,
but simply a huge number of things are near impossible to express thru
them.
One thing commonly misunderstood in computing industry is the notion of
expressiveness. If a language has a vocabulary of (smile, laugh, grin,
giggle, chuckle, guffaw, cackle), then that language will not be as
expressive, as a language with just (severe, slight, laugh, cry). The
former is "expressive" in terms of nuance, where the latter is
expressive with respect to meaning.
Similarly, in computer languages, expressiveness is significant with
respect to semantics, not syntactical variation.
These two contrasting ideas can be easily seen thru Perl versus Python
languages, and as one specific example of their text pattern matching
capabilities.
Perl is a language of syntactical variegations. Python on the other
hand, does not even allow changes in code''s indentation, but its
efficiency and power in expression, with respect to semantics,
showcases Perl''s poverty in specification.
http://xahlee.org/perl-python/what_i...esiveness.html
?? Copyright 2005 by Xah Lee.
Xah
xa*@xahlee.org
a?? http://xahlee.org/
推荐答案
嗯,这取决于参数的类型
你传递给方法,不是吗?打电话给
距离([1,1],[0,0])
对我来说很好。这是一个稍微简单的实现
,它避免了len(从而接受更广泛的参数类型)
和pow:
def distance(element1,element2):
dist = 0
为a,b为zip(element1,element2):
n = float (ab)
dist + = n * n
返回math.sqrt(dist)
(如果那是'不知道'' n维距离的正确公式。
我在过去的十年中忘记了太多的数学运算。)
/ Jorgen
-
// Jorgen Grahn< jgrahn @ Ph''nglui mglw''nafh Cthulhu
\ X / algonet.se> ; R''lyeh wgah''nagl fhtagn!
Well, that depends on the types of the arguments
you''re passing to the method, doesn''t it? A call like
distance([1,1], [0,0])
works fine for me. And here is a slightly simpler implementation
which avoids len (thus accepting a wider range of argument types)
and pow:
def distance(element1, element2):
dist=0
for a, b in zip(element1, element2):
n = float(a-b)
dist += n*n
return math.sqrt(dist)
(Dunno if that''s the correct formula for n-dimensional distance.
I have forgotten way too much math in the past ten years.)
/Jorgen
--
// Jorgen Grahn <jgrahn@ Ph''nglui mglw''nafh Cthulhu
\X/ algonet.se> R''lyeh wgah''nagl fhtagn!
问候,
乔治
Regards,
George
这篇关于什么是计算机语言的表达?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!