Introduction to Static and Dynamic Typing
One important concept to understand when programming is the difference between static and dynamic typing. Static typing can be seen in languages such as Java or C++, and dynamic typing is used in languages such as Python or PHP. Each has its advantages and disadvantages.
Static typing, because type checking is performed during compilation, allows for errors to be caught early in the development process. This way, the checks do not need to be performed each time the program is run and can make program execution more efficient. Variables cannot be created on the fly as they are needed; they must first be defined. Some programmers dislike this extra step in coding, but it often makes for safer, more predictable program outcomes.
In dynamic typing, type checking is done at run-time rather than compile-time. As a result, these languages can produce more run-time errors and have less guarantees with how the program will run, since certain "invalid" programs which a static typing language would reject at compilation are allowed to run. However, dynamic languages are more flexible. Since more errors tend to occur at run-time than compile-time, these programs are often more difficult to debug. As such, the principle of unit testing, or testing one piece of the program at a time, is extremely important when working with a dynamic language.
Note that static and dynamic typing are not the same as strong and weak typing. Strong typing simply means that variable types are required, and weak typing is when variables do not have a specific type. Many people assume static and strong typing are the same thing as are dynamic and weak typing, but this is not necessarily true. In Python, variables can be dynamically created as they are needed, but it is not a weak language as variables have types.
As you can see, understanding the difference between static and dynamic typing is an important aspect of programming, and can help you chose the language which best suits the needs of your application. Each has its own pros and cons, but both are widely used.
PHP has numerous free and open source libraries. The main focus of the language is to efficiently create truly dynamic web content on a server and display it to end users viewing the site.The dynamic content could be anything from a simple GIF image to an entirely customized web page rich with features ranging from basic HTML all the way to graphically intensive interactive Flash.
Related posts:
