Why programming matters — and how come you should learn to code

Portion of the code used as an example in this post

“Hey! I have this awesome idea to make this simple app. Let’s do it together, you do the technical stuff and I handle the rest. We’ll split 50/50”.

Did this sound familiar to you? Maybe you or someone you know heard something similar. Perhaps a client or a friend told you that what they propose it’s a one-time opportunity and that you need to take it. This, while he/she has no more clue on the execution of the idea, than a trader trying to make money in the long term out of Bitcoin by mere speculation.

Is this person, asking for our help and ‘partnership’, someone with bad intentions? Probably not, but naive he/she is, as the idea by itself means nothing without its embodiment in this world of ours. The creator of Linux kernel, Linus Torvalds, said it himself “Talk is cheap. Show me the code”.

Programming is a tool to distill ideas into solid and tangible executions

You see, before writing a single line of code you need to analyze the domain in which you are operating. Floating ideas don’t compile (or are interpreted either). They need to be translated into ifs, fors, buttons, forms, etc.

When we, as programmers, start to think about ways to translate ideas into code, we create (implicitly or explicitly) two byproducts of software. The first one is technical validation. No matter how many computers you have, you will not solve the halting problem. No matter how responsive your website is, if your client doesn’t have an Internet connection to connect to it.

On the other hand, coding brings validation of the business itself. Being very important, specially for fresh projects where there isn’t an expert on the subject of the program you’re building.

By learning how to code, you start to realize that, that “simple app” may be not so simple after all. It enables you to recognize, before opening your favorite text editor, when you are facing another real world problem that would be easy to solve by programming it and when it will be too complex or expensive to tackle. Trust me, knowing this beforehand will save you a lot of time, effort, and relationships.

Enhance your problem solving abilities and abstractions creations

Execution in programming often leads to problem solving and the creation of abstractions that can be somewhat invisible to the day to day routine of a business.

This is because in the daily rush, you can adapt to the situation you have in front of you. You have the advantage of not having a bunch of routines compiled (or interpreted) in your head with limited courses of action like a program does.

In the following scenario you’ll see how, when creating a program, you will encounter new abstractions to explain certain things of the business.

A simple example would be a software made for a coffee shop, which needs to calculate the final amount per item they need to charge their customers including discounts when they apply.

Let’s say the discount scheme works as follows:

  • If a customer orders more than 10 orders of coffee, he/she gets 20% off.

Sure thing, we can code something like this in Javascript:

let coffeesOrdered = prompt("Please type the amount of ordered coffees");
let coffeePrice = 3;
let finalAmount = coffeesOrdered*coffeePrice;
if(coffeesOrdered > 10){
finalAmount = finalAmount - finalAmount*0.2;
}
alert("The final amount is " + finalAmount);

The users are happy with it, it may be basic, but it works. Later they start selling muffins and donuts at the shop. They want to:

  • Apply only a 10% discount on both donuts and muffins.
  • The discount on muffins will be triggered when customers buy more than 5 of them together.
  • The discount on donuts will be triggered when customers buy more than 8 of them together.

Eager to implement more features, we agree to implement them. We fire up the text editor and start coding with the following:

let muffinsOrdered = prompt(“Please type th…

Wait. This sounds familiar.

So let’s not repeat ourselves (DRY concept):

class ItemsRepository {
constructor(){
this.data = []
}

add(item){
this.data.push(item)
}

obtainItem(searchedName){
for(let index in this.data){
let currentItem = this.data[index];
if(currentItem.name === searchedName){
return currentItem;
}
}
return null;
}
}

class Item {
constructor(name,cost,discount,discountAmountNeeded){
this.cost = cost;
this.discount = discount;
this.discountAmountNeeded = discountAmountNeeded;
this.name = name;
}

finalPrice(amount){
let discount = 0;
if(amount >= this.discountAmountNeeded)
discount = this.discount;
return (this.cost - discount * this.cost) * amount;
}
}

let items = new ItemsRepository();

while(1){
let productNameInput = prompt("Please type a product name to calculate its final cost");
let product = items.obtainItem(productNameInput);

if(product !== null){
let productAmountInput = prompt("Please type a the amount of such product in the order");

let totalAmount = product.finalPrice(productAmountInput);
console.log("The final amount is ", totalAmount)
} else {
alert("The item doesn't exist, proceeding to create a new item");
let newProductCostInput = prompt("Please type a cost amount for the new item");
let newProductDiscountInput = prompt("Please type a discount amount for the new item");
let newProductDiscountAmountNeededInput = prompt("Please type an amount of items required to apply the discount");
let newProduct = new Item(productNameInput,
newProductCostInput,
newProductDiscountInput,
newProductDiscountAmountNeededInput);
items.add(newProduct)
alert("The item has been successfully created.");
}
}

Try this script

Whoa! That’s a lot of new code added!

At fist glance this code looks much more complex. However, much of the lines of code were added to specify an abstraction. The concept of an item, that was absent in the first example. We focused on the last example what we wanted to solve (the items, its costs and discounts) rather than the how.

Thanks to programming, we now know what attributes an item must have to solve this problem. The real item may have another properties like height and weight but since they are not relevant to the calculation of the discount we don’t take them into account. We can now treat muffins and cups of coffees in the same way, since they are both items.

This is great because if tomorrow we need to add a new item, we simply add it to the items array without having to rewrite a single variable.

Which brings me to the next point.

You can have massive impact from day one

It is in this very nature of scalability in programming,that lies the opportunity for us to grow exponentially.

Let me explain.

Certain kind of companies can only grow linearly, like mosts restaurants. If you want to expand your restaurant, you’ll need to open more tables, which requires more staff, food, electricity, and physical space. Your earning will grow pretty much at the same rate that they were growing before the expansion. Because of the greater volume, the earned volume may be bigger but so will be the expenses numbers.

Referring to the example of the coffee shop. Let’s say I upload that script to the web and start charging a monthly fee for owners to start using it. What costs do I have as a programmer to run the show? In this case, only the server in which the script will be running and my personal expenses to survive so I can puke code into my machine.

If my program becomes so popular that every coffee shop in town uses it, how much will my expenses vary?

Maybe staff dedicated to customer support will be required and I’ll need better servers but these costs won’t grow linearly but in a factor of x2, x5 or even x100 in a earning/costs ratio. Servers nowadays can cost as little as US$1.25 per month and an increase of 1000 new clients may not require another customer support staff. Meanwhile in a restaurant (not franchises), the new hired waitress and food required to make the meal and serve it are certains added costs.

Now add the fact that if you create web-based software, your public is the world. The same problems you tackle in Argentina, people in Taiwan can use it to simplify their process as well.

The opportunities are endless.

How do I start programming?

You are not alone in this journey.

Start small. Choose a programming language and find an online course to start programming (like this one). Once you understand what a if is, what’s the use of a class is, go personal.

Make a 7 day challenge, each day, create your own program. Stick to it. Do free work for the people you look upon, or an non-profit organization. Share your progress as this would help internalize your whole process of learning while helping our great community of programmers.

If you happen to be in Buenos Aires, Argentina in October, 2017, I’ll be giving a free introduction course as a professor of the Javascript 101 workshop. I’ll post updates of this when available on my Twitter account (which is below).

I’d love to hear your story of what your first program is going to be. I’m here to help.

I invite you to create. I invite you to program.

Twitter: @alekrumkamp