views:

146

answers:

4

programming languages are grouped it 2 main classes "Dynamic" & "Static". - Is this always the case a programming language is in one of them and not in both, I mean can a language be dynamic and static at the same time ?

+4  A: 

C# 4.0 is a statically typed language that supports dynamic resolution as well. The dynamic keyword basically tells the compiler: don't worry about this for now. If it can't resolved the type at runtime an exception is thrown.

Brian Rasmussen
+1  A: 

Objective-C is another example. It's a strict superset of C, and C is statically typed. But the "objective" stuff can be totally dynamic (all objects declared as type id). The compiler does some static type checking of Objective-C objects, although it is limited since many standard methods return id. For example, the NSArray collection returns objects of type id, so the compiler can't catch:

NSMutableArray *a = [NSMutableArray arrayWithObject:@"I am a string"];
NSNumber *n = [a objectAtIndex:0]; //assigning a string to a number!

although it could flag, NSNumber *n = @"I am a string", at compile time.

Vincent Gable
A: 

yes its possible to have both together (static and dynamic)...

if one uses c# then we are on static track and the movement we use a new System.linq. Expression tree API in vs 2010 (.net 4.0) we are targeting our code towards the framework called DLR (dynamic language Runtime) a layer above CLR.

even our code created by expression class can also be use by other Dynamic languages like IronPython etc..

similarly we can use the iron python code over clr.. all we need to make sure they emit expression tree and are targeted towards the DLR.

prabhjot
+4  A: 

The distinction static and dynamic language is quite ambiguous since it can refer to many different (more or less suitable) criteria. I'll try to answer for each case:

Interpretation/Compilation

This doesn't depend on the language itself but just on the implementation used. Therefore languages can be executed through both an interpreter and a compiler. Examples

  • Haskell (GHC / GHCI / Hugs)
  • C++ (G++ / Ch)
  • F#

Some compiled languages also have the possibility to compile their code at runtime (.NET).

Static/Dynamic typing

Static and dynamic typing (duck typing) can be combined in one language. See C#'s dynamic, VB with Option Explicit/Strict off or Boo. Structural typing can be used to formulate strict typing without explicit type hierarchies. Polymorphic base types (System.Object) support some kind of dynamic behaviour as well, though the type is given statically.

Meta constructs (e.g. Reflection, Runtime type generation)

Are available in Java and .NET too.

Functional techniques(eg. Higher-order functions, continuations)

Can be replicated in statically-typed languages as well. See Haskell or Scala.

Dario