diff --git a/src/Markdowns/Catalog.js b/src/Markdowns/Catalog.js index 5ea6c5b..a7e90b9 100644 --- a/src/Markdowns/Catalog.js +++ b/src/Markdowns/Catalog.js @@ -19,24 +19,31 @@ export const Catalog = { { title: "Evolve your Developer Game", description: "Software Developer/Engineer: Starting out and Evolving", - category: "Crafstmanship", + category: "Craftsmanship", fileName: "evolve-developer", author: "Shreyas Balachandran", }, { title: "Code Craftsmanship", description: "Three simple rules to become a better code craftsman", - category: "Crafstmanship", + category: "Craftsmanship", fileName: "code-craftsmanship", author: "Natedeploys", }, { title: "10x Developers", description: "10x Developer attributes, road to success", - category: "Crafstmanship", + category: "Craftsmanship", fileName: "10x-developer", author: "Natedeploys", }, + { + title: "Difference between statically and dynamically typed", + description: "Difference between statically and dynamically typed and also strongly typed and weakly typed", + category: "Craftsmanship", + fileName: "difference-between-statically-and-dynamically-typed", + author: "Endormi", + }, ], Node: [ { diff --git a/src/Markdowns/difference-between-statically-and-dynamically-typed.md b/src/Markdowns/difference-between-statically-and-dynamically-typed.md new file mode 100644 index 0000000..df33398 --- /dev/null +++ b/src/Markdowns/difference-between-statically-and-dynamically-typed.md @@ -0,0 +1,76 @@ +# The difference between statically and dynamically typed + +We will also be talking about the difference between strongly typed and weakly typed. + +## Statically Typed + +Statically typed languages do the type checking which is the process of verifying and enforcing the constraints of types at compile-time. +The process of verifying and enforcing the constraints of types meaning that variable types are static, so that once you declare a variable to a type, you can't change it. +It's because statically typing is associated with the variable rather than the value. + +Examples of Statically typed languages: C, C++ and Java. + +A quick example of statically typed: + +```Java +int a = 1; +a = "foo"; +``` + +This causes an error, because a is supposed to be an integer only. + +## Dynamically Typed + +Dynamically typed languages do the type checking at run-time which brings some performance cost. +In dynamically typed languages variables are dynamic, meaning you can change the value after you set the variable to a type. + +Examples of Dynamically typed: Python, JavaScript, Ruby and scripting languages. + +A quick example of dynamically typed: + +```python +a = 1 +a = "foo" +``` + +However doesn't give an error. + +### Strongly typed + +Python is a language that is dynamically typed and strongly typed. + +Here is a quick example of strong typing: + +```Python +a = 1 +b = "1" + +print(a + b) +``` + +This causes an concatenation error, because you can't add an integer and string together. + +In strongly typed languages a string containing only digits doesn't magically become a number. + +A quick example on how to fix the concatenation error: + +```Python +print(a + int(b)) +``` + +### Weakly typed + +In weakly typed languages you don't need to specify types, but the result might not be what you wanted, see the example below. + +JavaScript is dynamically typed and weakly typed. + +Here is a quick example of weak typing: + +```javascript +a = 1 +b = "1" + +console.log(a + b); +``` + +Doesn't cause an error and it actually gives 11.