Is there a compiled* programming language with dynamic, maybe even weak typing?

I wondered if there is a programming language which compiles to machine code/binary (not bytecode then executed by a VM, that's something completely different when considering typing) that features dynamic and/or weak typing, eg:

Think of a compiled language where:

  • Variables don't need to be declared
  • Variables can be created during runtime
  • Functions can return values of different types
  • Questions:

  • Is there such a programming language?
  • (Why) not?
  • I think that a dynamically yet strong typed, compiled language would really sense, but is it possible?


    I believe Lisp fits that description.

    http://en.wikipedia.org/wiki/Common_Lisp


    Objective-C might have some of the properties you seek. Classes can be opened and altered in runtime, and you can send any kind of message to an object, whether it usually responds to it or not. In that way, you can implement duck typing, much like in Ruby. The type id , roughly equivalent to a void* , can be endowed with interfaces that specify a contract that the (otherwise unknown) type will adhere to.


    C# 4.0 has many, if not all of these characteristics. If you really want native machine code, you can compile the bytecode down to machine code using a utility.

    In particular, the use of the dynamic keyword allows objects and their members to be bound dynamically at runtime.

    Check out Anders Hejlsberg's video, The Future of C#, for a primer:

    http://channel9.msdn.com/pdc2008/TL16/

    链接地址: http://www.djcxy.com/p/72310.html

    上一篇: 静态类型和动态类型的定义

    下一篇: 是否有编译*编程语言与动态,甚至可能弱输入?