<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Sampath Balivada - Blog]]></title><description><![CDATA[Building intuitive and engaging (customer, developer, user, visual) experiences.]]></description><link>https://blog.sampath.dev</link><generator>RSS for Node</generator><lastBuildDate>Wed, 13 May 2026 07:01:46 GMT</lastBuildDate><atom:link href="https://blog.sampath.dev/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[Scalability, Reliability and Maintainability [Tenglish]]]></title><description><![CDATA[Note: This article is written in Telugu. This might look like English but it reads like Telugu.

Reliability, Scalability, Maintainability, Fault-tolerance, Security, Load, Bottleneck, Performance, Throughput, Response Time, p50, p90, p95, p99, p999,...]]></description><link>https://blog.sampath.dev/scalability-reliability-and-maintainability-tenglish</link><guid isPermaLink="true">https://blog.sampath.dev/scalability-reliability-and-maintainability-tenglish</guid><category><![CDATA[System Design]]></category><dc:creator><![CDATA[Sampath Balivada]]></dc:creator><pubDate>Sun, 28 Sep 2025 17:18:26 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1759079554176/86761c98-abd6-4c0a-a763-cb7578149542.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p><em>Note: This article is written in Telugu. This might look like English but it reads like Telugu.</em></p>
<blockquote>
<p>Reliability, Scalability, Maintainability, Fault-tolerance, Security, Load, Bottleneck, Performance, Throughput, Response Time, p50, p90, p95, p99, p999, SLA, SLO, Contracts, Scale-up, Scale-out, Distributed load, Stateless, Stateful, Load parameters, Operability, Health monitor, Accidental Complexity, Abstraction, Evolvability, Agility, Refactoring.</p>
</blockquote>
<p>Uffff…. Orey engineeru.<br />Jeevitam lo eppudain veeti anniti gurinchi aalochinchav entra?</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1759077283490/e750bab3-f7b6-42ff-9e95-0aa2ab7cbb18.jpeg" alt="Sagatu software mutyam after seeing these terms" class="image--center mx-auto" /></p>
<p><strong>PR raise chesama. Team lead okay annada. Reviewer merge chesada.</strong><br /><em>- ide kada ammai nuvvu chesedi?</em></p>
<h2 id="heading-konchem-kochem-chuddam">Konchem kochem chuddam</h2>
<p>Some basics of a good system. See these as the 3 sides of a triangle. You can only call it a triangle if it has 3 sides and 3 vertices. <em>(Kalupu… geetalu geesi vadileyka)</em></p>
<p><strong>Reliability:</strong> Yenda vachina.. vaanochina system saavakudadu. Pani cheseyali.<br /><strong>Scalability:</strong> Responding to change in load should be verrrrryy reasonable<br /><strong>Maintainability:</strong> Pani chese prati odiki abba SaiRam anipinchali</p>
<h2 id="heading-reliability">Reliability</h2>
<blockquote>
<p>Continuing to work correctly, even when things go wrong.</p>
</blockquote>
<p>Generally speaking, when you say a system is reliable, it usually means that it is tolerant to faults to a certain degree.</p>
<p>Edaina teda kottadanni <strong>fault</strong> anukunte. Teda kottina pani chesinappudu <strong>fault tolerant</strong> antam.</p>
<p>Indulo rakalu untai amma.</p>
<ol>
<li><p>Infrastructure (Hardware) faults <em>(mostly ni tappu em ledu ammai)</em></p>
</li>
<li><p>Software faults <em>(ade.. nuvvu ninna vadilesina NULL pointer eh)</em></p>
</li>
<li><p>Human faults <em>(debba mida debba)</em></p>
</li>
</ol>
<p>Aite fault is not the same as a failure.</p>
<p><strong>Fault</strong> <strong>-</strong> Oka part of the system, specification nunchi deviate ayyindi<br /><strong>Failure</strong> <strong>-</strong> Mottam system eh bucket tannesindi</p>
<p>We generally prefer tolerating faults over preventing faults… Kani security vishayam lo idi cheste fruit aipotav bidda.</p>
<p><strong><em>Summary:</em></strong> <em>Fault-tolerance can hide certain types of faults from the end user.</em></p>
<h2 id="heading-scalability">Scalability</h2>
<blockquote>
<p>Load perigite tattukuntada ni system?</p>
</blockquote>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1759078418627/ad7162a3-4248-4da3-8513-be58b81c40c1.jpeg" alt class="image--center mx-auto" /></p>
<p>Aha.. ala kaadu bhaiah nuvvu VMs add chesestav sare. But ave enduku ani doubt.</p>
<h3 id="heading-step-1-define-what-is-load-in-your-system"><strong>Step 1: Define what is Load in your system</strong></h3>
<blockquote>
<p>Load is basically calculated on the bottleneck of the system.</p>
</blockquote>
<p>Bottleneck batti cheptam asalu scalable ah? Scale cheste ela cheyyali ani.</p>
<h3 id="heading-step-2-then-define-performance"><strong>Step 2: Then define performance</strong></h3>
<blockquote>
<p>Asalu ni system ki em avasaram? What does performance mean to your system?</p>
</blockquote>
<p>For instance,<br />Batch Processing - Throughput avasaram<br />Online Services - Response Time avasaram</p>
<h3 id="heading-step-3-coping-with-load"><strong>Step 3: Coping with Load</strong></h3>
<blockquote>
<p>Scale-up or Scale-out and what exactly are you scaling?</p>
</blockquote>
<p>Neeku extra compute kavala? Storage kavala? Memory kavala?</p>
<p>Gurtu pettuko</p>
<blockquote>
<p>There’s is no <strong><em>magic scaling sauce</em></strong></p>
</blockquote>
<p>So ni system ki em kavalo telusukoni adi ichey.</p>
<p><strong><em>Summary:</em></strong> <em>An architecture is designed around that system’s</em> <strong><em>load parameters</em></strong></p>
<h2 id="heading-maintainability"><strong>Maintainability</strong></h2>
<blockquote>
<p>“Telugu bhasha lo naaku nachani oke okka padam” type stuff idi</p>
</blockquote>
<p>Is it maintainable ante manaki ardham avvadu kabatti. Inka divide cheddam. Single person maintain cheste avvadu ga. Chala mandi unnaru.</p>
<p><strong>Operability: Operations team ki chiraku teppinchaka</strong></p>
<p><strong>Simplicity: Kotta mutyam vaste prashantata undali aadiki</strong></p>
<p><strong>Evolvability: konchem flexible ga undela cheyyu. Repu poddunne okadu vachi naaku inko feature kavali antadu</strong></p>
<h2 id="heading-conclusion">Conclusion</h2>
<p>Okati pattukunte inkokati vadalaku.</p>
<blockquote>
<p><strong>Just like, life, career and passion.</strong> Edi vadilesina mana jeevitaniki ardham undadu.</p>
</blockquote>
<p><strong>Most importantly… ratri sariki ni system bratiki undadu.</strong></p>
]]></content:encoded></item><item><title><![CDATA[What Went Down in the First Class]]></title><description><![CDATA[It was definitely a fun filled session with Dr. V. Sankaran.
For starters. I started taking this course from IITM Pravartak on Applied Database Systems Engineering. This series will include the learnings, thoughts and experiences from the course.
Lin...]]></description><link>https://blog.sampath.dev/what-went-down-in-the-first-class</link><guid isPermaLink="true">https://blog.sampath.dev/what-went-down-in-the-first-class</guid><category><![CDATA[Linux]]></category><category><![CDATA[Kernel]]></category><category><![CDATA[Databases]]></category><dc:creator><![CDATA[Sampath Balivada]]></dc:creator><pubDate>Tue, 06 May 2025 12:46:37 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1746533391606/4e5accb1-e286-499f-9942-f7c326bb1e3f.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>It was definitely a fun filled session with <strong>Dr. V. Sankaran</strong>.</p>
<p>For starters. I started taking this course from IITM Pravartak on <strong>Applied Database Systems Engineering</strong>. This series will include the learnings, thoughts and experiences from the course.</p>
<p>Link: <a target="_blank" href="https://iitmpravartak.org.in/ADSE">https://iitmpravartak.org.in/ADSE</a></p>
<h2 id="heading-what-went-down">What went down?</h2>
<p>A little bit of philosophy along with a whole lot of linux. While we were deep into the ocean of processes a linux system has to handle, I was enlightened by this phrase.</p>
<blockquote>
<h3 id="heading-everything-has-a-priority-and-everyone-has-a-preference">Everything has a priority and everyone has a preference.</h3>
</blockquote>
<p>That hit hard. But don't worry I'm not going to be your philosophical friend today.</p>
<p>So processes have both a <strong>priority</strong> and a <strong>preference</strong>. Just because a process has a higher priority doesn't mean it will get to run first. The kernel has a preference.</p>
<p>For instance, a process with <strong>High Computation</strong> requirement can have a <strong>higher priority</strong> but the kernel will likely choose to give CPU time to a smaller process like a <strong>print job</strong> with <strong>lower priority</strong>.</p>
<p><em>No, the printer didn’t bribe the kernel.</em></p>
<p>This is because running the print job will only take a very small time on the microprocessor and hence, the kernel (essentially the scheduler) will have one less process to take care of in the process queue.</p>
<p>It’s not all black or white but linux tries to be <a target="_blank" href="https://docs.kernel.org/scheduler/sched-design-CFS.html">fair</a> here.</p>
<p>Oh! to be very clear, when and for what time a process gets to use the microcontroller is determined by 3 values: <strong>Preference, Realtime Priority and Nice Priority</strong>.</p>
<p>And…</p>
<p>That’s all lads. That was the first class. I swear Dr. Sankaran’s class was way more fun than what you just read.</p>
<p>We then went on to understand what the course will offer and the details about how we are going to play around with the linux kernel and kernel modules. Oh! I might need to brush up my C language. Every ounce of code that we write in this class will be in C. Okay, I am excited!</p>
<p>Sure then, I’ll be back after the next class to share what I’ve learned. Until then, <strong>happy hacking</strong>.</p>
<p><em>Quick Note: some of the keywords used above may not be the actual component or field names used in the linux kernel but they should give you an idea about what exists in the kernel.</em></p>
]]></content:encoded></item><item><title><![CDATA[What should we name it?]]></title><description><![CDATA[One of the most powerful sentences I've read in the book is "...focus on whether the code reads like paragraphs and sentences."
Yes, that should be the goal. Make sure it flows through the reader's mind like an Ilayaraja's symphony. Inspiring new ide...]]></description><link>https://blog.sampath.dev/what-should-we-name-it</link><guid isPermaLink="true">https://blog.sampath.dev/what-should-we-name-it</guid><category><![CDATA[Programming Tips]]></category><category><![CDATA[clean code]]></category><category><![CDATA[Programming Blogs]]></category><category><![CDATA[Java]]></category><category><![CDATA[naming]]></category><dc:creator><![CDATA[Sampath Balivada]]></dc:creator><pubDate>Wed, 21 Jun 2023 19:51:07 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1687373923440/68bf1bc2-7a91-445f-b262-7591c30dcbb8.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>One of the most powerful sentences I've read in the book is "...focus on whether the code reads like paragraphs and sentences."</p>
<p>Yes, that should be the goal. Make sure it flows through the reader's mind like an Ilayaraja's symphony. Inspiring new ideas. Connecting you with the moment. And just...</p>
<p>Okay, enough with Raja sir's music. Back to code.</p>
<h3 id="heading-so-how-do-we-make-that-happen">So how do we make that happen?</h3>
<p>Here are a few things that are stuck in my mind.</p>
<ol>
<li><p>Use names that describe what you are naming. A method? use a verb. A class? use a noun or a noun phrase. A variable? Describe what it stores.  </p>
<p> Believe me, I have seen a fair share of variables in my short career that requires you to be an NSA agent to decipher what it means.</p>
</li>
<li><p>Don't name something as A and make it do B. That's borderline evil. Why would you even think of doing something like that?</p>
</li>
<li><p><code>a1</code> or <code>a2</code> is not a meaningful name. An alphabet followed by a number is in most cases bad naming.  </p>
<p> Imagine calling Ram and Bheem from RRR as <code>a1</code> and <code>a2</code>. Yeahhh... doesn't sound so good. Does it?  </p>
<p> Give your variables, methods and classes some character.</p>
</li>
<li><p>While we are here, please for the love of Rajamouli... don't create your own acronyms. <code>MB</code> is not the right name for <code>MahendraBahubali</code>. You see how it can be interpreted in multiple ways right?</p>
</li>
<li><p>Also, don't bring fancy movie names here. Why are you naming that thing <code>Dumbledore</code>? It isn't going to shoot <strong><em>Avada Kedavra</em></strong> on your bugs anyways.</p>
</li>
</ol>
<p>That wasn't an exhaustive list but you get the idea. Name things in code with a short yet sensible name that makes the reader of the code understand what it does.</p>
<p>No one is awarding you to name things like a compiler. Name them like a human and you'll probably have thank yous of many programmers who are going to read what you are writing today.</p>
<p>That's one chapter. Let's meet for the next one.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1687376568469/60e082ad-e980-460b-a823-8ed2f7213a09.gif" alt /></p>
<blockquote>
<p><em>Although I present the contents of the book in a fun and though provoking way, I highly recommend you to read through the book once to get a sense of it. You can find the book</em> <a target="_blank" href="https://g.co/kgs/awpF72"><em>here</em></a><em>.</em></p>
</blockquote>
]]></content:encoded></item><item><title><![CDATA[The Curse of Perfection]]></title><description><![CDATA[Storytime people
Aight, so I have a friend who tried building a platform. In terms of engineering, not a lot of complex stuff but some auth here and some DB queries there and you should be good to go.
But the project never saw the light of day. Now, ...]]></description><link>https://blog.sampath.dev/the-curse-of-perfection</link><guid isPermaLink="true">https://blog.sampath.dev/the-curse-of-perfection</guid><category><![CDATA[product]]></category><category><![CDATA[engineering]]></category><category><![CDATA[Design]]></category><category><![CDATA[architecture]]></category><category><![CDATA[app development]]></category><dc:creator><![CDATA[Sampath Balivada]]></dc:creator><pubDate>Mon, 24 Apr 2023 12:30:42 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1682333485938/55717b51-f544-4c81-98df-0afc79bcc42d.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h3 id="heading-storytime-people">Storytime people</h3>
<p>Aight, so I have a friend who tried building a platform. In terms of engineering, not a lot of complex stuff but some auth here and some DB queries there and you should be good to go.</p>
<p>But the project never saw the light of day. Now, out of all the bottlenecks in the world (time, money, talent and everything else), the one thing that stopped the project was over-engineering.</p>
<h3 id="heading-over-engineering-you-may-ask">"Over-Engineering?" you may ask</h3>
<p>That's right. You can over-engineer stuff. Now, how's that a bad thing?</p>
<p>Sit down... I got some explaining to do here.</p>
<p>So, take a brand new product or a service that you want to build. How many users are you targeting initially?</p>
<p>If you answered more than 10, that's where the mistake lies. Unless of course, you know for sure.</p>
<p>Now, when you start building this product you think about scale, costs, pricing, architecture, performance and all the fancy stuff. I know this stuff feels good. I've been there in the never-ending tunnel of discussions about which tech stack to use and where are we deploying our application.</p>
<p>Now that rabbit hole of trying to achieve engineering perfection is over-engineering.</p>
<h3 id="heading-but">But...</h3>
<p>None of that matters to your first user.</p>
<p>What they want is an answer to the question, "What are you doing to solve my problem(s)?"</p>
<p>Does the user say the application is slow? Aight, fix it.</p>
<p>Does the user say they don't like the colours? Fine, fix it now.</p>
<p>Does the user say there are too many buttons? Hmm... see what can be removed.</p>
<p>You see where I am going with this right?</p>
<blockquote>
<p><strong>Perfection</strong> is a perceived trait.</p>
<p>- Sampath Balivada (That's me :P)</p>
</blockquote>
<h3 id="heading-is-it-truly-perfect">Is it truly perfect?</h3>
<p>What might be perfect for you might not be the same for someone else. And in the context of a product, oh boy the user's perception of perfection is way more important that any other stakeholders. (Of course, there may be exceptions here)</p>
<p>So... wait until the user tells you what their definition of perfection is and then act on it.</p>
<p>Imagine you engineer a perfect(?) solution that can scale to lakhs of users and can generate millions of rupees in revenue with enough users.</p>
<p>Ahhh... with <strong>enough users.</strong></p>
<p>You got no users right now. Build a solution, get users, ask them how they like it and then try to achieve perfection.</p>
<p>Perfection from the perspective of the user. Not the engineer.</p>
<h3 id="heading-how-do-you-stop-chasing-perfection-then">How do you stop chasing perfection then?</h3>
<p>Easy (although it isn't). Build what's barely necessary using whatever tools you have available at hand and deploy it on whichever platform you have access to.</p>
<p>The user doesn't care about this stuff anyways. All they need is a solution to their problem.</p>
<h3 id="heading-jugaad">Jugaad</h3>
<p>You might frown upon this but yeah, build something that sticks, share it with the world and then sit down to make it better. That's the only way to avoid the rabbit hole or should I say the curse of perfection for all your products and features.</p>
]]></content:encoded></item><item><title><![CDATA[Understanding and implementing Bezier Curves using HTML Canvas and Javascript]]></title><description><![CDATA[TLDR; 2 weeks ago, I saw a video by Fireship titled "WTF is a Bézier Curve?" and realized Bezier curves are beautiful and implemented them myself.
Try it out here:  https://sampath.dev/bezier-curve-js/
Source Code:  GitHub repo
How do we draw somethi...]]></description><link>https://blog.sampath.dev/bezier-curves</link><guid isPermaLink="true">https://blog.sampath.dev/bezier-curves</guid><category><![CDATA[graphics]]></category><category><![CDATA[Computer Science]]></category><category><![CDATA[JavaScript]]></category><category><![CDATA[HTML]]></category><dc:creator><![CDATA[Sampath Balivada]]></dc:creator><pubDate>Tue, 21 Dec 2021 14:01:07 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1640088106505/KEleynd4q.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p><strong>TLDR;</strong> 2 weeks ago, I saw a video by Fireship titled <a target="_blank" href="https://www.youtube.com/watch?v=BThr1pb77Fo">"WTF is a Bézier Curve?"</a> and realized Bezier curves are beautiful and implemented them myself.</p>
<p><strong>Try it out here:  <a target="_blank" href="https://sampath.dev/bezier-curve-js/">https://sampath.dev/bezier-curve-js/</a></strong></p>
<p><strong>Source Code:  <a target="_blank" href="https://github.com/sampathbalivada/bezier-curve-js">GitHub repo</a></strong></p>
<h3 id="heading-how-do-we-draw-something-on-a-screen">How do we draw something on a screen?</h3>
<p>In reality, everything on the screen is a drawing. Think in terms of pixels on the screen. How would you draw a line? </p>
<p>Just like any line on a Graph paper. Consider any corner of the screen as (0,0) or origin and consider two points <code>start</code> and <code>end</code> to draw a line from and to. We can get the line by plotting points for each point in the <a target="_blank" href="https://en.wikipedia.org/wiki/Locus_%28mathematics%29">locus</a> of the  <a target="_blank" href="https://en.wikipedia.org/wiki/Linear_equation">linear equation</a> of the line.</p>
<p>Now, how do we draw a curve?</p>
<p>Think about it... I'll wait.</p>
<p>Now, that I too thought about it, I came up with this very huge solution. Remember each point in the curve and re-plotting when necessary. Although that would work, it's a lot of storage space.</p>
<p>So, <strong>Pierre Bézier</strong> came up with a solution for that after being annoyed while drawing designs for the Renault automobile company. The underlying math was established by <strong>Bernstein</strong>, way before the advent of Bezier Curves but Pierre Bezier brought the math and applied it into computer graphics.</p>
<p>Now, the math is simple here. We need to first understand how we are plotting straight lines.</p>
<h3 id="heading-drawing-lines">Drawing lines</h3>
<p>Consider that we are drawing a line from <code>(0, 0)</code> to <code>(100, 0)</code>. So, we are drawing a line from <code>x = 0</code> to <code>x = 100</code>.</p>
<p>We need to plot a point at <code>x = 0</code>, <code>x = 1</code>, <code>x = 2</code>, <code>x = 3</code> and up to <code>x = 100</code>. To get these values, we can make use of the following formula and plot all values of <code>xi</code>.</p>
<pre><code class="lang-math">xi = (x2 - x1) * t + x1

where t is in the range [0, 1]
</code></pre>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1640091710724/hCRVYDy21.png" alt="image.png" />
<em>plotting the line y = 0 and x = [0, 100]</em></p>
<p>This is how we can draw a line and this process is called interpolation. Remember the <code>t</code>, we need it for later. Let's move on to drawing a curve.</p>
<h3 id="heading-drawing-curves">Drawing curves</h3>
<p>I'll try to make it as easy to understand as possible but pay close attention here. This is the crux of it.</p>
<p>We are interpolating here between two points <code>start</code> and <code>end</code>, <code>(0,0)</code> and <code>(100,0)</code> according to our line example. Let's add a new point <code>control</code> with the coordinate <code>(50, 50)</code>. This point will now define our curve.</p>
<p>As usual, we will interpolate here as well, but we will perform it between the points (<code>start</code> and <code>control</code>) and (<code>control</code> and <code>end</code>).</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1640092048834/X7oS56ai4.png" alt="image.png" /></p>
<p>This will give us two new points for every value of <code>t</code>. Refer to the <strong>Drawing lines</strong> section if you don't know what this is. Let's consider them as <code>pA</code> and <code>pB</code>. </p>
<p>Now, for every value of <code>pA</code> and <code>pB</code>, we now interpolate between them. So, we will find the value as stated below.</p>
<pre><code class="lang-text">pAt -&gt; pA for a given value t, while interpolating between start and control
pBt -&gt; pB for a given value t, while interpolating between control and end

pCt -&gt; pC for a given value t, while interpolating between pAt and pBt
</code></pre>
<p>To make it much clear, let's consider the results for <code>t =0. 1</code>.</p>
<pre><code class="lang-math">var xt = (p2.x - p1.x) * t + p1.x;

pA = ((50 - 0) * 0.1 + 0, (50 - 0) * 0.1 + 0) = (5, 5)
pB = ((100 - 50) * 0.1 + 50, (0 - 50) * 0.1 + 50) = (55, 45)

pC = ((55 - 5) * 0.1 + 5, (45 - 5) * 0.1 + 5) = (10, 9)
</code></pre>
<p>Similarly, we can find all the values of <code>pC</code> for every value of <code>t</code> in the range [0, 1]. Plotting these values on the graph will give us the following curve.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1640093869368/Z2zDU2-JA.png" alt="image.png" /></p>
<p>If you are confused about any step here, go back and read through the sections again or you can also comment where you are stuck and I'll try to elaborate if I can.</p>
<h3 id="heading-multiple-control-points">Multiple control points?</h3>
<p>This curve here has just one control point, what if you need a curve with more than one control point? We can do that as well. We do the same operations as for the above curve and do it recursively. </p>
<p>The one we calculated above is called a <em>Quadratic Bezier Curve</em>. Similarly, one with two control points is called a <em>Cubic Bezier Curve</em> and so on.</p>
<h3 id="heading-does-my-code-perform-all-this-interpolation">Does my code perform all this interpolation?</h3>
<p>The straight answer is 'No'. The reason is mathematics. Yes, it is necessary that we understand interpolation here to get the curve but in mathematics, we also have equations for curves. If we simplify the operation we are performing here, we can get a neat equation that we can use to get the point <code>pC</code> for a given value <code>t</code>.</p>
<p>This is what my code does.</p>
<pre><code class="lang-js"><span class="hljs-comment">// Quadratic Bezier Curve</span>
<span class="hljs-comment">// x(t) = (1−t)^2 * x0 + 2 * t * (1−t) * x1 + t^2 * x2</span>

<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">calcQuadraticBezierCurveValue</span>(<span class="hljs-params">c1, c2, control, t</span>) </span>{
    <span class="hljs-keyword">return</span> <span class="hljs-built_in">Math</span>.pow(<span class="hljs-number">1</span> - t, <span class="hljs-number">2</span>) * c1 + <span class="hljs-number">2</span> * t * (<span class="hljs-number">1</span> - t) * control + <span class="hljs-built_in">Math</span>.pow(t, <span class="hljs-number">2</span>) * c2;
}
</code></pre>
<pre><code class="lang-js"><span class="hljs-comment">// Cubic Bezier Curve</span>
<span class="hljs-comment">// x(t) = (1−t)^3 * x0 + 3 * (1-t)^2 * t * x1 + 3 * (1 - t) * t ^ 2 * x2 + t^3 * x3</span>

<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">calcCubicBezierCurveValue</span>(<span class="hljs-params">c1, c2, control1, control2, t</span>) </span>{
    <span class="hljs-keyword">return</span> <span class="hljs-built_in">Math</span>.pow(<span class="hljs-number">1</span> - t, <span class="hljs-number">3</span>) * c1 + <span class="hljs-number">3</span> * <span class="hljs-built_in">Math</span>.pow(<span class="hljs-number">1</span> - t, <span class="hljs-number">2</span>) * t * control1 + <span class="hljs-number">3</span> * (<span class="hljs-number">1</span> - t) * <span class="hljs-built_in">Math</span>.pow(t, <span class="hljs-number">2</span>) * control2 + <span class="hljs-built_in">Math</span>.pow(t, <span class="hljs-number">3</span>) * c2;
}
</code></pre>
<p>A list of formulae for each type of Bezier curve can be found on Wikipedia <a target="_blank" href="https://en.wikipedia.org/wiki/B%C3%A9zier_curve#Specific_cases">here</a>.</p>
<p>That's it, that's how we draw curves on our computer screens. That's some history and deep dive into how computers work. If you have suggestions or questions, drop them in the comments and let's talk. Feel free to play with the <a target="_blank" href="https://sampath.dev/bezier-curve-js/">website</a> and explore the <a target="_blank" href="https://github.com/sampathbalivada/bezier-curve-js">source code</a>. </p>
<p><em>It's a wrap!</em></p>
]]></content:encoded></item><item><title><![CDATA[Virtual Machines - Nand2Tetris]]></title><description><![CDATA[Note that, as per Wikipedia, we are now talking about Process Virtual Machines and not System Virtual Machines. Although, the idea is similar.
What they actually mean.
Keeping the terminology aside, let's think about a piece of software we use every ...]]></description><link>https://blog.sampath.dev/virtual-machines-nand2tetris</link><guid isPermaLink="true">https://blog.sampath.dev/virtual-machines-nand2tetris</guid><category><![CDATA[Java]]></category><category><![CDATA[Android]]></category><category><![CDATA[Art]]></category><category><![CDATA[code]]></category><category><![CDATA[Computer Science]]></category><dc:creator><![CDATA[Sampath Balivada]]></dc:creator><pubDate>Mon, 15 Nov 2021 18:14:01 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1636999910633/Tq-t5ZIYV.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Note that, as per <a target="_blank" href="https://en.wikipedia.org/wiki/Virtual_machine">Wikipedia</a>, we are now talking about <em>Process Virtual Machines</em> and not <em>System Virtual Machines</em>. Although, the idea is similar.</p>
<h3 id="what-they-actually-mean">What they actually mean.</h3>
<p>Keeping the terminology aside, let's think about a piece of software we use every day, the browser. We give a link to the browser, or in other senses, we tell the browser the location of a piece of code it can fetch using the internet. Once the browser fetches the code, it starts to understand (parse) and execute the instructions in the code. </p>
<p>On whichever device we type "amazon.com" on, the device browser fetches the same code. Maybe you are opening it on a mobile phone that runs Android and has an ARM architecture that has a RISC instruction set or you are running it on a Windows PC with an AMD/Intel processor that is executing the x86_64 instruction set, but it doesn't matter.</p>
<p>We have a special application here that's taking care of it all for us. The mighty browser. In a sense, a browser is a Virtual Machine. It is providing our code with a platform to run on that is entirely virtual and is independent of the underlying architecture or jargon.</p>
<p>This is how Modern Languages like Java, Dart, Kotlin or Python work on different machines and devices.</p>
<p>Everyone who took a Java course or wrote some code in Java is aware that Java first compiles to a middle language i.e. Java Byte Code which is then compiled in runtime to Machine Code (or maybe the Assembly language in this case). This is called "Just In Time" (JIT) compilation. This JIT compilation is performed by a Virtual Machine (Java Virtual Machine). This JVM is akin to the browser.</p>
<p>The Java Virtual Machine (JVM) and the Python Virtual Machine are stack machines. What this means is that it stores data and performs operations on these data using a stack.</p>
<h3 id="android-virtual-machine">Android Virtual Machine</h3>
<p>Android apps can be written in Java, meaning the syntax is there but Android apps cannot run on the JVM because they are not compiled to Java byte code.</p>
<p>Android apps run on the Dalvik Virtual Machine(DVM). At least they used to (Now, it moved to Android Run Time - ART) but the soul is there. It is a less resource-intensive Virtual Machine to run Dalvik Bytecode.</p>
<p>But there's another catch. The JVM is a Stack Machine but the DVM is a Register Machine. Meaning it works by manipulating the registers.</p>
<p>A JVM code to add two numbers 3 and 4 might look like this:</p>
<pre><code class="lang-text">push 3
push 4
add
</code></pre>
<p>The same may be achieved in a Register Machine this way:</p>
<pre><code class="lang-text">LOAD 3, R1
LOAD 4, R2 
ADD R1, R2, R3
</code></pre>
<p>We deal directly with the memory in a Register Machine.</p>
<p>So that's Process Virtual Machines and how computers understand stuff while we continue to write code in High-Level Languages. It's a boon that we are able to.</p>
]]></content:encoded></item><item><title><![CDATA[Building the WSL2 Linux Kernel Yourself]]></title><description><![CDATA[Why?
I want to try out hacking the Linux Kernel in weird ways and I want to make sure I am able to build it before changing bits and parts of it and experimenting.
I don't have a spare machine to do this stuff. Neither have I worked with Qemu or othe...]]></description><link>https://blog.sampath.dev/building-the-wsl2-linux-kernel-yourself</link><guid isPermaLink="true">https://blog.sampath.dev/building-the-wsl2-linux-kernel-yourself</guid><category><![CDATA[linux kernel]]></category><category><![CDATA[Linux]]></category><category><![CDATA[Windows]]></category><category><![CDATA[Open Source]]></category><category><![CDATA[Git]]></category><dc:creator><![CDATA[Sampath Balivada]]></dc:creator><pubDate>Sun, 14 Nov 2021 08:31:06 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1636878768022/2kkOKyHCT.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h3 id="why">Why?</h3>
<p>I want to try out hacking the Linux Kernel in weird ways and I want to make sure I am able to build it before changing bits and parts of it and experimenting.</p>
<p>I don't have a spare machine to do this stuff. Neither have I worked with Qemu or other emulation platforms to know what's happening with my kernel.</p>
<p>I'm not brave enough (yet) to install this <em>"god knows what bugs it has"</em> kernel on my only working machine to test things out.</p>
<p>I've been using WSL2 for a while to write code and build things, but I found that it also gives me a safe way to try a new or modified kernel and an emergency switch to the stable kernel if things go wrong, all while being able to interact with my computer and write code on it. Seems legit, so let's build it.</p>
<p>Please note that you need WSL2 to continue with the rest of the process. More info  <a target="_blank" href="https://docs.microsoft.com/en-us/windows/wsl/install">here</a> .</p>
<h3 id="building-the-kernel">Building the Kernel</h3>
<p>The  <a target="_blank" href="https://github.com/microsoft/WSL2-Linux-Kernel/blob/linux-msft-wsl-5.10.y/README.md">README.md</a> file of the WSL2-Linux-Kernel repository gives us 2 commands to build the kernel on an Ubuntu machine.</p>
<p>Personally, I had to jump through little hoops before I could successfully build the kernel. So, here goes nothing.</p>
<h3 id="steps-to-build-the-kernel">Steps to Build the Kernel</h3>
<p>Building On:</p>
<pre><code class="lang-text">Platform: WSL2
Distro: Ubuntu-20.04
Edition: Windows 10 Home
Build Number: 19043.1348
</code></pre>
<h4 id="1-clone-the-kernel-repository">1. Clone the Kernel Repository</h4>
<p>If your aim is to just build the kernel and you are not planning to hack on it yet, you can directly  <a target="_blank" href="https://github.blog/2020-12-21-get-up-to-speed-with-partial-clone-and-shallow-clone/">shallow clone</a>  the <code>microsoft/WSL2-Linux-Kernel</code> repository.</p>
<pre><code class="lang-bash">git <span class="hljs-built_in">clone</span> --depth 1 https://github.com/microsoft/WSL2-Linux-Kernel.git
</code></pre>
<p>If you are planning to hack on the kernel yourself and do some other stuff, it would be wise to  <a target="_blank" href="https://docs.github.com/en/get-started/quickstart/fork-a-repo#forking-a-repository">fork the repository</a>  and then clone your fork.</p>
<pre><code class="lang-bash">git <span class="hljs-built_in">clone</span> --depth 1 https://github.com/sampathbalivada/WSL2-Linux-Kernel.git
</code></pre>
<p>Here, I do not wish to have the git history locally so I am choosing to shallow clone, if you want the history, you can remove the --depth option.</p>
<h4 id="2-installing-tools">2. Installing Tools</h4>
<p>Kernels don't build (in other words, compile) by themselves. They need a compiler and other tools to build. For that, the repository README asks us to run the below command, so let's run it.</p>
<pre><code class="lang-bash">sudo apt install build-essential flex bison libssl-dev libelf-dev
</code></pre>
<p>While building the kernel, I encountered an error that required <code>pahole</code>, let's look into it at a later point as our primary goal now is to build the kernel. </p>
<p>Upon further research, I was able to determine that <code>pahole</code> is a part of the  <a target="_blank" href="https://yum-info.contradodigital.com/view-package/epel/dwarves/"><code>dwarves</code></a>  package. So, let's install it as well.</p>
<pre><code class="lang-bash">sudo apt install dwarves
</code></pre>
<p>Now, we have all the tools needed to build the kernel.</p>
<h4 id="3-summon-the-makefile">3. Summon the Makefile</h4>
<p>Before we initiate the build, we may want to create an identity for ourselves using the version string.</p>
<p>So, let's modify the version </p>
<p>File: <code>WSL2-Linux-Kernel/Microsoft/config-wsl</code></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1636876834005/kDbpAAeSa.png" alt="wsl2.png" /></p>
<p>All set. Now, let's build our own kernel for WSL2.</p>
<pre><code class="lang-bash">make KCONFIG_CONFIG=Microsoft/config-wsl -j4
</code></pre>
<p><code>-j4</code> creates 4 parallel tasks for building the kernel. You may choose to increase or decrease the number <code>4</code> as per your liking but the thumb rule is that you create 4 parallel tasks if your PC has 4 cores and so on.</p>
<h4 id="4-build-finished-what-next">4. Build finished. What next?</h4>
<p>So you are done with the 10-15 minute build process and would like to move on to using this kernel that you built.</p>
<p>A quick <code>ls</code> in the WSL2-Linux-Kernel directory will reveal that we now have a new file name <code>vmlinux</code>. That's the kernel we just built. </p>
<p>Now, let's move it to a location on the Windows Machine. I moved it to <code>C:\Users\&lt;username&gt;\</code>. You may move it to any location of your liking.</p>
<p>Now comes the neat part. Telling WSL to use our Kernel instead of the default one. How do we do it? Through a configuration file.</p>
<p>WSL allows us to specify  <a target="_blank" href="https://docs.microsoft.com/en-us/windows/wsl/wsl-config#global-configuration-options-with-wslconfig">global settings</a>  for all the distros using the <code>.wslconfig</code> file located at <code>%USERPROFILE%\.wslconfig</code>.</p>
<p>This is how I configured my <code>.wslconfig</code> file.</p>
<p>File Name: <code>%USERPROFILE%\.wslconfig</code> or <code>C:\Users\&lt;username&gt;\.wslconfig</code></p>
<pre><code class="lang-config">[wsl2]
kernel=C:\\Users\\sampathbalivada\\vmlinux
</code></pre>
<p>We now need to restart the WSL Virtual Machine for it to pick up the new configuration file and also use the kernel we built.</p>
<p>Open a new PowerShell window and type the following command to shut down all the running WSL2 VMs. Make sure to save your work before shutting down. </p>
<pre><code>wsl <span class="hljs-comment">--shutdown</span>
</code></pre><p>Now open a new Ubuntu or your favourite distro terminal and type in the below command.</p>
<pre><code class="lang-bash">cat /proc/version
</code></pre>
<p>You should be greeted with your custom version name. It indicates that WSL is now running a kernel that's built by you. Phew!</p>
<pre><code class="lang-text">Linux version 5.10.74.3-sampathbalivada-local-WSL2+
</code></pre>
<h3 id="whats-next">What's next?</h3>
<p>In future blog posts, I will try to understand and elaborate on the different subsystems in Linux and how they work in cohesion with each other. We will also see if we can change some stuff in the kernel and play with it.</p>
]]></content:encoded></item><item><title><![CDATA[Assemblers - Nand2Tetris]]></title><description><![CDATA[Some of the quotes and information are part of the Nand2Tetris course available on Coursera.
Assemblers
Assemblers are simple. They turn symbolic code (assembly) into machine code (binary). We can also write everything in machine code but it's much e...]]></description><link>https://blog.sampath.dev/assemblers-nand2tetris</link><guid isPermaLink="true">https://blog.sampath.dev/assemblers-nand2tetris</guid><category><![CDATA[Computer Science]]></category><category><![CDATA[Python]]></category><category><![CDATA[Python 3]]></category><category><![CDATA[cpu]]></category><dc:creator><![CDATA[Sampath Balivada]]></dc:creator><pubDate>Thu, 04 Nov 2021 10:33:10 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1636021897975/4uFDbj2kz.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p><em>Some of the quotes and information are part of the Nand2Tetris course available on Coursera.</em></p>
<h3 id="assemblers">Assemblers</h3>
<p>Assemblers are simple. They turn symbolic code (assembly) into machine code (binary). We can also write everything in machine code but it's much easier for us to make a computer do it. But, it is also hard to write an assembler in machine code.</p>
<h3 id="cross-compilation">Cross Compilation</h3>
<p>So what do we do? We use a different computer to write an assembler in a high-level language like C++, Java or Python and use it to translate our assembly code to binary code.</p>
<p>The assembly code is not the same for every machine as platforms might change and it's the same case with Machine code as well. As the CPU changes, the type of operations it can perform will also change. </p>
<p>Cross Compilation is the process of compiling a piece of code on a computer where the output is compiled to be run on a different platform than the one we are compiling on.</p>
<p>A perfect example of cross-compilation would be mobile apps. Desktop PCs are built on the x86_64 platform whereas mobiles are built on the ARM platform but we compile mobile apps on Desktop and run them on mobile devices.</p>
<blockquote>
<p>If you want to try out the assembler that I built for the course, you can find it  <a target="_blank" href="https://github.com/sampathbalivada/assembler-for-hack-computer">here</a>.</p>
</blockquote>
]]></content:encoded></item><item><title><![CDATA[Game Consoles and Oscillators - Nand2Tetris]]></title><description><![CDATA[Extra Bits of information related to the course that I found interesting.
Game Consoles
Remember those game consoles that we plugged into the TV and inserted a cartridge that said 1000000 in 1? Those were computers (well technically).
They were 16-bi...]]></description><link>https://blog.sampath.dev/game-consoles-and-oscillators-nand2tetris</link><guid isPermaLink="true">https://blog.sampath.dev/game-consoles-and-oscillators-nand2tetris</guid><category><![CDATA[Computer Science]]></category><category><![CDATA[cpu]]></category><category><![CDATA[logic]]></category><dc:creator><![CDATA[Sampath Balivada]]></dc:creator><pubDate>Thu, 04 Nov 2021 08:17:35 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1636013816230/KSbpejFwJcg.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p><em>Extra Bits of information related to the course that I found interesting.</em></p>
<h3 id="game-consoles">Game Consoles</h3>
<p>Remember those game consoles that we plugged into the TV and inserted a cartridge that said <strong>1000000 in 1</strong>? Those were computers (well technically).</p>
<p>They were 16-bit (fourth generation) and 32/64-bit (fifth-generation). These word sizes are somewhat debatable (click  <a target="_blank" href="https://en.wikipedia.org/wiki/Sixth_generation_of_video_game_consoles#Bits_and_system_power">here</a> for more info) but the real thing is that these were more like computers and had all the parts like RAM, CPU and even ROM.</p>
<p>The ROM is the <strong>1000000 in 1</strong> cartridges that we used to buy at local stores for Rs. 50/-. So we basically swapped out ROMs whenever we wanted to and the reset button just moved the PC (Program Counter) to 0.</p>
<p>Those glitches and random artefacts? The PC probably messed up the count or the ROM lost a bit somewhere. It's crazy to think that I had a computer even before I thought I had one and it used a CRT TV as a monitor.</p>
<h3 id="oscillators-in-modern-computers">Oscillators in Modern Computers</h3>
<p>In the course, while building the CPU, we never thought of the Oscillator that gave us the clock pulse. It was treated as an external entity that the CPU knew how to handle. In reality and in modern computers, the oscillators are a part of the CPU.</p>
<p>To know why it's now moved inside the CPU we have to know that in the usual sense, an oscillator would be a different entity and the pulse would be routed to all the components that need a clock cycle to work with - CPU, Memory, Registers etc. In reality, each component in the computer can run at its own speed. The RAM chip currently in your computer might be running at 2333 MHz and your CPU might be running at a speed of 2.8 GHz. That's a lot of difference and there are mechanisms to handle it.</p>
<p>But for the explanation as to how oscillators are implemented modern CPUs, they are a part of the CPU or whichever component they are giving a pulse to.</p>
]]></content:encoded></item><item><title><![CDATA[Harvard and von Neumann Architecture - Nand2Tetris]]></title><description><![CDATA[Some of the quotes and information are part of the Nand2Tetris course available on Coursera.
von Neumann architecture
Let's think from a normal standpoint where we have a single memory device that both stores the program that we need to execute and a...]]></description><link>https://blog.sampath.dev/harvard-and-von-neumann-architecture-nand2tetris</link><guid isPermaLink="true">https://blog.sampath.dev/harvard-and-von-neumann-architecture-nand2tetris</guid><category><![CDATA[Computer Science]]></category><category><![CDATA[cpu]]></category><category><![CDATA[architecture]]></category><dc:creator><![CDATA[Sampath Balivada]]></dc:creator><pubDate>Thu, 04 Nov 2021 07:52:35 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1636012238946/YSZDBM8lU.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p><em>Some of the quotes and information are part of the Nand2Tetris course available on Coursera.</em></p>
<h3 id="von-neumann-architecture">von Neumann architecture</h3>
<p>Let's think from a normal standpoint where we have a single memory device that both stores the program that we need to execute and also stores the data for the program during execution. There are two cycles in this operation. Since we can only operate once on the memory per clock cycle, we have to execute an instruction in 2 cycles.</p>
<p>The two cycles would be:</p>
<ol>
<li>Fetch Cycle: we probe the memory for the instruction we will be executing.</li>
<li>Execute Cycle: once we have the instruction, we operate on the memory to store and retrieve the data required for the instruction.</li>
</ol>
<p>This is how  <a target="_blank" href="https://en.wikipedia.org/wiki/Von_Neumann_architecture">von Neumann Architecture </a> handles instruction fetching and execution - in two cycles.</p>
<h3 id="harvard-architecture">Harvard Architecture</h3>
<p>To overcome this limitation of using 2 cycles, the Harvard Mark I relay-based computer, stored instructions on punched tape (the ROM) and data in electro-mechanical counters (or in other words, the RAM).</p>
<p>That's where the architecture got its name from -  <a target="_blank" href="https://en.wikipedia.org/wiki/Harvard_architecture">Harvard Architecture</a>.</p>
<p>Why is this better? The CPU can access both the instruction to execute and also the data required to execute the instruction in the same cycle. So, for something that needs 48 clock cycles to execute, we can finish it in 24 clock cycles. This is quite advantageous and saves time but it's costlier as we need to maintain two memory devices instead of one.</p>
<h3 id="what-architecture-does-my-cpu-follow">What architecture does my CPU follow?</h3>
<p>CPUs that are currently in use implement a modified version of the Harvard Architecture, which is called as, lo and behold,  <a target="_blank" href="https://en.wikipedia.org/wiki/Modified_Harvard_architecture">Modified Harvard Architecture</a>. The most significant modification is the use of a split-cache where we implement memory hierarchy and store the instructions in separate data and instruction memory at low levels. The modification is that, instead of having 2 address spaces, one for instructions and one for data, we use single address space.</p>
]]></content:encoded></item><item><title><![CDATA[Handling I/O - Nand2Tetris]]></title><description><![CDATA[Some of the quotes and information are part of the Nand2Tetris course available on Coursera.
Handling I/O
I/O in a computer is handled by the device drivers. But how? The devices, when working, put a value into a memory location, say the mouse will c...]]></description><link>https://blog.sampath.dev/handling-io-nand2tetris</link><guid isPermaLink="true">https://blog.sampath.dev/handling-io-nand2tetris</guid><category><![CDATA[Computer Science]]></category><category><![CDATA[logic]]></category><dc:creator><![CDATA[Sampath Balivada]]></dc:creator><pubDate>Wed, 27 Oct 2021 18:32:49 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1635359445899/4NW40CP1K.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p><em>Some of the quotes and information are part of the Nand2Tetris course available on Coursera.</em></p>
<h3 id="handling-io">Handling I/O</h3>
<p>I/O in a computer is handled by the device drivers. But how? The devices, when working, put a value into a memory location, say the mouse will continuously write its change in location value to the memory at address 7345, the driver will continuously look into that location and get the value to work with and changes the location of the pointer on the screen accordingly.</p>
<p>The computer that I am building as a part of the course takes input from the keyboard and outputs it to a virtual screen of dimensions 512x256. So there are 512 pixels horizontally and 256 rows of those 512 pixels.</p>
<p>For each pixel, we store the value to be displayed in the memory using bits in memory. For a black and white screen, we can consider the pixel as black if the value is set to <code>1</code> and white if it is set to <code>0</code>.</p>
<p>The set of bits that define the pixel values of the screen is called the Screen Memory Map or VRAM (Video RAM). In real-life computers, it is defined somewhere from 64 to 128 MB. If the computer has a dedicated Graphics Processing Unit (GPU) this number will usually be much higher.</p>
<p>Similar to this, the keyboard also writes to a memory location and it is called the Keyboard Memory Map. In the computer that I am building, this is a 16-bit register and is more than enough to represent the ASCII coded values on the keys and can also support Unicode values if necessary.</p>
]]></content:encoded></item><item><title><![CDATA[Machine Language and Memory - Nand2Tetris]]></title><description><![CDATA[Some of the quotes and information are part of the Nand2Tetris course available on Coursera.
Machine Language
The Machine Language is the most important interface of a computer. It specifies the interaction between the hardware and the software of th...]]></description><link>https://blog.sampath.dev/machine-language-and-memory-nand2tetris</link><guid isPermaLink="true">https://blog.sampath.dev/machine-language-and-memory-nand2tetris</guid><category><![CDATA[Computer Science]]></category><category><![CDATA[logic]]></category><dc:creator><![CDATA[Sampath Balivada]]></dc:creator><pubDate>Wed, 27 Oct 2021 18:10:39 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1636880858257/IJ1eoR0kJ.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p><em>Some of the quotes and information are part of the Nand2Tetris course available on Coursera.</em></p>
<h3 id="machine-language">Machine Language</h3>
<p>The Machine Language is the most important interface of a computer. It specifies the interaction between the hardware and the software of the computer. Wasn't this the kernel? Well theoretically yes but the Linux kernel is written in C and Assembly which is converted to Machine Language.</p>
<p>Machine Language is in Binary and they directly correspond to the hardware implemented in the computer. For instance, if the hardware has an implementation for Addition, there is a binary code for that operation.</p>
<p>Because Machine Language directly corresponds to the hardware implementation of a computer, so there are two things that can change in a Machine Language:</p>
<ol>
<li>Set of operations available. (Division, Bulk Copy, etc.)</li>
<li>Data Types (Register Width, Floating Point, etc.)</li>
</ol>
<h3 id="memory-hierarchy">Memory Hierarchy</h3>
<p>Fast memory is expensive, large memory is slow. For this reason, we have a memory hierarchy. We arrange faster and small memory close to the CPU and slow and large memory farther from the CPU.</p>
<p>This solves 2 problems:</p>
<ol>
<li>Need to supply long memory address</li>
<li>Getting the memory contents of the CPU</li>
</ol>
<h3 id="flow-control">Flow Control</h3>
<p>Computers execute commands and operations in a sequence. To control the sequence in which operations are performed or to repeat the same operations again and again, we use Conditional and Unconditional jumps.</p>
]]></content:encoded></item><item><title><![CDATA[Memory - Nand2Tetris]]></title><description><![CDATA[Some of the quotes and information are part of the Nand2Tetris course available on Coursera.
The types are many but the ways they work are not
So, there are types of memory, Cache, RAM, ROM, Secondary Memory like Flash, etc. but all of these are fund...]]></description><link>https://blog.sampath.dev/memory-nand2tetris</link><guid isPermaLink="true">https://blog.sampath.dev/memory-nand2tetris</guid><category><![CDATA[Computer Science]]></category><category><![CDATA[logic]]></category><dc:creator><![CDATA[Sampath Balivada]]></dc:creator><pubDate>Sat, 23 Oct 2021 18:55:12 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1635015189715/KL--fao1r.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p><em>Some of the quotes and information are part of the Nand2Tetris course available on Coursera.</em></p>
<h3 id="the-types-are-many-but-the-ways-they-work-are-not">The types are many but the ways they work are not</h3>
<p>So, there are types of memory, Cache, RAM, ROM, Secondary Memory like Flash, etc. but all of these are fundamentally doing the same thing. At least from a logical standpoint. </p>
<p>What they have is a group of registers that work together. Now, what is a register you ask? That's the neatest part of a memory chip that creates an illusion of storage.</p>
<h3 id="repeat-until-i-tell-you-to-change-it">Repeat until I tell you to change it.</h3>
<p>That's it, that's the principle behind the working of a register. Let's say you have a friend, you ask him to shout out 45 until you tell him not to. Now, did you really ask your friend to store it? Nah but you can at any point in time of the future listen, and determine that you asked him to shout out 45. You didn't store it, you just made sure it is repeated enough into the future. Neat eh? That's how a register works.</p>
<p>This is called the state of a register and it creates an illusion of storage. There's also another thing a register is defined with, it's the word width. In the virtual computer that I am building the word, length is 16-bit as It's a 16-bit computer that I am building. </p>
<h3 id="ram-random-access-memory">RAM (Random Access Memory)</h3>
<p>RAM can be thought of as a sequence of addressable registers. At any given point in time, only one register in the RAM is selected. To select we use a selection number that is of width k. Here k = log2(n) where n is the number of registers we have in the RAM. As RAM is created using a set of Registers which are built using Data Flip Flops, RAM is basically a sequential chip.</p>
<p>Now, where does RAM get its name from? From the ability to select any Register and know what's in the register instantaneously. Like seriously, even if you just queried the 1st register, you can immediately ask for the 3678th Register and you get it in a clock cycle. It's just a matter of selection rather than searching. <em>Definitely a thing of beauty.</em></p>
]]></content:encoded></item><item><title><![CDATA[Sequential Logic - Nand2Tetris]]></title><description><![CDATA[Some of the quotes and information are part of the Nand2Tetris course available on Coursera.
The Heart Beat
Sequential Logic is when we introduce the concept of time to computing. I see it this way, let's just say we made an AND gate to calculate the...]]></description><link>https://blog.sampath.dev/sequential-logic-nand2tetris</link><guid isPermaLink="true">https://blog.sampath.dev/sequential-logic-nand2tetris</guid><category><![CDATA[Computer Science]]></category><category><![CDATA[logic]]></category><dc:creator><![CDATA[Sampath Balivada]]></dc:creator><pubDate>Sat, 23 Oct 2021 18:31:35 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1635013852259/BAMd62Wek.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p><em>Some of the quotes and information are part of the Nand2Tetris course available on Coursera.</em></p>
<h3 id="the-heart-beat">The Heart Beat</h3>
<p>Sequential Logic is when we introduce the concept of time to computing. I see it this way, let's just say we made an AND gate to calculate the AND for a pair of binary digits. Now, when should I read the output? immediately? after eternity?</p>
<p>Now time is in reality, not discrete enough to say, "I'll wait a millisecond and then read it". So, the computer has its own way of calculating this. It's called a clock. So, there is a tick-tock inside the computer maintained by an oscillator, and we do something during the tick and read its value during the tock. In reality, this happens a lot of times, like a few billion times a second. That's what that Ghz is. So each GHz is 1 billion clock cycles per second. A cycle is a complete tick-tock.</p>
<p>So far what I did was Combinatorial Logic. Let me explain this. Consider that time is divided into integer time steps. And let us consider an instant of time to be 't'. Then we can represent combinatorial logic and sequential logic this way.</p>
<p>Combinatorial Logic: <code>out[t] = function(in[t])</code></p>
<p>Sequential Logic: <code>out[t] = function(in[t-1])</code></p>
<p>It's important to make it clear that this sequential logic is how computers remember things.</p>
<h3 id="the-basis-of-sequential-logic-in-computers">The basis of Sequential Logic in Computers</h3>
<p>Like how NAND are the fundamental building blocks of logic,  Clocked Data Flip Flops are the fundamental blocks of sequential logic. In reality, they are also built using NAND gates but this fact is generally ignored to keep the two types of logic separate and isolated. </p>
]]></content:encoded></item><item><title><![CDATA[ALU - Nand2Tetris]]></title><description><![CDATA[Some of the quotes and information are part of the Nand2Tetris course available on Coursera.
Von Neumann Architecture
Von Neumann Architecture is the crux of any computer. Of course, the design goals and the type of designs change a lot. If you study...]]></description><link>https://blog.sampath.dev/alu-nand2tetris</link><guid isPermaLink="true">https://blog.sampath.dev/alu-nand2tetris</guid><category><![CDATA[Computer Science]]></category><category><![CDATA[logic]]></category><dc:creator><![CDATA[Sampath Balivada]]></dc:creator><pubDate>Sat, 23 Oct 2021 08:08:01 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1634976748586/uCI3q4Px-.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p><em>Some of the quotes and information are part of the Nand2Tetris course available on Coursera.</em></p>
<h3 id="von-neumann-architecture">Von Neumann Architecture</h3>
<p>Von Neumann Architecture is the crux of any computer. Of course, the design goals and the type of designs change a lot. If you study networking then you could say that the Von Neumann Architecture is to Computer as the TCP/IP model is to networking. Not so standardized but gets you moving and helps you to understand what's going on.</p>
<p>Now when we talk about ALU, we may go ahead and implement every operation that we want using it, like Addition, Comparison, Subtraction, Multiplication, Division, etc. In fact, modern Microprocessors implement very specific types of things at a hardware level. For instance, SoCs like Apple Silicon M1 Pro and Max have a media engine that natively encodes and decodes the ProRes video codec. This is because the transcoder is not implemented at a software level but rather it's moved to a Hardware level.</p>
<h3 id="efficiency-while-adding-numbers">Efficiency While Adding Numbers</h3>
<p>Now the computer that I am building (Of course it's a virtual computer) uses a rather inefficient technique to implement an Adder. The carry bit is passed from one FullAdder to the another but in the real world, that's a lot of gates and will lead to a significant loss in time.</p>
<p>We have to remember that an Adder is supposedly the most fundamental part of a computer and it is necessary that we build it as efficiently as possible. Introducing a much more efficient Adding method, Carry Look Ahead. </p>
<p>it does exactly what it says, instead of having a carry while adding each set of bits, we prematurely calculate the carry bit as a separate set of operations to the bit addition. <a target="_blank" href="https://www.geeksforgeeks.org/carry-look-ahead-adder/">Here</a> is a good explanation for it.</p>
<p>By the way, the Virtual Machine that I am building is a 16-bit computer. So, the word length is 16 bits. Modern computers like the phone or laptop or whatever the screen you are reading this blog on are usually <a target="_blank" href="https://en.wikipedia.org/wiki/32-bit_computing">32-bit</a> or <a target="_blank" href="https://en.wikipedia.org/wiki/64-bit_computing">64-bit</a>.</p>
<p><em>PS: For readers who speak Telugu</em> <br />
<em>What is an ALU? ALU ante... ALU sir.</em> : ) <br />
<em>(If you know, you know)</em></p>
]]></content:encoded></item><item><title><![CDATA[Adding Things - Nand2Tetris]]></title><description><![CDATA[Some of the quotes and information are part of the Nand2Tetris course available on Coursera.
Representing decimal in binary
A decimal can be represented as a sum of powers of 2. In this way,
99 = 64 + 32 + 2 + 1 = 1100011

A word, please.
A word is a...]]></description><link>https://blog.sampath.dev/adding-things-nand2tetris</link><guid isPermaLink="true">https://blog.sampath.dev/adding-things-nand2tetris</guid><category><![CDATA[Computer Science]]></category><category><![CDATA[cpu]]></category><dc:creator><![CDATA[Sampath Balivada]]></dc:creator><pubDate>Thu, 21 Oct 2021 17:27:08 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1634976711435/vTpCCKx-Q.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p><em>Some of the quotes and information are part of the Nand2Tetris course available on Coursera.</em></p>
<h3 id="representing-decimal-in-binary">Representing decimal in binary</h3>
<p>A decimal can be represented as a sum of powers of 2. In this way,</p>
<pre><code class="lang-text">99 = 64 + 32 + 2 + 1 = 1100011
</code></pre>
<h3 id="a-word-please">A word, please.</h3>
<p>A word is a unit of data with a fixed number of bits. It tells us, how big of a number a computer can or particularly a processor can evaluate. Now we have 0 or 1 that we can represent using just a single bit. What happens if we want to represent maybe the number 2 or 3? We use 2 bits. So, the length is varying depending on the decimal number. We don't want a computer to guess if <code>110</code> is a <code>12</code> or if it's a <code>6</code>. A word defines that length. Now, if we have a 4-bit word, we represent <code>110</code> as <code>0100</code>.</p>
<h3 id="creating-an-alu">Creating an ALU</h3>
<p>The most fundamental thing in an ALU is the Addition functionality.</p>
<p>We build the basic arithmetic this way:</p>
<p>Addition -&gt; Negation -&gt; Subtraction -&gt; Comparision -&gt; (Multiplication -&gt; Division)</p>
<p>Multiplication and Division are implemented in software rather than in the hardware as they are easy to build that way. Multiplication is built using Addition and Division is built using Subtraction. That's the reason why Multiplication is less expensive than a Division operation. So, why is subtraction more expensive you ask. Good question, cause we subtract using a method like this.</p>
<pre><code class="lang-text">y - x = y + (-x)
</code></pre>
<h3 id="so-how-do-we-represent-negative-numbers">So, how do we represent Negative Numbers?</h3>
<p>Initially, we used something called a sign bit, but it's kinda not elegant.</p>
<blockquote>
<p>Usually if you don't have something elegant, it is going to bite you. </p>
</blockquote>
<p> So, now we use 2's complement to do this stuff, which is elegant. In 2's complement we represent all numbers as <code>2^n - x</code>.</p>
]]></content:encoded></item><item><title><![CDATA[Boolean Logic, Chips and HDL - Nand2Tetris]]></title><description><![CDATA[We can basically build anything with DNF
Basically, we can use the  Disjunctive Normal Form  to get a Boolean function that can be later simplified to well-known gates. The crux is that we simplify our implementation process by relying on simpler thi...]]></description><link>https://blog.sampath.dev/boolean-logic-chips-and-hdl-nand2tetris</link><guid isPermaLink="true">https://blog.sampath.dev/boolean-logic-chips-and-hdl-nand2tetris</guid><category><![CDATA[Computer Science]]></category><category><![CDATA[logic]]></category><dc:creator><![CDATA[Sampath Balivada]]></dc:creator><pubDate>Wed, 20 Oct 2021 18:52:03 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1634976675380/iZlb24U3J.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h3 id="we-can-basically-build-anything-with-dnf">We can basically build anything with DNF</h3>
<p>Basically, we can use the  <a target="_blank" href="https://en.wikipedia.org/wiki/Disjunctive_normal_form">Disjunctive Normal Form</a>  to get a Boolean function that can be later simplified to well-known gates. The crux is that we simplify our implementation process by relying on simpler things that we built in the past.</p>
<h3 id="how-exactly-can-we-prove-that-everything-can-be-built-using-nand-gates">How exactly can we prove that everything can be built using NAND gates?</h3>
<p>If we try to apply DNF to truth tables, we can deduce that every Boolean function can be represented using only AND, OR and NOT gates.</p>
<p>We can also derive OR using AND and NOT gates. (I am not going to tell you how. Hint: De Morgan's Law)</p>
<p>And by the power of combination, we have the NAND gate which can be used as an elementary gate to build every other gate and implement all Boolean functions that we want to.</p>
<h3 id="what-is-a-chip">What is a Chip?</h3>
<p>A chip or a gate provides an interface for the user. It specifies a set of input wires and the output wire(s). This is defined in an HDL stub file. The chip developer/builder has a contract that they will not change this. The chip designer decides what this interface will be.</p>
<p>A chip has to be implemented. The black box has to be defined by someone, that someone is the builder. They now use the magic of Boolean logic and the various gates available to them to implement the chip as defined by the interface and the truth table stated by the Designer.</p>
<p>Before we move to other stuff, we have to also make a note that hardware construction projects for these chips are made by two kinds of people.</p>
<ol>
<li>System Architect / Designer who creates the Chip API, test script, compare file for the chip interface.</li>
<li>Developers who implement the chip interface and develop the implementation for the chip defined. </li>
</ol>
<h3 id="more-about-hdl">More about HDL</h3>
<p>HDL is a functional/declarative language so order doesn't matter.</p>
<p>Common HDLs:</p>
<ul>
<li>VHDL</li>
<li>Verilog</li>
</ul>
<p>These HDLs are much more complex and have advanced functions like loops to ease the chip implementation process.</p>
]]></content:encoded></item><item><title><![CDATA[Logic Gates - Nand2Tetris]]></title><description><![CDATA[Some of the quotes and information are part of the Nand2Tetris course available on Coursera.
So chips or what we refer to as CPUs are created as a combination of gates. Usually in billions. These gates are transistors that are etched in silicon. So, ...]]></description><link>https://blog.sampath.dev/logic-gates-nand2tetris</link><guid isPermaLink="true">https://blog.sampath.dev/logic-gates-nand2tetris</guid><category><![CDATA[Computer Science]]></category><category><![CDATA[cpu]]></category><category><![CDATA[logic]]></category><dc:creator><![CDATA[Sampath Balivada]]></dc:creator><pubDate>Mon, 18 Oct 2021 17:03:39 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1634575397207/B2jLxiaAI.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p><em>Some of the quotes and information are part of the Nand2Tetris course available on Coursera.</em></p>
<p>So chips or what we refer to as CPUs are created as a combination of gates. Usually in billions. These gates are transistors that are etched in silicon. So, someone drew billions of transistors on a piece of metalloid (silicon) and now you are able to read this article on your device. Dammit... that's probably the most complex thing ever existed in the entire known history of humankind and the fact is that it is built on simple mathematical logic. This mathematical logic is combined and formulated as logic gates.</p>
<h3 id="what-is-a-logic-gate-then">What is a logic gate then?</h3>
<p>For starters, a  <a target="_blank" href="https://en.wikipedia.org/wiki/Logic_gate">logic gate</a>  is like a black box, that takes single or multiple inputs and produces a single output. So, if we were to imagine that in a real-world scenario, think of it like a cardboard box with copper wires going in and one wire coming out. We let electricity flow to different input wires and depending on which input wires have electricity flowing through them, something happens inside and we get electricity through the output wire or we don't.</p>
<p>Now, there are different types of logic gates like  <a target="_blank" href="https://en.wikipedia.org/wiki/AND_gate">AND</a>,  <a target="_blank" href="https://en.wikipedia.org/wiki/OR_gate">OR</a>,  <a target="_blank" href="https://en.wikipedia.org/wiki/XOR_gate">XOR</a>,  <a target="_blank" href="https://en.wikipedia.org/wiki/NAND_gate">NAND</a>, etc. Often in computer science, we say that computers are built using just one logic gate, i.e. NAND gate. This is because we can create any gate with a combination of NAND gates. We can basically chain one box's output to another box's input.</p>
<h3 id="do-we-really-use-only-nand-gates-in-a-cpu">Do we really use only NAND gates in a CPU?</h3>
<p>For a virtual computer, this can be okay but for an actual chip, it's not the most ideal way to go. For a real-world CPU, we can build a chip using different types of gates based on the different types of workloads that we run on the chip. Using multiple gates to create a new gate is not always the best way as less number of gates directly relates to speed. </p>
<h3 id="so-how-are-chips-designed-in-real-life">So how are chips designed in real life?</h3>
<p>Prototyping and testing chips practically in a lab is a costly affair. Fabrication is hard and very very costly. And if somehow we end up missing out on that one gate, it's more than impossible to repair something at the scale of nanometers. So we use  <a target="_blank" href="https://en.wikipedia.org/wiki/VHDL">VHSIC Hardware Description Language</a>  (VHDL or simply called HDL)</p>
<p><em>The above is my understanding of the hardware inside a computer from the perspective of a computer scientist and not a substitute for the actual learnings of a chip designer.</em></p>
]]></content:encoded></item><item><title><![CDATA[Abstraction - Nand2Tetris]]></title><description><![CDATA[Some of the quotes and information are part of the Nand2Tetris course available on Coursera.
We are usually worried about the what of everything we come across. What should I use to get an output? The print function. What should I use to get user inp...]]></description><link>https://blog.sampath.dev/abstraction-nand2tetris</link><guid isPermaLink="true">https://blog.sampath.dev/abstraction-nand2tetris</guid><category><![CDATA[Computer Science]]></category><category><![CDATA[algorithms]]></category><dc:creator><![CDATA[Sampath Balivada]]></dc:creator><pubDate>Sat, 16 Oct 2021 19:26:39 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1634412298696/Zw4jUFAjb.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p><em>Some of the quotes and information are part of the Nand2Tetris course available on Coursera.</em></p>
<p>We are usually worried about the what of everything we come across. What should I use to get an output? The print function. What should I use to get user input? The input function, etc.</p>
<p>But very few times, or at least never, we do not ask the question, How?</p>
<p>The "what" is abstraction and the "how" is implementation.</p>
<blockquote>
<p>Don't worry about the rest; just worry about what it's supposed to do and trust that someone else worried about the how.</p>
</blockquote>
<p>Separating concerns is the most potent tool in computer science. We forget the implementation once it's done and only care about what it does.</p>
<p>This really gives us a perspective about various problem-solving techniques that we use like divide and conquer, dynamic programming, etc. where we implement a solution for a small problem and then forget what it does and only zoom out and focus on the bigger picture that we get.</p>
<p>I would say, it is a boon that we are able to do that and all of this is possible only because we have efficient interfaces that we can talk with.</p>
<p>This also highlights the importance of good naming conventions and writing function and variable names that do and store what they exactly sound like. Now, we definitely don't have to worry about how something is implemented and trust the interface to actually depict what is happening under the hood.</p>
<p>I also recently discovered that Apple uses seriously long names for some of its iOS APIs. (I was unable to find the most recent API but here is an example. <a target="_blank" href="https://mackuba.eu/2010/10/31/the-longest-names-in-cocoa/">Link</a>). Now, maybe I can justify long names and actually write them out instead of trying to make them very short or have very weird names like "abc, "xyz" or the holy word "temp", which I suppose will definitely fail to represent what the function does.</p>
]]></content:encoded></item><item><title><![CDATA[Why am I building everything with Svelte now?]]></title><description><![CDATA[Note: This blog post is just an opinion and a take on why I have a personal preference.
Alright, let me confess a bit here. I'm not a fan of the frameworks. I understand the benefits they give me but given the scale at which I build stuff (literally ...]]></description><link>https://blog.sampath.dev/why-am-i-building-everything-with-svelte-now</link><guid isPermaLink="true">https://blog.sampath.dev/why-am-i-building-everything-with-svelte-now</guid><category><![CDATA[Svelte]]></category><category><![CDATA[javascript framework]]></category><category><![CDATA[Web Development]]></category><dc:creator><![CDATA[Sampath Balivada]]></dc:creator><pubDate>Fri, 15 Oct 2021 11:56:07 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1634298769667/S4n2fRmjD.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p><em>Note: This blog post is just an opinion and a take on why I have a personal preference.</em></p>
<p>Alright, let me confess a bit here. I'm not a fan of the frameworks. I understand the benefits they give me but given the scale at which I build stuff (literally next to none?), all those fancy frameworks like React, Angular, Vue and Flutter Web are just... you know, overkill.</p>
<p>I've always built my personal website and any short and small projects with plain and pure HTML, CSS and JS up until now. I've worked with a team to build a website for the Dept. of Computer Science and Engineering of my college which, lo and behold, we wrote in pure CSS and JS. Scary eh?</p>
<p>Yes it was, but we were the rebels we were and just hated all those bundling, transpiling, compiling and everything in the middle. And for our inexperienced eyes and hands, the document.getElementById() function was more than enough to build a website.</p>
<p>Of course, we completed the website and it was fast and all. It wasn't the most responsive website we ever built but hey, we were learning. </p>
<p>Fast forward to just an year ago, I would still prefer this plain old JS and CSS cause why not. It was getting my work done and I didn't have always tidy up everything into a bunch of folders and all. I just use a single JS file and make it as readable as possible.</p>
<p>I was building desktop apps with electron and building websites for a lot of purposes at the same time was building mobile apps with Flutter. I just missed the reactivity and reusability that Flutter offered. Although, I built applications with React at this point, I just knew it was overkill.</p>
<p>Now meet this new age framework I discovered, Svelte. Now this is a framework but it barely looked like one to me. Why? Cause it didn't change a lot of the structure of html and reactivity felt built in. Like I could just drop the document.getElementById() statements and call it a day cause it is just similar to vanilla web.</p>
<p>It also had an added advantage of components. So, I create a card and make it look exactly like I want it to but later when I find something annoying and have to change it, I just need to change it in a single file and the entire website will have the updated card without me copy pasting that card again and again. (I know we can achieve this in vanilla web as well but, confidence, confidence that we will never change that card again, but eventually we do)</p>
<p>So, I started using Svelte and discovered that a lot of things are already reactive, like do you want to reactively respond to a change in screen/window size? You can do that (without writing any additional functions). Only want to apply a CSS property to a h1 tag inside a component? That's the default way. Want to change the text color for all the text boxes? Yup, just edit everything in the global.css file. All of this while also being as close to actual vanilla web as possible. It felt like going from C to C++ rather than going from C to Java, C being vanilla web, C++ being Svelte and Java being frameworks like React JS.</p>
<h3 id="so-thats-it-svelte-is-the-framework-to-use-for-everything">So, that's it? Svelte is the framework to use for everything?</h3>
<p>Nah! At least not yet for me. Frameworks like react, vue and angular have huge communities around them building stuff. A lot of startups choose them for the same reason. Svelte, I would say is still very young and for some things, chances are that you need to create a package and release it out on npm. </p>
<p>For me it currently looks like a good way to introduce people to reactivity. In an age where people start learning React and then learn HTML, CSS and JS and try to wrap their head around JSX. This framework can be a good starting point to learn the building blocks of web and also understand why we need reactivity and reusability in our applications/websites.</p>
<p>Svelte, is now my de facto framework for building small projects with ease. If you would like to see the kind of projects that I build with Svelte, you can take a look at <a target="_blank" href="https://podcast.cacheho.in">podcast.cacheho.in</a> and my landing page <a target="_blank" href="https://sampath.dev">sampath.dev</a>. </p>
<p><em>The opinions stated in this blog post are my own and do not represent that of my employer.</em></p>
]]></content:encoded></item></channel></rss>