Monday, October 5, 2009

Statically Typed Languages

Any programming language in existence today has primitive types that values can be defined as. An example of this would be an integer or a string. This holds true for both statically typed languages and dynamically typed languages. The differences between the two programming language varieties is that in statically typed languages, variables require at least a primitive type before they may be assigned a value. That is, you can't say that variable int_obj has a value of 10 before declaring that int_obj is going to store integer values. Additionally, once a variable has been declared to store certain types, it cannot store a different type. So our int_obj cannot decide to store "10".

The reason for doing this is so that the program can be compiled into machine code that is directly executable by the hardware. Otherwise, the it only serves as a limitation. So are statically typed languages dead? This obviously depends on context because the raw machine code performance is always going to be a requirement. But does this been that entire applications need to be built using a statically typed languages such as C? Probably not. Developing in these languages is no easy task and there are several other development factors to consider during development such as maintainability. Dynamically typed languages offer much more flexibility in both design and maintainability. But this comes at the cost of performance because dynamically typed languages need a virtual machine to execute programs.

Java is an interesting language because it was designed to help implement C++ style applications without the added complexity. Java, however, is still considered a statically typed language. Developers still need to declare the type of the construct before it is used. Java still does perform well, but it is still an interpreted language that is statically typed. This actually helps with the performance even though it is an interpreted language.

So is it possible to have a dynamically typed language that can still support the raw performance offered by statically typed languages? The best approach here is to have a dynamically typed languages which are extended by the low level constructs of statically typed languages.

No comments :

Post a Comment