CSC/ECE 517 Fall 2009/wiki1b 2 sk: Difference between revisions

From Expertiza_Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 14: Line 14:
= Introduction =
= Introduction =


<b>1.1 Statically Typed Languages </b>
<b> Dynamically Typed Languages </b>
Dynamically typed languages are those in which type checking is done at run-time.  Variable need not be defined before they are used.  Some examples of dynamically typed languages are Ruby, Python, PHP, Smalltalk, Prolog, JavaScript, Objective-C.
/* Ruby code sample */
a = [1, 2, 3, 4, "Hi"]
 
The above code declares array that holds mix of integer and string types.  Note that there was no need to specify array type and this would be determine automatically during runtime.  However such a declaration is not possible in statically typed language like C, C++, Java, etc. doing so would give compile time errors.

Revision as of 05:20, 20 September 2009

Contents

1.Introduction

 1.1 Dynamically Typed Languages
 1.2 Statically Typed Languages

2. Advantages of Statically Typed v/s Dynamically typed 3. When Statically Typed is preferred over Dynamically typed 4. Examples 5. Conclusion 6. Glossary 7. References


Introduction

Dynamically Typed Languages Dynamically typed languages are those in which type checking is done at run-time. Variable need not be defined before they are used. Some examples of dynamically typed languages are Ruby, Python, PHP, Smalltalk, Prolog, JavaScript, Objective-C. /* Ruby code sample */ a = [1, 2, 3, 4, "Hi"]

The above code declares array that holds mix of integer and string types. Note that there was no need to specify array type and this would be determine automatically during runtime. However such a declaration is not possible in statically typed language like C, C++, Java, etc. doing so would give compile time errors.