<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Archives on Madhav Khosla</title><link>https://madhavkhoslaa.github.io/archive/</link><description>Recent content in Archives on Madhav Khosla</description><generator>Hugo</generator><language>en</language><copyright>© Madhav Khosla</copyright><lastBuildDate>Thu, 08 Jun 2023 02:01:58 +0530</lastBuildDate><atom:link href="https://madhavkhoslaa.github.io/archive/index.xml" rel="self" type="application/rss+xml"/><item><title>Error handling in Rust.</title><link>https://madhavkhoslaa.github.io/archive/errors/</link><pubDate>Thu, 08 Jun 2023 02:01:58 +0530</pubDate><guid>https://madhavkhoslaa.github.io/archive/errors/</guid><description>&lt;p&gt;&lt;img src="https://madhavkhoslaa.github.io/images/VSG6kWK.jpeg" alt="image"&gt;&lt;/p&gt;
&lt;p&gt;Errors in any language are hard to handle since they include the caller, defining errors, handling them and reporting to the end user. In this blog I will explain how to handle and create errors in rust.&lt;/p&gt;
&lt;h1 id="types-of-errors"&gt;Types of Errors&lt;/h1&gt;
&lt;ol&gt;
&lt;li&gt;Unrecoverable Errors&lt;/li&gt;
&lt;li&gt;Recoverable Errors&lt;/li&gt;
&lt;/ol&gt;
&lt;h1 id="how-to-handle-unrecoverable-errors"&gt;How to handle unrecoverable Errors.&lt;/h1&gt;
&lt;p&gt;These errors are errors that make you want to stop the execution of the program. Like not being able to find a free port for starting the server, division by zero.
These errors use the &lt;code&gt;panic&lt;/code&gt; macro to stop the execution of the program in rust.&lt;/p&gt;</description></item><item><title>Functional Programming in Rust 2: Iterators</title><link>https://madhavkhoslaa.github.io/archive/rustiter/</link><pubDate>Sun, 20 Nov 2022 23:01:35 +0530</pubDate><guid>https://madhavkhoslaa.github.io/archive/rustiter/</guid><description>&lt;h1 id="iterator-design-pattern-what-is-it"&gt;Iterator Design Pattern, What is it?&lt;/h1&gt;
&lt;h2 id="example-1"&gt;Example 1&lt;/h2&gt;
&lt;p&gt;Let&amp;rsquo;s consider you are this tiny person in the image and you have to walk traverse the tree below. Ideally, how you traverse it, it does not matter what is the most important thing is &lt;strong&gt;1.&lt;/strong&gt; where you are and &lt;strong&gt;2.&lt;/strong&gt; Where you want to be when you go to the &lt;code&gt;next&lt;/code&gt; node.&lt;/p&gt;
&lt;p&gt;So in a way, an iterator design pattern(in real life) is a thought process of how you iterate a structure(not just a tree), or you know where you want(not how) to go &lt;code&gt;next&lt;/code&gt;.&lt;/p&gt;</description></item><item><title>Functional Programming in Rust 1: Closures</title><link>https://madhavkhoslaa.github.io/archive/functionalrust/</link><pubDate>Tue, 27 Sep 2022 02:01:58 +0530</pubDate><guid>https://madhavkhoslaa.github.io/archive/functionalrust/</guid><description>&lt;p&gt;&lt;img src="https://madhavkhoslaa.github.io/images/y0nqC0G.jpg" alt="image"&gt;&lt;/p&gt;
&lt;h1 id="what-is-functional-programming"&gt;What is Functional Programming?&lt;/h1&gt;
&lt;p&gt;It is a Programming Paradigm where you use functions to solve what you are building. The most common features that you might have used FP in any language will be Map and Reduce.
Where you pass in a function what iterates in the collection you run map or reduce on.&lt;/p&gt;
&lt;p&gt;Rust has some functional features too that I plan to write here.&lt;/p&gt;
&lt;h1 id="closures"&gt;Closures&lt;/h1&gt;
&lt;p&gt;Let&amp;rsquo;s do a quick Google search &amp;ldquo;closures&amp;rdquo;; The first result that comes to me is from MDN.&lt;/p&gt;</description></item><item><title>Understanding Rust Ownership</title><link>https://madhavkhoslaa.github.io/archive/rustownership/</link><pubDate>Sun, 03 Jul 2022 02:01:58 +0530</pubDate><guid>https://madhavkhoslaa.github.io/archive/rustownership/</guid><description>&lt;p&gt;Ownership is one of the features that make it different than so many programming languages and what makes it memory safe and a good language for concurrent programming. It solves problems like null pointers, dangling pointers and data races without a garbage collector at the run time.&lt;/p&gt;
&lt;h1 id="understanding-rust-ownership"&gt;Understanding Rust Ownership&lt;/h1&gt;
&lt;p&gt;&lt;img src="https://madhavkhoslaa.github.io/images/j5Pxkuu.jpg" alt="image"&gt;&lt;/p&gt;
&lt;h1 id="how-is-data-stored-in-the-program"&gt;How is data stored in the program?&lt;/h1&gt;
&lt;ol&gt;
&lt;li&gt;Stack&lt;/li&gt;
&lt;li&gt;Heap&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Data(variables in function arguments and defined) in the stack have a known type hence the size of the data in the stack is known at the time of compilation. However, data types like vectors and strings are bound to grow in size hence they are stored in the heap(their size cannot be determined at the time of compilation).&lt;/p&gt;</description></item><item><title>Creational Design Patterns: My lessons on it</title><link>https://madhavkhoslaa.github.io/archive/ceationaldesignpatterns/</link><pubDate>Fri, 24 Jun 2022 02:01:58 +0530</pubDate><guid>https://madhavkhoslaa.github.io/archive/ceationaldesignpatterns/</guid><description>&lt;h1 id="creational-design-patterns"&gt;Creational Design Patterns&lt;/h1&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;a href="https://refactoring.guru/design-patterns/creational-patterns"&gt;Creational design patterns provide various object creation mechanisms, which increase flexibility and reuse of existing code&lt;/a&gt;.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h1 id="why-were-they-made-and-why-should-you-care-about-reading-them"&gt;Why were they made and why should you care about reading them?&lt;/h1&gt;
&lt;p&gt;You must have noticed in a larger code base where multiple classes dealing with the class instantiation becomes too hard, in fact in the case of languages like java where the ecosystem expects everything to be a class; a framework called spring had been developed to solve the problem of instantiating classes(and so much more). So you get the scope of the problem of just the creation of objects.&lt;/p&gt;</description></item><item><title>SOLID Patterns: My lessons on it</title><link>https://madhavkhoslaa.github.io/archive/solid/</link><pubDate>Tue, 07 Jun 2022 04:01:25 +0530</pubDate><guid>https://madhavkhoslaa.github.io/archive/solid/</guid><description>&lt;p&gt;SOLID is just an acronym for a few principles that Robert C. Martin compiled together. SOLID Design principles aim to make your code base extensible, easy to modify in the future, and easy to debug and fix. They are &lt;em&gt;not rules&lt;/em&gt; just a bunch of thought ideas of segregation of logic and how to organize your code.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;S&lt;/strong&gt; =&amp;gt; &lt;a href="#1-Single-Responsibility-Principle"&gt;Single Responsibility Principle&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;O&lt;/strong&gt; =&amp;gt; &lt;a href="#Open-Close-Princple"&gt;Open Close Princple&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;L&lt;/strong&gt; =&amp;gt; &lt;a href="#Liskov-Substitution-Principle"&gt;Liskov Substitution Principle&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;I&lt;/strong&gt; =&amp;gt; &lt;a href="#Interface-Segregation-Principle"&gt;Interface Segregation Principle&lt;/a&gt;&lt;/p&gt;</description></item><item><title>Caching: My lessons on it</title><link>https://madhavkhoslaa.github.io/archive/post1/</link><pubDate>Sat, 19 Mar 2022 02:01:58 +0530</pubDate><guid>https://madhavkhoslaa.github.io/archive/post1/</guid><description>&lt;p&gt;Caching is a cheap way to scale a system&amp;rsquo;s performance in very less time. Being cheap and easy to implement on the top of a existing system it also brings some problems such as invalidation and infrastructure for setting up the cache itself. Here I plan to talk about some lessons on caching that I&amp;rsquo;ve learnt in a few months.&lt;/p&gt;
&lt;h1 id="philosophy-of-caching"&gt;Philosophy of Caching&lt;/h1&gt;
&lt;p&gt;&lt;em&gt;The supreme art of war is to subdue the enemy without fighting it - Sun Tzu&lt;/em&gt;&lt;/p&gt;</description></item></channel></rss>