At the heart of programming is a simple idea:
Input -> Processing -> Output
But between input and processing lies something more important, storage.
Before a computer can do anything useful with data, it must first store it somewhere. That “somewhere” is memory. And in programming, the way we interact with memory starts with one core concept:
Variables
Programming is just a way of communicating with a computer, telling it what to store, how to transform it, and what to return.
In this article, we’ll explore how two very different languages, Python and Go, handle the same idea: variables.
Variables: The First Mental Model
A variable is simply a named storage location in memory.
For example (What it does is):
- “store the number 10”
- “label it as x”
- “retrieve it later when needed”
Simple concept, but different languages implement it very differently.
And that’s where Python and Go start to diverge.
Python vs Go: Two Different Philosophies
Python and Go both allow you to store data in variables, but they were designed with different priorities:
- Python: flexibility and speed of writing code
- Go: structure, safety, and predictability
This difference shows up immediately in how variables are declared.
Dynamic vs Static Typing
Python (Dynamic Typing)
In Python, you don’t explicitly declare the type of a variable:
- x=10
Python automatically figures out the datatype at runtime.
This is called dynamic typing.
It gives you flexibility:
- You can reuse variables freely
- You don’t need to define types upfront
- It speeds up development
But the trade-off is that errors may only show up when the program runs.
Go (Static Typing)
In Go, you must define the type explicitly:
- var x int = 10
Once declared, the type cannot change.
So this is invalid:
- x = "hello" // error
This is called static typing.
It forces structure:
- Types are known before execution
- Errors are caught early (at compile time)
- Code is more predictable in large systems
Two Ways of Declaring Variables
Python keeps it simple:
- x = 10
That’s it. One way, one rule.
Go gives you two main approaches:
Explicit Declaration
- var x int = 10
### Short Declaration (Walrus-style feel)
- x := 10
The := operator tells Go:
“Infer the type automatically, but still lock it in permanently.”
So Go gives you convenience — but never sacrifices structure.
The Concept of “Nothing”
Another major difference is how both languages handle empty or uninitialized values.
Python: None
In Python, “no value” is represented explicitly:
- x = None
This means:
“This variable exists, but it currently holds nothing.”
It is very explicit and readable.
Go: Zero Values
Go does something different.
If you declare a variable but don’t assign a value, Go automatically gives it a default:
- var x int
- fmt.Println(x) // 0
So instead of null or None, Go uses zero values:
- int → 0
- string → ""
- bool → false
This design avoids uninitialized variables entirely.
While python thinks: “Let me give you freedom and decide later.” Go thinks: “Let me force clarity so you don’t make mistakes later.”
Even something as simple as variables reveals deep design philosophies:
- Python prioritizes developer speed and flexibility
- Go prioritizes safety and predictability
Both are correct, just optimized for different worlds:
- Python → scripting, AI, automation, rapid development
- Go → backend systems, scalability, performance-critical services.
Thanks for reading, what do you think about this? Read, like and comment.


Top comments (0)