What statically typed languages are similar to Python?

Casebash picture Casebash · Feb 15, 2010 · Viewed 10.8k times · Source

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:

  • Syntax support: such as that for dictionaries, array comprehensions
  • Functions: Keyword arguments, closures, tuple/multiple return values
  • Runtime modification/creation of classes
  • Avoidance of specifying classes everywhere (in Python this is due to duck typing, although type inference would work better in a statically typed language)
  • Metaprogramming support: This is achieved in Python through reflection, annotations and metaclasses

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

Answer

Jørn Schou-Rode picture Jørn Schou-Rode · Feb 15, 2010

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