SlideShare uma empresa Scribd logo
1 de 12
Static typing vs Dynamic Typing
languages
A paradigm of computer language, based on compiler’s and interpreter’s behavior
Do you know why these applications work so swiftly without giving errors for
the things that may happen but they don’t happen
Compiled vs. Interpreted
“When source code is translated”
 Source Code: Original code (usually typed by a human into a computer)
 Translation: Converting source code into something a computer can read (i.e. machine
code)
 Run-Time: Period when program is executing commands (after compilation, if
compiled)
 Compiled: Code translated before run-time
 Interpreted: Code translated on the fly, during execution
Typing
“When types are checked”
"3" + 5 will raise a type error in strongly typed languages, such as Python and Go, because they
don't allow for "type coercion": the ability for a value to change type implicitly in certain contexts
(e.g. merging two types using +). Weakly typed languages, such as JavaScript, won't throw a type
error (result: '35').
•Static: Types checked before run-time
•Dynamic: Types checked on the fly, during execution
Type-checking has nothing to do with the language being
compiled or interpreted! You need to separate these
terms conceptually.
Python Example (Dynamic, Interpreted)
def foo(a):
if a > 0:
print 'Hi'
else:
print "3" + 5
foo(2)
Because Python is both
interpreted and dynamically
typed, it only translates and
type-checks code it’s
executing on. The else block
never executes, so "3" + 5 is
never even looked at!
What if it was statically typed?
 A type error would be thrown before the code is even run. It still performs type-checking
before run-time even though it is interpreted.
What if it was compiled?
 A type error would be thrown before the code is even run. It still performs type-checking
before run-time even though it is interpreted.
Go Example (Static, Compiled)
package main
import ("fmt")
func foo(a int) {
if (a > 0) {
fmt.Println("Hi")
}
else {
fmt.Println("3" + 5)
}
}
func main() {
foo(2)
}
The types are checked before
running (static) and the type
error is immediately caught!
The types would still be checked before run-time
if it was interpreted, having the same result. If it
was dynamic, it wouldn’t throw any errors even
though the code would be looked at during
compilation.
Performance
 A compiled language will have better performance at run-time if it’s statically typed because the
knowledge of types allows for machine code optimization.
 Statically typed languages have better performance at run-time intrinsically due to not needing
to check types dynamically while executing (it checks before running).
 Similarly, compiled languages are faster at run time as the code has already been translated
instead of needing to “interpret”/translate it on the fly.
 Note that both compiled and statically typed languages will have a delay before running for
translation and type-checking, respectively.
Catching up Error
 Static typing catches errors early, instead of finding them during execution (especially useful for
long programs). It’s more “strict” in that it won’t allow for type errors anywhere in your program
and often prevents variables from changing types, which further defends against unintended
errors.
num = 2
num = '3' // ERROR
 Dynamic typing is more flexible (which some appreciate) but allows for variables to change types
(sometimes creating unexpected errors).
Dynamically Interpreted Languages
 AppleScript
 Erlang (compiled into Erlang bytecode and
interpreted by the BEAM VM)
 Elixir (runs on the Erlang VM)
 Java (is compiled into Java bytecode to be
interpreted by JVM)
 Clojure
 Groovy
 Kotlin
 ColdFusion
 Scala
 Lisp
 Lua
 Pike
 .NET Framework languages (translated to bytecode,
called CIL).
 C++/CLI
 C#
 Visual Basic .NET
 F#
 Python (compiled into Python bytecode and
interpreted by CPython)
 Squeak Smalltalk
 Visual FoxPro
https://hackernoon.com/i-finally-understand-static-vs-dynamic-typing-and-you-will-too-ad0c2bd0acc7
End Note
It all depends upon the compiler that compiles the script.

Mais conteúdo relacionado

Mais procurados

Mais procurados (20)

[OOP - Lec 19] Static Member Functions
[OOP - Lec 19] Static Member Functions[OOP - Lec 19] Static Member Functions
[OOP - Lec 19] Static Member Functions
 
Operators and expressions in c language
Operators and expressions in c languageOperators and expressions in c language
Operators and expressions in c language
 
class and objects
class and objectsclass and objects
class and objects
 
Data types in C
Data types in CData types in C
Data types in C
 
functions of C++
functions of C++functions of C++
functions of C++
 
Introduction to Java Programming
Introduction to Java ProgrammingIntroduction to Java Programming
Introduction to Java Programming
 
Introduction to c programming
Introduction to c programmingIntroduction to c programming
Introduction to c programming
 
C++ Language
C++ LanguageC++ Language
C++ Language
 
Introduction to c++ ppt 1
Introduction to c++ ppt 1Introduction to c++ ppt 1
Introduction to c++ ppt 1
 
Functions in C
Functions in CFunctions in C
Functions in C
 
Programming in ansi C by Balaguruswami
Programming in ansi C by BalaguruswamiProgramming in ansi C by Balaguruswami
Programming in ansi C by Balaguruswami
 
Introduction to Input/Output Functions in C
Introduction to Input/Output Functions in CIntroduction to Input/Output Functions in C
Introduction to Input/Output Functions in C
 
Type conversion
Type conversionType conversion
Type conversion
 
Python basic
Python basicPython basic
Python basic
 
Control statements in java
Control statements in javaControl statements in java
Control statements in java
 
Object Oriented Programming Using C++
Object Oriented Programming Using C++Object Oriented Programming Using C++
Object Oriented Programming Using C++
 
Operators in c programming
Operators in c programmingOperators in c programming
Operators in c programming
 
Operators in C++
Operators in C++Operators in C++
Operators in C++
 
Array in c++
Array in c++Array in c++
Array in c++
 
Operators in java
Operators in javaOperators in java
Operators in java
 

Semelhante a Static typing vs dynamic typing languages

Programming Paradigm & Languages
Programming Paradigm & LanguagesProgramming Paradigm & Languages
Programming Paradigm & LanguagesGaditek
 
Programming Paradigm & Languages
Programming Paradigm & LanguagesProgramming Paradigm & Languages
Programming Paradigm & LanguagesGaditek
 
Lecture 1 introduction to language processors
Lecture 1  introduction to language processorsLecture 1  introduction to language processors
Lecture 1 introduction to language processorsRebaz Najeeb
 
1.Overview of Programming.pptx
1.Overview of Programming.pptx1.Overview of Programming.pptx
1.Overview of Programming.pptxVishwas459764
 
unit1pdf__2021_12_14_12_37_34.pdf
unit1pdf__2021_12_14_12_37_34.pdfunit1pdf__2021_12_14_12_37_34.pdf
unit1pdf__2021_12_14_12_37_34.pdfDrIsikoIsaac
 
Chapter1pdf__2021_11_23_10_53_20.pdf
Chapter1pdf__2021_11_23_10_53_20.pdfChapter1pdf__2021_11_23_10_53_20.pdf
Chapter1pdf__2021_11_23_10_53_20.pdfDrIsikoIsaac
 
Language translators
Language translatorsLanguage translators
Language translatorsAditya Sharat
 
Lecture1 compilers
Lecture1 compilersLecture1 compilers
Lecture1 compilersAftab Ahmad
 
Go language presentation
Go language presentationGo language presentation
Go language presentationparamisoft
 
Insight into progam execution ppt
Insight into progam execution pptInsight into progam execution ppt
Insight into progam execution pptKeerty Smile
 
Chapter 2 Program language translation.pptx
Chapter 2 Program language translation.pptxChapter 2 Program language translation.pptx
Chapter 2 Program language translation.pptxdawod yimer
 
La 5 Pl Translator
La 5   Pl TranslatorLa 5   Pl Translator
La 5 Pl TranslatorCma Mohd
 
Compiler_Lecture1.pdf
Compiler_Lecture1.pdfCompiler_Lecture1.pdf
Compiler_Lecture1.pdfAkarTaher
 
Compiler an overview
Compiler  an overviewCompiler  an overview
Compiler an overviewamudha arul
 
COMPILER CONSTRUCTION KU 1.pptx
COMPILER CONSTRUCTION KU 1.pptxCOMPILER CONSTRUCTION KU 1.pptx
COMPILER CONSTRUCTION KU 1.pptxRossy719186
 
Phases of Compiler.pptx
Phases of Compiler.pptxPhases of Compiler.pptx
Phases of Compiler.pptxssuser3b4934
 

Semelhante a Static typing vs dynamic typing languages (20)

Ic lecture8
Ic lecture8 Ic lecture8
Ic lecture8
 
How a Compiler Works ?
How a Compiler Works ?How a Compiler Works ?
How a Compiler Works ?
 
Programming Paradigm & Languages
Programming Paradigm & LanguagesProgramming Paradigm & Languages
Programming Paradigm & Languages
 
Programming Paradigm & Languages
Programming Paradigm & LanguagesProgramming Paradigm & Languages
Programming Paradigm & Languages
 
Lecture 1 introduction to language processors
Lecture 1  introduction to language processorsLecture 1  introduction to language processors
Lecture 1 introduction to language processors
 
3.2
3.23.2
3.2
 
1.Overview of Programming.pptx
1.Overview of Programming.pptx1.Overview of Programming.pptx
1.Overview of Programming.pptx
 
unit1pdf__2021_12_14_12_37_34.pdf
unit1pdf__2021_12_14_12_37_34.pdfunit1pdf__2021_12_14_12_37_34.pdf
unit1pdf__2021_12_14_12_37_34.pdf
 
Chapter1pdf__2021_11_23_10_53_20.pdf
Chapter1pdf__2021_11_23_10_53_20.pdfChapter1pdf__2021_11_23_10_53_20.pdf
Chapter1pdf__2021_11_23_10_53_20.pdf
 
Language translators
Language translatorsLanguage translators
Language translators
 
Lecture1 compilers
Lecture1 compilersLecture1 compilers
Lecture1 compilers
 
Go language presentation
Go language presentationGo language presentation
Go language presentation
 
1._Introduction_.pptx
1._Introduction_.pptx1._Introduction_.pptx
1._Introduction_.pptx
 
Insight into progam execution ppt
Insight into progam execution pptInsight into progam execution ppt
Insight into progam execution ppt
 
Chapter 2 Program language translation.pptx
Chapter 2 Program language translation.pptxChapter 2 Program language translation.pptx
Chapter 2 Program language translation.pptx
 
La 5 Pl Translator
La 5   Pl TranslatorLa 5   Pl Translator
La 5 Pl Translator
 
Compiler_Lecture1.pdf
Compiler_Lecture1.pdfCompiler_Lecture1.pdf
Compiler_Lecture1.pdf
 
Compiler an overview
Compiler  an overviewCompiler  an overview
Compiler an overview
 
COMPILER CONSTRUCTION KU 1.pptx
COMPILER CONSTRUCTION KU 1.pptxCOMPILER CONSTRUCTION KU 1.pptx
COMPILER CONSTRUCTION KU 1.pptx
 
Phases of Compiler.pptx
Phases of Compiler.pptxPhases of Compiler.pptx
Phases of Compiler.pptx
 

Mais de Jawad Khan

2.1 input and output in c
2.1 input and output in c2.1 input and output in c
2.1 input and output in cJawad Khan
 
2.2 variable arithmetics and logics
2.2 variable arithmetics and logics2.2 variable arithmetics and logics
2.2 variable arithmetics and logicsJawad Khan
 
1.2 programming fundamentals
1.2 programming fundamentals1.2 programming fundamentals
1.2 programming fundamentalsJawad Khan
 
1.1 programming fundamentals
1.1 programming fundamentals1.1 programming fundamentals
1.1 programming fundamentalsJawad Khan
 
7 8. emi - analog instruments and digital instruments
7 8. emi - analog instruments and digital instruments7 8. emi - analog instruments and digital instruments
7 8. emi - analog instruments and digital instrumentsJawad Khan
 
6. emi instrument transformers (with marking)
6. emi   instrument transformers (with marking)6. emi   instrument transformers (with marking)
6. emi instrument transformers (with marking)Jawad Khan
 
5 emi ac bridges (with marking)
5 emi  ac bridges (with marking)5 emi  ac bridges (with marking)
5 emi ac bridges (with marking)Jawad Khan
 
4. emi potentiometer and ac bridges
4. emi  potentiometer and ac bridges4. emi  potentiometer and ac bridges
4. emi potentiometer and ac bridgesJawad Khan
 
3 .emi wattmeter and energy meter
3 .emi   wattmeter and energy meter3 .emi   wattmeter and energy meter
3 .emi wattmeter and energy meterJawad Khan
 
2. emi analog electromechanical instruments
2. emi  analog electromechanical instruments2. emi  analog electromechanical instruments
2. emi analog electromechanical instrumentsJawad Khan
 
1. emi concept of measurement system
1. emi   concept of measurement system1. emi   concept of measurement system
1. emi concept of measurement systemJawad Khan
 
Varibale frequency response lecturer 2 - audio+
Varibale frequency response   lecturer 2 - audio+Varibale frequency response   lecturer 2 - audio+
Varibale frequency response lecturer 2 - audio+Jawad Khan
 
Variable frequency response lecture 3 - audio
Variable frequency response   lecture 3 - audioVariable frequency response   lecture 3 - audio
Variable frequency response lecture 3 - audioJawad Khan
 
Varibale frequency response lecturer 1 - audio
Varibale frequency response   lecturer 1 - audioVaribale frequency response   lecturer 1 - audio
Varibale frequency response lecturer 1 - audioJawad Khan
 
Two port network - part 3
Two port network - part 3Two port network - part 3
Two port network - part 3Jawad Khan
 
Two port network - part 2
Two port network - part 2Two port network - part 2
Two port network - part 2Jawad Khan
 
Two port network - part 1
Two port network - part 1Two port network - part 1
Two port network - part 1Jawad Khan
 
4. ideal transformer and load conversion
4. ideal transformer and load conversion4. ideal transformer and load conversion
4. ideal transformer and load conversionJawad Khan
 
3. magnetic coupled circuits examples
3. magnetic coupled circuits examples3. magnetic coupled circuits examples
3. magnetic coupled circuits examplesJawad Khan
 
2. magnetic coupled circuits
2. magnetic coupled circuits2. magnetic coupled circuits
2. magnetic coupled circuitsJawad Khan
 

Mais de Jawad Khan (20)

2.1 input and output in c
2.1 input and output in c2.1 input and output in c
2.1 input and output in c
 
2.2 variable arithmetics and logics
2.2 variable arithmetics and logics2.2 variable arithmetics and logics
2.2 variable arithmetics and logics
 
1.2 programming fundamentals
1.2 programming fundamentals1.2 programming fundamentals
1.2 programming fundamentals
 
1.1 programming fundamentals
1.1 programming fundamentals1.1 programming fundamentals
1.1 programming fundamentals
 
7 8. emi - analog instruments and digital instruments
7 8. emi - analog instruments and digital instruments7 8. emi - analog instruments and digital instruments
7 8. emi - analog instruments and digital instruments
 
6. emi instrument transformers (with marking)
6. emi   instrument transformers (with marking)6. emi   instrument transformers (with marking)
6. emi instrument transformers (with marking)
 
5 emi ac bridges (with marking)
5 emi  ac bridges (with marking)5 emi  ac bridges (with marking)
5 emi ac bridges (with marking)
 
4. emi potentiometer and ac bridges
4. emi  potentiometer and ac bridges4. emi  potentiometer and ac bridges
4. emi potentiometer and ac bridges
 
3 .emi wattmeter and energy meter
3 .emi   wattmeter and energy meter3 .emi   wattmeter and energy meter
3 .emi wattmeter and energy meter
 
2. emi analog electromechanical instruments
2. emi  analog electromechanical instruments2. emi  analog electromechanical instruments
2. emi analog electromechanical instruments
 
1. emi concept of measurement system
1. emi   concept of measurement system1. emi   concept of measurement system
1. emi concept of measurement system
 
Varibale frequency response lecturer 2 - audio+
Varibale frequency response   lecturer 2 - audio+Varibale frequency response   lecturer 2 - audio+
Varibale frequency response lecturer 2 - audio+
 
Variable frequency response lecture 3 - audio
Variable frequency response   lecture 3 - audioVariable frequency response   lecture 3 - audio
Variable frequency response lecture 3 - audio
 
Varibale frequency response lecturer 1 - audio
Varibale frequency response   lecturer 1 - audioVaribale frequency response   lecturer 1 - audio
Varibale frequency response lecturer 1 - audio
 
Two port network - part 3
Two port network - part 3Two port network - part 3
Two port network - part 3
 
Two port network - part 2
Two port network - part 2Two port network - part 2
Two port network - part 2
 
Two port network - part 1
Two port network - part 1Two port network - part 1
Two port network - part 1
 
4. ideal transformer and load conversion
4. ideal transformer and load conversion4. ideal transformer and load conversion
4. ideal transformer and load conversion
 
3. magnetic coupled circuits examples
3. magnetic coupled circuits examples3. magnetic coupled circuits examples
3. magnetic coupled circuits examples
 
2. magnetic coupled circuits
2. magnetic coupled circuits2. magnetic coupled circuits
2. magnetic coupled circuits
 

Último

10 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 202410 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 2024Mind IT Systems
 
Exploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdfExploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdfproinshot.com
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providermohitmore19
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension AidPhilip Schwarz
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfkalichargn70th171
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...Health
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplatePresentation.STUDIO
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...harshavardhanraghave
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsJhone kinadey
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsArshad QA
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️Delhi Call girls
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsAlberto González Trastoy
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionSolGuruz
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerThousandEyes
 
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfintroduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfVishalKumarJha10
 
Define the academic and professional writing..pdf
Define the academic and professional writing..pdfDefine the academic and professional writing..pdf
Define the academic and professional writing..pdfPearlKirahMaeRagusta1
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️Delhi Call girls
 

Último (20)

10 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 202410 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 2024
 
Exploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdfExploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdf
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS LiveVip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation Template
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with Precision
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
 
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfintroduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
 
Define the academic and professional writing..pdf
Define the academic and professional writing..pdfDefine the academic and professional writing..pdf
Define the academic and professional writing..pdf
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 

Static typing vs dynamic typing languages

  • 1. Static typing vs Dynamic Typing languages A paradigm of computer language, based on compiler’s and interpreter’s behavior
  • 2. Do you know why these applications work so swiftly without giving errors for the things that may happen but they don’t happen
  • 3. Compiled vs. Interpreted “When source code is translated”  Source Code: Original code (usually typed by a human into a computer)  Translation: Converting source code into something a computer can read (i.e. machine code)  Run-Time: Period when program is executing commands (after compilation, if compiled)  Compiled: Code translated before run-time  Interpreted: Code translated on the fly, during execution
  • 4. Typing “When types are checked” "3" + 5 will raise a type error in strongly typed languages, such as Python and Go, because they don't allow for "type coercion": the ability for a value to change type implicitly in certain contexts (e.g. merging two types using +). Weakly typed languages, such as JavaScript, won't throw a type error (result: '35'). •Static: Types checked before run-time •Dynamic: Types checked on the fly, during execution
  • 5. Type-checking has nothing to do with the language being compiled or interpreted! You need to separate these terms conceptually.
  • 6. Python Example (Dynamic, Interpreted) def foo(a): if a > 0: print 'Hi' else: print "3" + 5 foo(2) Because Python is both interpreted and dynamically typed, it only translates and type-checks code it’s executing on. The else block never executes, so "3" + 5 is never even looked at!
  • 7. What if it was statically typed?  A type error would be thrown before the code is even run. It still performs type-checking before run-time even though it is interpreted. What if it was compiled?  A type error would be thrown before the code is even run. It still performs type-checking before run-time even though it is interpreted.
  • 8. Go Example (Static, Compiled) package main import ("fmt") func foo(a int) { if (a > 0) { fmt.Println("Hi") } else { fmt.Println("3" + 5) } } func main() { foo(2) } The types are checked before running (static) and the type error is immediately caught! The types would still be checked before run-time if it was interpreted, having the same result. If it was dynamic, it wouldn’t throw any errors even though the code would be looked at during compilation.
  • 9. Performance  A compiled language will have better performance at run-time if it’s statically typed because the knowledge of types allows for machine code optimization.  Statically typed languages have better performance at run-time intrinsically due to not needing to check types dynamically while executing (it checks before running).  Similarly, compiled languages are faster at run time as the code has already been translated instead of needing to “interpret”/translate it on the fly.  Note that both compiled and statically typed languages will have a delay before running for translation and type-checking, respectively.
  • 10. Catching up Error  Static typing catches errors early, instead of finding them during execution (especially useful for long programs). It’s more “strict” in that it won’t allow for type errors anywhere in your program and often prevents variables from changing types, which further defends against unintended errors. num = 2 num = '3' // ERROR  Dynamic typing is more flexible (which some appreciate) but allows for variables to change types (sometimes creating unexpected errors).
  • 11. Dynamically Interpreted Languages  AppleScript  Erlang (compiled into Erlang bytecode and interpreted by the BEAM VM)  Elixir (runs on the Erlang VM)  Java (is compiled into Java bytecode to be interpreted by JVM)  Clojure  Groovy  Kotlin  ColdFusion  Scala  Lisp  Lua  Pike  .NET Framework languages (translated to bytecode, called CIL).  C++/CLI  C#  Visual Basic .NET  F#  Python (compiled into Python bytecode and interpreted by CPython)  Squeak Smalltalk  Visual FoxPro https://hackernoon.com/i-finally-understand-static-vs-dynamic-typing-and-you-will-too-ad0c2bd0acc7
  • 12. End Note It all depends upon the compiler that compiles the script.