How programming came to the masses

Image for post
Image for post

Many people think that they could never be a programmer, that it’s too difficult and that they aren’t smart enough. But programming is getting easier. Today with the languages and tools we have, programming is more like explaining a task to a human than it is like instructing a computer.

The original difficulty of writing software came from computers only understanding binary. Imagine looking at binary such as this 010000010100001001000011 and trying to determine where one word ends and another begins(Those 24 ones and zeros represent abc). In the late 1940’s the first programming “language” was developed, called Assembly, to give humans a more native way to write software. Assembly improved on binary by creating a set of commands: add, mov, pop and others. These are a lot easier to understand than 00101110. This was one of the first major steps to making programming easier for people.

add eax ebx

This is an example line of Assembly. It tells the CPU to add two values together.

About ten years after the development of Assembly a new language came out that really rocked the computing world, Fortran. It was the first “high-level” language. High-level meaning that it’s getting closer to english and typically higher-level language are easier to program with. For the past 50 years the dominant languages C, Java and JavaScript have each improved upon their predecessor by making programming more like a spoken language for the programmer. Let’s take a look at an example.

(C code. Just skim through it, the purpose of this example is that it looks ugly)

int listenfd, connfd;
socklen_t clientlen;
struct sockaddr_in ip4addr;
struct sockaddr_storage clientaddr;
char client_hostname[MAXLINE], client_port[MAXLINE];if (argc != 2) {
fprintf(stderr, "usage: %s <port>\n", argv[0]);
exit(0);
}
ip4addr.sin_family = AF_INET;
ip4addr.sin_port = htons(atoi(argv[1]));
ip4addr.sin_addr.s_addr = INADDR_ANY;
if ((listenfd = socket(AF_INET, SOCK_STREAM, 0)) < 0){
perror("socket error");
exit(EXIT_FAILURE);
}
if (bind(listenfd, (struct sockaddr*)&ip4addr, sizeof(struct sockaddr_in)) < 0) {
close(listenfd);
perror("bind error");
exit(EXIT_FAILURE);
}
if (listen(listenfd, 100) < 0) {
close(listenfd);
perror("listen error");
exit(EXIT_FAILURE);
}

while (1) {
clientlen = sizeof(struct sockaddr_storage);
connfd = accept(listenfd, (struct sockaddr *)&clientaddr, &clientlen);
getnameinfo((struct sockaddr *) &clientaddr, clientlen,
client_hostname, MAXLINE,
client_port, MAXLINE, 0);
printf("Connected to (%s, %s)\n", client_hostname, client_port);
echo(connfd);
close(connfd);
}

These lines of code tell a computer to allow connections from other computers and to echo back any data it receives. I can explain in one sentence what this code does so why does it need to be 40 lines long? Wouldn’t it be better if programming that same functionality was just as easy as writing down “accept connections from other computers and send back to them whatever they send you”.

const express = require('express')
const app = express()
app.get('/', (request, response) => {response.send(request)})app.listen(80)

Echo server written in JavaScript

Now I know that these four lines of code probably still look pretty scary to someone who is unfamiliar with programming. But, they are exponentially easier to understand than the 40 lines of C above. The first two lines just import a tool we need. With this line of code we tell the computer “send back whatever is sent to you”. And the last line tells the computer “accept connections from other computers”.

In two lines of code we can explain to a computer what I would explain to a person in one sentence. How crazy is that! We can almost communicate to a computer as easily as we can to a person. I know that the syntax is foreign but syntax is learned easily. The above four lines of code contain almost all the ‘grammar’ that a developer needs on a daily basis. That’s a lot less than what I had to learn for the MCOM 320 grammar test.

Image for post
Image for post

So how useful are those lines of code? Well, they constitute a server. A server is a term that you may have heard tossed around before and bear with me, I’m going to use that term a lot in this paragraph. Servers have two parts: software and hardware. The code above is a server in the software sense. Everyday we interact with servers, they sit ready to answer questions, to “serve information”. Every time you navigate to a webpage you’re making a request to a server; every time you open instagram, you request your feed from a server and the server sends you the images and text that make up your feed. The internet is servers.

To show you the above server in action let's change this line of code

to this

If I run this server and then ask it for data using a web browser, we get back ‘hello world’, the string we just told the server to return.

Image for post
Image for post

This example is simple and a server that only can return the string ‘hello world’ isn’t very useful in real world applications. But, the server’s capability to respond to requests is a fundamental building block used to make awesome things like online gaming, messaging, shopping, and streaming.

Image for post
Image for post

How does that building block get translated into something like Spotify or Google? Remember that programming is a form of communication. Creating advanced software that companies like Spotify and Google use is like an author writing a book. The author spends many hours researching topics, gathering ideas, making outlines and planning how they can clearly and concisely convey their message. Once the author has given much forethought to their topic they write and revise the book many times until the book is ready to communicate the story or idea to an audience.

That same process of planning writing and revising is followed to write complex software. The only difference is that software conveys ideas to computers instead of people.

Conclusion

Programming is getting easier, so easy that without any knowledge of how computers function anyone can still create incredible software. I have studied computer science for three years, I have had two internships with Amazon, and I am just now learning how computers actually run software. Programming doesn’t require in-depth knowledge of how computers work, it’s just communicating, and anyone can do that.

If you’re interested in apps, games, design, artificial intelligence, automation or a slew of other things; you should try programming. I’m not saying you’ll like it, programming isn’t for everyone, but I hope that you now know that programming is just another form of communication and that you can learn to program just like you learned to speak.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store