Python是我目前所知道的最优秀的语言,但是由于自动完成,静态类型是一个很大的优势(虽然对动态语言的支持有限,但与静态语言所支持的语言相比,它是微不足道的)。我很好奇是否有任何语言试图将Python的好处添加到静态类型化语言中。特别是,我对语言很感兴趣,其特性如下:
是否有任何静态类型化语言具有大量这些特性?
发布于 2010-02-15 09:20:09
嘘是公共语言基础结构(又称公共语言基础结构)的静态类型语言。微软.NET平台)。这种语法受到Python的高度启发,散列/列表/数组是语法的一部分:
i = 5
if i > 5:
print "i is greater than 5."
else:
print "i is less than or equal to 5."
hash = {'a': 1, 'b': 2, 'monkey': 3, 42: 'the answer'}
print hash['a']
print hash[42]
for item in hash:
print item.Key, '=>', item.Value发布于 2010-02-15 12:59:54
眼镜蛇是CLR的静态类型语言(作为Boo)。在其网页上:
眼镜蛇是一种通用的编程语言,具有:
Sample code:
"""
This is a doc string for the whole module.
"""
class Person
"""
This is a class declaration.
"""
var _name as String # declare an object variable. every instance of Person will have a name
var _age as int
cue init(name as String, age as int)
_name = name
_age = age
def sayHello
# This is a method
# In strings, anything in brackets ([]) is evaluated as an expression,
# converted to a string and substituted into the string:
print 'Hello. My name is [_name] and I am [_age].'
def add(i as int, j as int) as int
""" Adds the two arguments and returns their sum. """
return i + j发布于 2010-02-15 22:53:28
虽然Haskell不是面向对象的,但它提供了大量您感兴趣的特性:
do表示法。(对字典的语法支持仅限于成对列表,例如,
dict = ofElements (“人造卫星”,1957年),(“阿波罗”,1969年),(“挑战者”,1988年)另外,为了让你有宾至如归的感觉,Haskell有明显的缩痕!
实际上,我认为Haskell与Python的总体感觉完全不同,但这主要是因为非常强大的静态类型系统。如果您有兴趣尝试静态类型的语言,Haskell是目前最雄心勃勃的语言之一。
https://stackoverflow.com/questions/2264889
复制相似问题