What Is Code?
This question was asked to me on Quora. You can see the original here. Got a question yourself? Send me a question on Quora, or just a plain old email :-).
I really love questions like yours! It’s great to ask from time to time: “How does it work?”
Yes, a computer uses transistors. They form “flip flops”. A flip flop is a piece of hardware that can have two states: on and off. Applying current makes the flip flop switch. Placing a couple of them in line can let you execute sequential commands, because you can create multiple combinations of on-and-off switches. The clock inside a CPU (the thingy that pulses electrical current) makes the flip flops switch, really fast, so it can load up instructions and execute them. Simply put, that’s a computer: binary representations of state data, billions of times per second.
In basic terms, the “stack” of computer languages is this:
- Higher order language, such as Swift, gets compiled into:
- Assembly language, a instructional language for processors (like: add 1 to this registry, or move byte A to registry 42), gets translated to:
- Binary, the raw 0’s and 1’s the flipflops in the CPU process, consists of:
- Analog electrical currents, high and low, representing 1 and 0. This is where you start to see transistors. An iPhone 6 CPU has 2 billion transistors. These currents consist of:
- Electrons moving through a conducting wire. You can see the wire as a tube of marbles: push one in, and another comes out the other end.
Who’s Checking The Dentist’s Teeth?
A higher-order programming language like Swift gets compiled into assembly, and some other stuff, by a compiler program. That compiler program can be written in anything, really. Just like the dentist goes to another dentist to have their teeth cleaned, a compiler is written by another programmer in another language.
Also, programming languages can be interpreted. Instead of creating an independently runnable executable file, the language is fed into an interpreter, which in turn feeds it to the CPU. Closely related to the interpreter is the virtual machine, such as the Java VM, that mediates between the Java language and the hardware. In that way, you can write Java code once, then develop multiple VMs for different types of hardware (an Intel processor, or the tiny CPU in your washing machine), and still run the same code.
What Does Binary Look Like?
In essence, a binary code is just analog electrical current. As a programmer, you really don’t think about that, though. You can’t see it with a microscope, but if you were to run a binary current through an oscilloscope you’d see this:
(You can clearly see “on” and “off”, although there’s some leakage too.)
Down The Rabbit Hole
Imagine, that as I’m typing this, my fingers are causing the keyboard to send out electrical currents. They get picked up by some electronics, and ultimately hit the CPU. The CPU then informs the screen to put some pixels up there, in the form of letter characters. It also gets sent to a space in memory that stores the text I’m typing, as part of the HTML on the page. Then I hit submit…
The text gets sent over the internet, across routers and big fiber optics internet cables, to you. And then, it hits your CPU and your CPU…
It’s almost too much to think about. Thankfully, there’s a human at the other point of the line. Because in essence, computers are just a big bunch of marble pushers…
Join 11.000+ app developers and marketers
- Get a weekly curated list of app development tools, articles and resources in your inbox
- 10x your app installs with relevant App Store Optimization and app marketing strategies
- BONUS: Grab a free copy of the App Toolbox 2017 to supercharge your next app project
Most Popular Content
Got a killer app idea?
Grab the App Toolbox 2017 to learn how to save time building your app,
and how to 10x your app installs in the App Store. With the toolbox, you'll immediately know how to move forward to build better, more profitable apps.
Get The App Toolbox
and how to 10x your app installs in the App Store. With the toolbox, you'll immediately know how to move forward to build better, more profitable apps. Get The App Toolbox
Comments & Thoughts
On The Blog
My App List: Apps I Use To Be Fitter, Happier, More Productive
It's the list of apps, updated August 2015, of apps I use daily. It's true, these apps make me fitter, happier and more productive. Gems like IFTTT, Trello, and the good ol' notebook, it's all in here.
[MEGA POST] Best of Quora: Building Better, More Profitable Apps With Swift, App Store Optimization & Growth Hacking
"He who asks a question is a fool for five minutes; he who does not ask a question remains a fool forever." Make sure you're no one's fool by learning from the questions of others in this MEGA Best of Quora blog post.
What Are The Best Tips And Practices For Creating Mobile Apps?
When learning programming or design, where do you start? It’s tough as a beginner, knowing that there’s much to learn in so little time. And when you’ve learned a new topic, how do you know whether you’ve truly mastered it? To shed some light on learning how to create mobile apps, I’ve set out 9 different places to go, people to meet and tactics to keep in mind.