Skip to content

Instantly share code, notes, and snippets.

@rgardner
Last active August 29, 2015 14:00
Show Gist options
  • Save rgardner/11347929 to your computer and use it in GitHub Desktop.
Save rgardner/11347929 to your computer and use it in GitHub Desktop.
Strong vs. Weak; Static vs. Dynamic Typing

The following description is from Bruce Tate's excellent: Seven Languages in Seven Weeks by Bruce A. Tate in his chapter on Scala (p123). The coercion property of strongly typed languages confused me when I first learned about these language designs in my Introduction to Computer Science course. Hope this passage helps someone else too.

My Inner Battle with Static Typing

Strong vs. Weak

Strong Typing

The lanugage detects when two types are compatible, throwing an error or coercing the types if they are not. Examples: Java and Ruby

Weak Typing

the compiler doesn't necessarily care whether the data in a memory location is an integer, a string, or just data. Examples: C and Assembly

Static vs. Dynamic

Statically typed languages enforce polymorphism based on the structure of the types. Is it a duck by the genetic blueprint (static), or is it a duck because it quacks or walks like one? Statically typed languages benefit because compilers and tools know more about your code to trap errors, highlight code, and refactor. The cost is having to do more work and living with some restrictions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment