Monday, October 29, 2007

Dynamic and static languages

As I've mentioned I'm reading a "Design Patterns" by Erich Gamma. Yesterday I've finished reading about structural patterns. I have to say that this book contributed a lot to my understanding of object-oriented programming, not only in a way of giving information about patterns, but also about whole programming. While reading I've often found examples of difference between dynamic programming languages and static ones.

In most cases dynamic languages looked better that static. Some methods hard to implement in static languages are easy to implement or built in dynamic languages: creating prototypes, changing behavior of object on-the-fly, programming by interface not implementation. It's not a secret dynamic languages such as Perl, Python, Ruby, etc. usually require less amount of code lines than static like C++. This mainly provided by different approaches to code handling: static languages are usually compiled, while dynamic are interpreted.

Dynamic nature of languages like Python provide rather wide abilities to work with classes and objects but in most cases programmers doesn't need available but rather low-level features (does we need very often put definition of function in if-statement?). And the cost is slow execution speed. Moreover if there is an error in program developer will know about it only when interpreter will reach this piece of code, while some of such errors could be caught during compilation.

As I think, is that in most cases interpreted languages are enough good for very big range of application what is proved by current trends in programming. But compiling languages still are rather popular. They are much better in implementing complex algorithms which uses a lot of resources. I agree with J. Ousterhout in article "Scripting", that static languages are useful for complex data structures from basic data types, which are often accompanied by low-level difficult to understand algorithms; and with dynamic (scripting) languages we can combine this elements to systems. Present dynamic languages (at least as I know Python and Ruby) provide an ability to plug into program modules written on C/C++. Thomas and Hunt in "Pragmatic Programmer" wrote a lot about DSL (Domain-Specific Languages). They can be thought as scripting languages with very tight integration into application. I think in future we can expect not only the expansion of using of dynamic languages but also developing of more tight integration between them and static languages.

No comments: