views:

117

answers:

5

In my reading on dynamic and static typing, I keep coming up against the assumption that statically typed languages are compiled, while dynamically typed languages are interpreted. I know that in general this is true, but I'm interested in the exceptions.

I'd really like someone to not only give some examples of these exceptions, but try to explain why it was decided that these languages should work in this way.

+1  A: 

Python is a dynamic language that has compilers.

See this SO question - Python - why compile?, for instance.

In general, compiling makes the program run much faster.

Oded
but still runs in an interpreter, as it is not compiled to machine language but to a special byte code that can only be run by a python virtual machine (a.k.a. interpreter)
flybywire
As do Java, C# and the other .NET languages. They are all still considered to be compiled, even if it is to bytecode.
Oded
That's interesting. I guess bytecode blurs the distinction between compiling and interpreting.
Skilldrick
Any language can be compiled into any form between "whitespace removed" and "machine code", type systems don't have anything to do with it.
deceze
.NET bytecode isn't interpreted, it is compiled further into native machine code (is NetMF an exception to this?). Java isn't a .NET language.
Ben Voigt
+1  A: 

I believe Java (a statically typed language) was interpreted on older versions of the JVM, whereas it now uses Just In Time (JIT) compilation, meaning machine code is generated at runtime. I also believe ML and its dialects can be interpreted, and ML is definitely statically typed.

Michael Williamson
+1  A: 

Actionscript has dynamic typing and compiles to bytecode.

And it even compiles right down to native machine code if you want to release a Flash app on the iPhone.

Anon.
+1  A: 

Objective-C is compiled and supports dynamic typing (certainly when calling methods via [target doSomething] syntax). That is, you can send any message to a target (using ordinary language syntax, without programming against a reflection API), receive only a warning at compile time that it might not be handled, and receive an exception only at runtime if the target doesn't respond to that selector (which is like a method signature); and you can ask any object (which can all be of static type id if your code doesn't know any better or doesn't care) whether it respondsToSelector: to probe its capabilities.

Woody Zenfell III
+5  A: 
Norman Ramsey
Wow, awesome answer :D Thanks very much.
Skilldrick