Dark Mode

Code is not code

Code is language
By
Published ~ 3 minutes read

Code is something you can see and read but can't understand. The whole point is to hide its real meaning in plain sight. It is coded. Code, that we use in programming is not hidden. You can read it, you can understand it, you can extend it. What we refer to as code is just a language.

A year into working as a programmer, I was deeply into optimization. I would spend hours on a program, optimizing it to the max even if it was to shave off a micro second. If you use JavaScript, then you know that performance is important. Interpreted code is slow by nature, but add to it the layer of the browser, the DOM, and under powered devices and it becomes even slower.

It is important to make sure the code you write in JavaScript is optimized to run as fast as possible in any given environment. And since the browser is tied to the internet, making sure your file is small makes it download faster. As a result, I started writing smaller files. Smaller not because they were better but because, who needs those long variable names anyway?

So this code:

(function(){
var spans = document.getElementsByTagName("span"),
titles = [];
for(var i = 0;i if (spans[i].className === "title"){
titles.push(spans[i]);
}
}
for(var i = 0;i titles[i].onclick = function(){
window.location.href = "#"+this.getAttributes("data-id");
};
}
})();

Becomes this (not recommended):

!function(d,u,s,r){
var a = d.getElementsByTagName(s),t = [],i,l = a.length;
for(i = 0;i (a[i].className === u)?t.push(a[i]):0;
}
l=t.length;
for(i = 0;i t[i].onclick = function(){d.location.href = "#"+this.getAttributes(r);};
}
}(document,"title","span","data-id");

The bottom one is shorter but very hard to read. It is the typical definition of code: it is obscure, not everyone can read it, but the compiler goes through it like butter.

The top one is much easier to maintain by humans. It is its own documentation without the need of comments. This is what programming languages are supposed to be, languages. They are easy to understand by both humans and computers. The code we write in our programs are the equivalent of words in the English language. Each word has a meaning, each sentence is a statement and all put together they describe instructions for the computer.

Cryptographers produce code. As coders, we write instructions in a language that both human and machine can understand.


Did you like this article? You can buy me a coffee.
Share your insightful comments here.

Join my newsletter

Follow me on Twitter, Spotify, or RSS Feed

On a related note, here are some interesting articles.

My solution is to run away ... at least for a moment

What do you do when you hit a wall? When you found a bug and you can't figure out how to fix it. You spend hours and hours in front of the screen and nothing seems to work. Sometimes this can be the worse nightmare for a programmer and putting more hours trying to fix it won't make a difference.

I cheated!

I had a hard time following the school program. Sitting down, watching a teacher with no confidence talk about things that are supposed to be exciting was not my idea of learning a new skill. I once read somewhere that in the United States education system, the motto is No child left behind. Here I was sitting down in class feeling left behind. I came to school to learn the minimum to be propelled into a career where I will be able to grow and never have to worry about bills, grocery price, or rent. But the professor was talking about "Java or JavaScript", then gave us code to copy and paste into a dot HTML file. None of this made sense to me.

Big O is for the interview only

I didn't know what Big O meant. At least not before I had worked many jobs and on many projects as a developer. I remember reading about it in school but I didn't see any use for it in a real world. If you are like me and never encountered it yet worked in the field, we are the lucky ones. It's hard to get passed any interviewer without having to encounter a question about it.

View all articles

Comments

There are no comments added yet.

Let's hear your thoughts

For my eyes only