<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">

 <title>Arbitree</title>
 <link href="//atom.xml" rel="self"/>
 <link href="//"/>
 <updated>2018-06-04T21:57:41+05:30</updated>
 <id>/</id>
 <author>
   <name></name>
   <email></email>
 </author>

 
 <entry>
   <title>But what *is* a program?</title>
   <link href="//2018/06/04/but-what-is-a-program.html"/>
   <updated>2018-06-04T00:00:00+05:30</updated>
   <id>//2018/06/04/but-what-is-a-program</id>
   <content type="html">&lt;p&gt;Look around you. What do you see? Well, people mostly. But also, an exponentially increasing lot of computers.
They’re everywhere. Almost in everything that runs on electricity. That’s good, and a bit frightening, but hey,
they help you a awful lot.&lt;/p&gt;

&lt;p&gt;But they’re dumb. Period. They can’t do one thing unless it is explicitly told to them.&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;Although, that thing is slowly changing now, but that is a whole other issue.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;So, what’s their secret sauce? What makes them so &lt;em&gt;helpful&lt;/em&gt;? And hey, why do we &lt;em&gt;need&lt;/em&gt; a computer
at all?&lt;/p&gt;

&lt;p&gt;Let’s start from the beginning.&lt;/p&gt;

&lt;h2 id=&quot;the-premise&quot;&gt;The Premise&lt;/h2&gt;

&lt;p&gt;We are already good at calculations. We don’t need external help of any kind to calculate &lt;code&gt;2 + 5&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Some may say that was way too easy. Fair enough. How about &lt;code&gt;11 x 13&lt;/code&gt;? That was a bit harder than the previous. 
But that was easy too. Let’s up the game.&lt;/p&gt;

&lt;p&gt;What is &lt;code&gt;132 x 462&lt;/code&gt;? This might take a minute to do by hand. But it is still doable.&lt;/p&gt;

&lt;p&gt;Alright then, what is &lt;code&gt;388126 x 481924&lt;/code&gt;? Things are getting tougher now, isn’t it? 
We can still do it, but imagine tens of them coming towards you at one second. You have to either be specially trained, or be a prodigy.&lt;/p&gt;

&lt;h2 id=&quot;the-problem&quot;&gt;The Problem&lt;/h2&gt;

&lt;p&gt;So, we can do mathematical calculations, we can even do some tough ones, but the problem is the majority of 
us will hit a roadblock if things start to get a bit large and speedy. 
I mean we could still do that, but by the time we’ll be finished with it, we’ll probably lose the value of 
the reason for which we started the calculation at first. 
So, we need a helping hand. 
We need some &lt;em&gt;thing&lt;/em&gt; that’ll do the calculations for us, and hopefully will be speedier than us too.&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;The reason we’re bothered about doing fast, efficient mathematical calculation is that everything can be 
expressed in mathematical terms, from having a &lt;a href=&quot;https://www.independent.co.uk/news/science/perfect-cheese-on-toast-if-bbread-ccheese-and-ttime-what-is-the-point-of-all-these-formulae-8773470.html&quot;&gt;perfect cheese on toast&lt;/a&gt;, to travelling to outer space.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2 id=&quot;the-initial-solution&quot;&gt;The (Initial) Solution&lt;/h2&gt;

&lt;p&gt;We are pretty good at making machines, and surely enough, we can jolt some bolts and wires to make some 
machines that’ll perform all the additions subtractions and multiplications for us. Consider 
we’ve done that, and we’ve built 4 machines :&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;&lt;strong&gt;MA&lt;/strong&gt; : The machine which carries instructions on how to perform addition of two numbers. 
The machine takes two integers, processes them, i.e. performs decimal addition, and gives back another integer, i.e. the sum, as result.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;MS&lt;/strong&gt; : The machine that knows how to subtract two integers. 
Like the addition machine, it takes in two integers, and gives back the difference as result.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;MM&lt;/strong&gt; : The machine that is soldered to multiply two integers. 
It takes input as previous, multiplies them, and returns back the result.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;MD&lt;/strong&gt; : The divider machine. Likewise, takes two integers, divides the first by the second, and returns back the result.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Our plan is ingenious, in so that it removes the hard task, the calculations, from us, and works like some 
magic wand which just joins two integers in whatever way it was made for to. 
They can, or particularly &lt;b&gt;MM&lt;/b&gt; can, breeze through the task of &lt;code&gt;388126 x 481924&lt;/code&gt; which previously had us sweats in palms.&lt;/p&gt;

&lt;p&gt;But hold on. How about mixed operations? &lt;code&gt;(4723381 + 9323940) x 882123&lt;/code&gt;? 
That might seem a bit odd, but all we have to do is get the result of &lt;code&gt;4723381 + 9323940&lt;/code&gt; 
from &lt;b&gt;MA&lt;/b&gt;, the addition machine, and feed it to the &lt;b&gt;MM&lt;/b&gt;, multiplication machine.&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;And that’s enough math for one day.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;When we do the calculation by hand, we still have to perform the exact three steps. 
But now we’re performing one. We have lessen the work by 66%, by we still have to intervene. We’re still &lt;em&gt;bottlenecking&lt;/em&gt;.&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;Bottleneck&lt;/p&gt;

  &lt;p&gt;&lt;em&gt;noun&lt;/em&gt;&lt;/p&gt;

  &lt;p&gt;a narrow section of road or a junction that impedes traffic flow.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Consider another scenario. We have to find the sine of a given angle. Our four machines do not do the job. 
So we invent a new one. And gradually we invent a hundred other for hundred different operations, 
and switch through them as we’re performing calculations. By doing so, we’re diminishing the performance 
gain that we were getting for simple calculations at first when the first four machines were introduced.&lt;/p&gt;

&lt;p&gt;Previously, we were lacking at processing the data. Now, the machines will sit idle most of the time, 
hence the usage of the total processing power at hand will be minimum, and most of the time we’ll just 
nervously switch from one machine to another.&lt;/p&gt;

&lt;h2 id=&quot;the-solution-20&quot;&gt;The Solution (2.0)&lt;/h2&gt;

&lt;p&gt;If you look closely, you’ll notice that the function that a machine performs, is bound by the set of instructions 
that were given to it &lt;em&gt;at the time of production&lt;/em&gt;. 
The instructions are the things that label a machine as &lt;em&gt;The addition machine&lt;/em&gt;, or &lt;em&gt;The multiplication machine&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;So how about building such a machine, which also takes the instructions as the input?&lt;/p&gt;

&lt;p&gt;Consider a generic machine, which has some fundamental operations built-in, but it does nothing by itself unless specified. 
When we want the machine to perform something on two integers, like previously, we give it two integers. 
But this time, we give it an &lt;em&gt;additional&lt;/em&gt; input, &lt;strong&gt;a sequential set of instructions&lt;/strong&gt; that tells it what 
exactly should it do with the given integers.&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;Although, to be honest, addition, subtraction, multiplication and
division are also some of the fundamental operations of a modern
computer. But you get the idea.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;We give it the data, and we give it the instructions on how to process the data alongside. 
We then build a general purpose computational device, or simply, a &lt;em&gt;computer&lt;/em&gt;.&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;Computer&lt;/p&gt;

  &lt;p&gt;&lt;em&gt;noun&lt;/em&gt;&lt;/p&gt;

  &lt;p&gt;an electronic device which is capable of receiving information (data) in a 
particular form and of performing a sequence of operations in accordance with 
a predetermined but variable set of procedural instructions (program) to produce a result in the form of information or signals.&lt;/p&gt;

  &lt;p&gt;(Phew. That was a bad idea.)&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Now let the idea sink in for a moment. We have a machine which takes the data as input, &lt;em&gt;as well as&lt;/em&gt; the 
instructions on how to process them. 
That sequential set of instructions are generally referred to as a &lt;em&gt;program&lt;/em&gt;, because it programs the device, i.e. controls its behaviour.&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;Program&lt;/p&gt;

  &lt;p&gt;&lt;em&gt;noun&lt;/em&gt;&lt;/p&gt;

  &lt;p&gt;a planned series of future events or performances.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;That solves our basic problem of having to maintain a larger array of specialized devices. 
When we want to perform a long operation using our new machine, at each step, we feed it the usual input, along with 
the instructions on processing them. And when they’re done, we collect the output from them.&lt;/p&gt;

&lt;p&gt;Still, we have to do one step at a time, since till now, we are the ones who are feeding the machine the inputs. 
We still will be limited by our capacity of feeding the machine, we still will bottleneck.&lt;/p&gt;

&lt;h2 id=&quot;the-semifinal-solution&quot;&gt;The (Semifinal) Solution&lt;/h2&gt;

&lt;p&gt;We are inching towards our goal of performing calculations as fast as possible, but we still can’t remove &lt;em&gt;us&lt;/em&gt; from 
the equation. Our new generic machine is now mostly perfect. It just requires some final touches.&lt;/p&gt;

&lt;p&gt;How about, we store all the steps that are need to be done along with the numbers on which the steps are to be performed 
&lt;em&gt;somewhere apriori to the calculation&lt;/em&gt;, and tell the &lt;b&gt;Processor&lt;/b&gt; (well of course, it processes everything) to fetch 
and process them &lt;em&gt;from there&lt;/em&gt; in its own time?&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;Processor&lt;/p&gt;

  &lt;p&gt;&lt;em&gt;noun&lt;/em&gt;&lt;/p&gt;

  &lt;p&gt;a machine that processes something.&lt;/p&gt;

  &lt;p&gt;(Mine was original, I swear.)&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;We just need to make the processor understand how to fetch them, which is not a problem, since we can tell it now &lt;em&gt;how to&lt;/em&gt; process 
a thing along with &lt;em&gt;what&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;That storage where the steps and inputs are apriori loaded, is known as the &lt;b&gt;Memory&lt;/b&gt;, since it helps the processor remember what to do next.&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;As you will see, the term &lt;em&gt;memory&lt;/em&gt; for computers is quite analogous to the
way we think about &lt;em&gt;memory of a human being&lt;/em&gt;. They only difference being
we know everything about the memory of a computer, i.e. how it can be stored
and retrieved, and almost nothing about the memory of a human being.
Quite ironical, isn’t it?&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;We will now load the numbers and steps that are to be performed on them in memory, turn the processor on, and collect the results from the 
memory when the processor is finished.&lt;/p&gt;

&lt;p&gt;The memory will be the bridge between us and the processor. 
It will be much faster than us, and we will still rip all the benefits that we are getting from a generic processor. 
If we want to add something, we will write the steps for addition, along with the numbers to add, load them into 
memory, and turn the processor on.&lt;/p&gt;

&lt;p&gt;And bam! We will get the result instantly (or however fast the first generational CPUs were).&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;There are a few different kind of memories that a computer can have,
ordered by the speed by which they can be accessed and the amount of
data they can store. Memory is costly, and hence the memory with
highest access speed usually has the least storage space.&lt;/p&gt;

  &lt;p&gt;Think of it in a humanly manner. The memories that we access frequently,
we don’t have to put a lot of pressure to bring them on. They just kind
of come out of us. But there are much less things that you need to
access from your memory in regular basis and in an intricate manner,
like the password of your bank account. They come in short bursts.&lt;/p&gt;

  &lt;p&gt;That awesome party that you went last time, you remember about it
for a longer duration, but you don’t remember all the intricate details
about it at all.&lt;/p&gt;

  &lt;p&gt;It’s important to priotize what to remember, and also what to
forget. Your brain does this for you when you sleep, a bit of
housekeeping, to clean out the junk of the day and keep the
most important and relevant bits of it stored in safe places.&lt;/p&gt;

  &lt;p&gt;A computer cannot just clean out your data. It’s &lt;em&gt;your&lt;/em&gt; data after
all. It has to decide what’s more important, what it has to 
recall very frequently, and move it to a faster storage so that
the recall operation itself takes less time, and it can concentrate
on actually processing the data. The data that was in the faster 
storage earlier would then get moved to the slower storage. 
A computer does this all the time, as &lt;em&gt;what is important&lt;/em&gt; changes 
quite frequently according to a particular context.&lt;/p&gt;

  &lt;p&gt;We’ll talk about it more, but for now, let’s come back to
the problem at hand - efficiently solving calculations as
fast as possible.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The machine we designed is still &lt;em&gt;not perfect&lt;/em&gt; though. 
In one sense that we have to specify &lt;em&gt;all&lt;/em&gt; the steps for addition &lt;em&gt;each time&lt;/em&gt; we want to add something, among others. 
That’ll increase both our efforts and the processors.&lt;/p&gt;

&lt;p&gt;So, what should be the remedy then?&lt;/p&gt;

&lt;p&gt;‘Till next time.&lt;/p&gt;

&lt;hr /&gt;
</content>
 </entry>
 
 <entry>
   <title>Initial Commit</title>
   <link href="//2018/06/03/initial-commit.html"/>
   <updated>2018-06-03T00:00:00+05:30</updated>
   <id>//2018/06/03/initial-commit</id>
   <content type="html">&lt;p&gt;I’ve always wanted a place where I can record my learnings in a human readable version, be it for my future self, or for any one of you.
I’ve fiddled with wordpress and friends before, but they never attracted me that much. I felt like I have less control over stuff. That was
a while ago.
I tried posting a bit of content to some popular websites out there, but all of them got rejected for not suiting their genre.
I also had a GitHub page intially, but left it for not having enough time at that time.&lt;/p&gt;

&lt;p&gt;Recently there is a huge trend of choosing GitLab over GitHub between people, and that has its fair share of reasons.
I don’t want to repeat them, but recently I started transitioning my projects to GitLab.
The only thing that it lacks is a good Android client IMO. The rest of the interface is pretty solid and modern, and
might be a bit more confusing to the newbies than GitHub.
Although I might have preferred a way to change the whole website interface to a darker theme, because its background is more
bright than GitHub, but I think it’s just me (is it really though?).&lt;/p&gt;

&lt;p&gt;Last night, after an hour or two, I finally managed to create a &lt;code class=&quot;highlighter-rouge&quot;&gt;GitLab page&lt;/code&gt;, and today this is the first post on it.
I have final exams tomorrow, and I can’t really think of a better way to rather spend my time on.&lt;/p&gt;

&lt;p&gt;So, that’s a lot of information. I will be posting anything new I learn in here from now on, and some general posts
to lessen the fear of programming among general people, which I have been planning to do for some time. Also, some random
posts will also make their way here, as you will expect from a random guy at the internet, and now that I think about it,
trying to categorize my future posts was really a bad idea to begin with.&lt;/p&gt;

&lt;p&gt;‘Till next time. :)&lt;/p&gt;

&lt;hr /&gt;
</content>
 </entry>
 

</feed>
