Type Checking:
Type checking is the process of verifying that a program is type safe. A program is type safe if the arguments of all of its operations are the correct type. Type Checking can occur either at compile time or at run time. It is to minimize the possibility of type errors.
Statically Typed Languages:
A programming language is statically typed if it performs type checking at compile time.
Ex: Java, C, C++, C Sharp, Pearl, COBOL, D, Fortran, GNU Pascal, Scala, Spark, Swift, Visual Prolog
Advantages:
- A large class of errors are caught in the early stage of development process.
- Static typing usually results in compiled code that executes more quickly because when the compiler knows the exact data types that are in use, it can produce optimized machine code (i.e. faster and/or using less memory).
Dynamically Typed Languages:
A programming language is dynamically typed if it performs type checking at runtime. These languages verify at runtime, rather than at compile time, that values in an application conform to expected types. These languages typically do not have any type information available at compile time. The type of an object can be determined only at runtime.
Ex: Python, R, JavaScript, Ruby, Visual Basic, PHP, Perl, PowerShell, Objective-C, Lisp, Tcl, AppleScript, Clojure, E, Erlang, Euler, F-Script, J, K, MATLAB, NewtonScript, Parlog, PostScript, Prolog
Advantages:
- Dynamic type checking typically results in less optimized code than static type checking.
- The absence of a separate compilation step means that you don’t have to wait for the compiler to finish before you can test your code changes. This makes the debug cycle much shorter and less cumbersome.
Disadvantages:
- It includes the possibility of run time type errors and forces run time checks to occur for every execution of the program (instead of just at compile-time).
Strongly Typed Languages:
A programming language that features strong typing specifies restrictions on the types of values supplied to its operations. If a computer language implements strong typing, it prevents the execution of an operation if its arguments have the wrong type.
Ex: Java, C, Ruby, Perl, Python, Pascal, Ada, Self, Clojure, Smalltalk
Weekly Typed Languages:
A language that features weak typing would implicitly convert(cast) arguments of an operation if those arguments have wrong or incompatible types.
Ex: JavaScript, Visul Basic, PHP
No comments:
Post a Comment