Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Advantages of Dynamic and Static type checking

Can anyone provide some advantages and disadvantages each; static type checking and dynamic type checking?

like image 535
rp7 Avatar asked Jan 16 '13 21:01

rp7


People also ask

What are the advantages of dynamic type checking?

Advantage of Dynamic Type Checking Dynamic type checking can find many errors that cannot be identified by static type checking. In most languages, static type checking is not possible for some language constructs in certain cases but the same purpose can be achieved by dynamic type checking.

What is the difference between static and dynamic checking?

Static checking: the bug is found automatically before the program even runs. Dynamic checking: the bug is found automatically when the code is executed. No checking: the language doesn't help you find the error at all.

What is the difference between static and dynamic typing?

First, dynamically-typed languages perform type checking at runtime, while statically typed languages perform type checking at compile time.


2 Answers

This question has been hit on a few times at SO:

What is the difference between statically typed and dynamically typed languages?

Dynamic type languages versus static type languages

Are dynamic languages slower than static languages?

Dynamically compiled language vs statically compiled language

like image 155
Bryan Johnson Avatar answered Sep 23 '22 01:09

Bryan Johnson


Static typing has the following main benefits:

It allows statically (without running the program) detecting many programming errors quickly, reliably and automatically. This helps reduce the number of bugs and reduces the time spent on debugging. Type declarations serve as automatically-checked documentation. They make programs easier to understand and maintain. Static typing may improve runtime efficiency. (Note that the Alore runtime cannot currently take advantage of type declarations, but this will likely change in the future.) Dynamic typing has a different, complementary set of benefits:

Dynamic typing is conceptually simpler and easier to understand than static typing, especially when using powerful container types such as Alore arrays, tuples and maps. This effect is pronounced for non-expert programmers. Dynamic typing is more flexible. A static type system always restricts what can be conveniently expressed. Programming with a static type system often requires more design and implementation effort. Dynamic typing results in more compact programs, since it is more flexible and does not require types to be spelled out. The benefits of static typing are more pronounced for large and complex programs. It offers little benefit over dynamic typing when writing short scripts and prototypes, for example. In these cases it mainly slows down the programmer, and dynamic typing is preferable.

via: http://www.alorelang.org/doc/typeoverview.html

like image 34
PuJA PhuLARA Avatar answered Sep 23 '22 01:09

PuJA PhuLARA