CSC/ECE 517 Fall 2010/ch7 7a ed
Novel Implementations of Design Patterns in Dynamic Languages
Dynamic languages such as Ruby and Javascript allow many novel implementations of the design patterns we cover in previous chapters, which would not be possible or feasible in complied languages such as Java and C. Language features only available in dynamic languages give developers an increased amount of flexibility in how they can implement design patterns. These language features and the some examples of the implementations they allow are detailed in this section.
Language Features
"These behaviors can be emulated in nearly any language of sufficient complexity, but dynamic languages provide direct tools to make use of them" [1]. Some of the most helpful tools are as follows:
Closures
Metaprogramming
eval
In dynamic languages, any arbitrary code can be executed dynamically at runtime. This can include code that is generated from user input. This is a subset of metaprogramming.
References
- Wikipedia. Dynamic programming language. 2 October 2010. http://en.wikipedia.org/wiki/Dynamic_programming_language
- Cornford, Richard. Javascript Closures. March 2004. http://jibbering.com/faq/notes/closures/