Implicit vs Explicit Typing

Python variables do not need explicit declaration to reserve memory space. 

Here I will:
  • Describe the difference between explicit typed variables and implicit typed variables using examples.
  • In large scale applications, explain whether or not explicit declaration has a better impact over implicit declaration.

Type expression can be either explicit or implicit. 

  • Explicit typed variables are manually set. That is their type is stated clearly and in detail.
  • Implicit typed variables are typed by their context. 

Is there any performance difference?

Strictly speaking, there shouldn't be much (if any) performance difference when it comes to the use of implicit declaration vs explicit declaration in large scale applications.
The key is that variables don't have types, per se - values do. In Python, variables aren't so much declared (as in other languages), rather variables are assigned a name. 
  • If I were to say myint = 5, then I should be able to infer pretty easily that x is an int. 
  • Similarly, myfloat = 2.0 is quite clearly a floating point number. 
  • And mystring = "I'm a string" is quite clearly a string. 

With all that said...

I've always been under the impression that explicit typing lends itself toward easier maintainability of code, which is important when the majority of the work done on code is maintenance. 
Honestly, I think this will be my first time grappling with a dynamically typed language and the paradigm shift is...interesting. 

What are your thoughts?



0 Comments:

Post a Comment