哪些静态类型语言与 Python 相似? [英] What statically typed languages are similar to Python?

查看:65
本文介绍了哪些静态类型语言与 Python 相似?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Python 是我目前所知道的最好的语言,但是由于自动完成,静态类型是一个很大的优势(尽管对动态语言的支持有限,但与静态支持的相比,它算不了什么).我很好奇是否有任何语言试图将 Python 的优点添加到静态类型语言中.特别是我对具有以下功能的语言很感兴趣:

Python is the nicest language I currently know of, but static typing is a big advantage due to auto-completion (although there is limited support for dynamic languages, it is nothing compared to that supported in static). I'm curious if there are any languages which try to add the benefits of Python to a statically typed language. In particular I'm interesting in languages with features like:

  • 语法支持:例如字典、数组推导式的语法支持
  • 函数:关键字参数、闭包、元组/多个返回值
  • 运行时修改/创建类
  • 避免在任何地方指定类(在 Python 中这是由于鸭子类型,尽管类型推断在静态类型语言中效果更好)
  • 元编程支持:这是在 Python 中通过反射、注释和元类实现的

是否有任何静态类型语言具有大量这些功能?

Are there any statically typed languages with a significant number of these features?

推荐答案

Boo 是一个公共语言基础结构(又名 Microsoft .NET 平台)的静态类型语言.语法高度受 Python 启发,哈希/列表/数组是语法的一部分:

Boo is a statically typed language for the Common Language Infrastructure (aka. the Microsoft .NET platform). The syntax is highly inspired by Python, and hashes/lists/array are part of the syntax:

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

这篇关于哪些静态类型语言与 Python 相似?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆