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, e.g:
Think of a compiled language where:
Questions:
I think that a dynamically yet strong typed, compiled language would really sense, but is it possible?
No - it's certainly possible to compile dynamic languages. There are even some dynamic languages that are always compiled by design (e.g. Clojure).
In dynamic typing, types are associated with values not variables. Dynamically typed languages include Groovy, JavaScript, Lisp, Lua, Objective-C, Perl (with respect to user-defined types but not built-in types), PHP, Prolog, Python, Ruby, Smalltalk and Tcl.
So in simple terms, static/dynamic typing refers to the time when type checking occurs: compile time for static typing, and run time for dynamic languages. Likewise, strong/weak typing refers to how aggressive a language is in enforcing its type system.
Weak Typing For instance, JavaScript is an example of weakly typed language. The implication is that operations between variables of different data types are legal.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With