<?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" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Saksham Gupta on Medium]]></title>
        <description><![CDATA[Stories by Saksham Gupta on Medium]]></description>
        <link>https://medium.com/@saksham2410?source=rss-703e3bdfe2da------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*Lrn0JEyib_1OVJXF</url>
            <title>Stories by Saksham Gupta on Medium</title>
            <link>https://medium.com/@saksham2410?source=rss-703e3bdfe2da------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 02:57:33 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@saksham2410/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[HTTP/2 — Introduction to gRPC]]></title>
            <link>https://medium.com/@saksham2410/http-2-introduction-to-grpc-91342c569516?source=rss-703e3bdfe2da------2</link>
            <guid isPermaLink="false">https://medium.com/p/91342c569516</guid>
            <category><![CDATA[proto]]></category>
            <category><![CDATA[grpc]]></category>
            <category><![CDATA[protobuf]]></category>
            <category><![CDATA[http2]]></category>
            <category><![CDATA[http-request]]></category>
            <dc:creator><![CDATA[Saksham Gupta]]></dc:creator>
            <pubDate>Fri, 29 May 2020 18:02:44 GMT</pubDate>
            <atom:updated>2020-05-29T20:16:03.558Z</atom:updated>
            <content:encoded><![CDATA[<h3>HTTP/2 — Introduction to gRPC</h3><p>A revolutionary technology that really improves internet communication.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/763/0*dcnC2wwwzxa8GJPu.jpg" /><figcaption>(Source: poweredbysearch.com)</figcaption></figure><p>So, before we look into HTTP/2 too let’s take a step back and understand how most of the web works today, which is HTTP/1 request.</p><p>Just to give you the general idea and some shortcuts to understanding the differences, HTTP/1.1 was released in 1997 which was a long time ago and it has worked for many years but the Internet has changed and evolved while the standard really never changed.</p><h3><strong>How HTTP/1 works and it’s disadvantages.</strong></h3><blockquote>Nowadays, every website loads approx. <strong>50–100 assets on average</strong>, and headers are sent at every request and are of the form <strong>PLAINTEXT</strong> (heavy size)</blockquote><blockquote>HTTP/1 open a new <strong>TCP</strong> connection to a server at each request (One Open Request Per Connection).</blockquote><blockquote>No <strong>header compression</strong> is there. The <strong>duplication of data</strong> across requests (cookies and other headers) is a major problem with HTTP/1.</blockquote><blockquote>It only works with <strong>Request/Response mechanism</strong> (no server side push is there).</blockquote><blockquote>These inefficiencies add <strong>latency</strong> and increase network <strong>packet</strong> size</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/440/0*VG6hpKArbO_Tj9B3.png" /><figcaption>(Source BccFalna.com)</figcaption></figure><p>This diagram basically depicts the working of HTTP/1 request. Originally, it comprised of only <strong>GET</strong> and <strong>POST</strong> methods. One connection per request.</p><h3>How HTTP/2 works and it’s Advantages.</h3><p><strong>HTTP/2 supports Multiplexing</strong></p><blockquote>The client and server can push messages in parallel over the same TCP connection. This greatly reduces latency</blockquote><p><strong>HTTP/2 supports server push</strong></p><blockquote>Servers can push streams(multiple messages) for one request from the client. This saves round trips (latency)</blockquote><p><strong>HTTP/2 supports header compression</strong></p><blockquote>Headers can now be compressed. These have much less impact on the packet size. (Average http request can have over 20 headers including cookies).</blockquote><p><strong>HTTP/2 is binary</strong></p><blockquote>(Protocol buffers is a binary protocol used in HTTP/2)</blockquote><p><strong>HTTP/2 is secure</strong></p><blockquote>SSL is not required by default but recommended.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*rsoyG1zID1SF8kZq.png" /><figcaption>(Source: phpclasses.org)</figcaption></figure><p><strong>A comparison of HTTP/2 and HTTP/1.1</strong></p><p>The following image was broken into 80 different tiles. Let’s see the difference between data transfer in form of 80 connections (HTTP/1.1) and 1 connection (HTTP/2)</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2FiDIbr2l8JY8QTGD3Ob%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fgiphy.com%2Fgifs%2FiDIbr2l8JY8QTGD3Ob&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="193" frameborder="0" scrolling="no"><a href="https://medium.com/media/76a59f8fb0d7176e2f346da83ac181d0/href">https://medium.com/media/76a59f8fb0d7176e2f346da83ac181d0/href</a></iframe><h3><strong>How to use HTTP/2 in your applications?</strong></h3><p>The most common way these days to use HTTP/2 connection out of the box is by using the <strong>gRPC framework</strong>.</p><blockquote>Building an API is hard. You need to think about a lot factors such as Data Models, Endpoints, how to invoke it and how to handle errors, thinking about the efficiency of the API, latency, scalability, load balancing, inter operability with other languages, authentication, monitoring, logging?</blockquote><p>The most common way to build API’s is by using HTTP-REST framework. But do you want to leave all that boring stuff and just do the logic part? <strong>That’s gRPC for you!</strong></p><p>What is an API at it’s core, it’s just a contract saying that I need this data (Send a Request) and Here’s your data (Sends you the response). <strong>gRPC</strong>, at a high level, allows you to define request and response for <strong>RPC (Remote Procedure Calls)</strong> and handles the rest for you.</p><p>RPC is a Remote Procedure Call, at the Client Code, it just looks like you’re calling a function from the server. It supports streaming, language independent, low latency.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/638/0*QGku6HQCg_NAdzIh" /><figcaption>(Source: SlideShare)</figcaption></figure><p>So, at the core, you need to define the messages and services using Protobufs, and feed it to the protoc and gRPC Compiler. The rest of the gRPC code will be automatically generated for you and you just need to provide an implementation for it. <br>Example of a .proto file —</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b4f41a5ea0981c62fff7211883b2b0f3/href">https://medium.com/media/b4f41a5ea0981c62fff7211883b2b0f3/href</a></iframe><p>(If you don’t know about Protocol Buffers, it’s an evolved way of JSON, the data is binary and efficiently serialised. It’s very convenient for transporting a lot of data)</p><p>We can compile this code by using</p><blockquote>protoc -I=. ./{fileName}.proto \</blockquote><blockquote>— js_out=import_style=commonjs,binary:./{output_directory} \</blockquote><blockquote>— grpc_out=./{output_directory} \</blockquote><blockquote>— plugin=protoc-gen-grpc=`which grpc_tools_node_protoc_plugin`</blockquote><p>The above command is used for compiling the code to work with common js files.</p><p>Now, if you’ll go and check your output_directory, you can see that there are two files there — <strong>{fileName}_pb.js</strong> and {<strong>fileName}_grpc_pb.js.</strong></p><p>Try to read those files and you can see that gRPC automatically made the definitions of all the messages and their objects. Now the only part left is implementing them in the client and server.</p><p>PS:- The type of service we created is a <strong>unary API in goRPC</strong>. There are <strong>3 more types of API’s in gRPC</strong> which we will cover in the <strong>next story</strong> where we’ll built a full app using HTTP/2 and gRPC</p><p>That’s all for this story. :)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=91342c569516" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[CSR, SSR or PSSR?]]></title>
            <link>https://medium.com/@saksham2410/csr-ssr-or-pssr-4f7759cbf3fb?source=rss-703e3bdfe2da------2</link>
            <guid isPermaLink="false">https://medium.com/p/4f7759cbf3fb</guid>
            <category><![CDATA[csr]]></category>
            <category><![CDATA[ssrs]]></category>
            <category><![CDATA[faster-web-apps]]></category>
            <category><![CDATA[progressive-rendering]]></category>
            <category><![CDATA[progressive-web-app]]></category>
            <dc:creator><![CDATA[Saksham Gupta]]></dc:creator>
            <pubDate>Thu, 21 May 2020 20:31:10 GMT</pubDate>
            <atom:updated>2020-05-21T20:58:11.780Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*B-a0_BtnV8TsXQXzpYfbng.png" /></figure><h3>Client Side Rendering (CSR)</h3><p>With a client-side rendering solution, you redirect the request to a single HTML file and the server will deliver it without any content (or with a loading screen) until you fetch all the JavaScript and let the browser compile everything before rendering the content.</p><p>Page load behaviour in Client Side Rendering :-</p><ol><li>Browser makes a request to the server for HTML Server sends back the HTML with script tags in head and no content in body</li><li>Browser parses the HTML and makes http requests to load the scripts. Once the scripts are loaded, the browser parses them and makes API requests and loads all the content asynchronously.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*GRUKIy5W_rOHH6ts.png" /><figcaption>(Source : developers.google.com)</figcaption></figure><p>Under a good and reliable internet connection, it’s pretty fast and works well. But what happens when we are on a high latency and low bandwidth network?</p><p>Some <strong>Pros</strong> of <strong>CSR</strong> are :-</p><ol><li>Fast website rendering after the initial javascript load, the <strong>content can be loaded asynchronously</strong>. The<strong> critical content </strong>can be loaded<strong> first</strong> and then <strong>non-critical content later</strong>.</li><li>Good for web applications. Server serves static HTML and initial load JavaScript bundles can be <strong>cached</strong> in the browsers which may benefit frequent users. Also provides a robust selection of JavaScript libraries.</li></ol><p>Some <strong>Cons</strong> of <strong>CSR</strong> are :-</p><ol><li>Initial load takes longer time because JavaScript <strong>blocks content load</strong>. The larger your bundle size is, the longer it will take to show content on the page.</li><li>API requests are not co-located with the browser location. This may take even longer in slower networks due to high latency and low bandwidth.</li><li><strong>Low SEO </strong>if not implemented correctly<strong>, SEO</strong> scores take a huge hit since search engines don’t execute JavaScript and only an empty page is indexed.</li></ol><h3>Server Side Rendering (SSR)</h3><p>Server rendering generates the full HTML for a page on the server in response to navigation. This avoids additional round-trips for data fetching and templating on the client, since it’s handled before the browser gets a response.</p><p>Server-side sends a fully rendered page to the client; the client’s JavaScript bundle takes over and allows the SPA framework to operate.</p><p>Page load behaviour in Server Side Rendering :-</p><ol><li>Browser makes a request to the server for HTML. Server makes API requests (usually co-located) and renders the content in the server.</li><li>Once the page is ready, the server sends it to the browser. The browser loads and parses the HTML and paints the content on the screen without waiting for the JavaScript bundle(s) to load.</li><li>Once the JavaScript bundle(s) are loaded, the browser hydrates interactivity to DOM elements, which is usually attaching event handlers and other interactive behaviours.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/994/0*FJhKbVwt-QwAZx19.png" /><figcaption>(Source: developers.google.com)</figcaption></figure><p>Now Imagine that a user clicks a link on a page, the browser sends a request to the server and the entire process is carried out by the server again. This process not only increases the load on the server but also consumes unnecessary internet bandwidth.</p><p>Some <strong>Pros</strong> of <strong>SSR</strong> are :-</p><ol><li>It enables pages to load faster which provides a better user experience. Since the server serves <strong>HTML with content</strong>, neither the browser nor search engines have to depend on JavaScript for the content.</li><li>It plays an important role in SEO and correctly indexes webpages. (Google favours web pages with faster load time.)</li><li>It provides body to the HTML pages for all server ships and Content is <strong>not</strong> blocked by the time taken to load JavaScript bundle(s).</li><li>Page loads a lot <strong>faster than CSR</strong>.</li></ol><p>Some <strong>Cons</strong> of <strong>SSR</strong> are :-</p><ol><li>Rendering a big application on the server-side can be very time consuming and it may increase the loading time due to it being a single bottleneck. The entire HTML has to be rendered on the server before sending it to the client, non-critical content has to be rendered on the server before sending the response HTML to the client.</li></ol><h3>Progressive Server Side Rendering (PSSR)</h3><p><strong>Progressive Server Side Rendering </strong>allows you to send HTML in chunks that the browser can progressively render as it’s received. This can provide a fast <strong>First Paint </strong>and <strong>First Contentful Paint</strong> as markup arrives to users faster. You <strong>render the critical content</strong> on the server, you start <strong>streaming it to the client without waiting for non-critical content</strong>. You then stream the non-critical content later once it’s rendered on the server.</p><p>Page load behaviour in Progressive SSR :-</p><ol><li>The procedure is same as of SSR but it renders only the critical content first in the server and streams it to the browser.</li><li>It (browser) then receives chunk of HTML and renders it on the screen. Server renders non-critical content after rendering critical content and streams it to the client.</li><li>Once the entire page is loaded, the browser hydrates interactivity to DOM elements, which is usually attaching event handlers and other interactive behaviours.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*egF_5zJuu-dzZJVn.png" /><figcaption>(Source : divante.com)</figcaption></figure><p>Progressive rendering actually takes the benefits from both CSR and SSR, because the APIs are co-located in the server and at the same time, <strong>critical content can be rendered quickly without having to wait for non-critical content.</strong></p><p>Some <strong>Pros</strong> of <strong>PSSR</strong> are :-</p><ol><li>Very useful for slower networks. We can render on server but stream critical content to client without waiting for non-critical content.</li><li>Page loads faster than both CSR and SSR because Content is not blocked by the time taken to load JavaScript bundle(s).</li></ol><p>Some <strong>Cons</strong> of <strong>PSSR</strong> are :-</p><ol><li>The hydration of the DOM and attaching of event listeners takes place only after the whole page is rendered. Even though content shows up quickly, interactivity will be enabled only after non-critical content is loaded.</li><li>No framework as such for progressive rendering.</li></ol><h3>How to do progressive rendering?</h3><p>Progressive rendering is possible by streaming HTML. In Node.Js you can use streams to build applications, read more about it <a href="https://www.freecodecamp.org/news/node-js-streams-everything-you-need-to-know-c9141306be93/">here</a>.</p><p>Node.Js has this <a href="https://nodejs.org/api/stream.html#stream_readable_streams">Readable</a> API which will let you pipe a readable stream.</p><p>Here’s a great <a href="https://nodesource.com/blog/understanding-streams-in-nodejs/">link</a> to learn about streams and implement them. An example code would look like :-</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d8063e106fa97d80dce71729487c7f5a/href">https://medium.com/media/d8063e106fa97d80dce71729487c7f5a/href</a></iframe><p>Attaching below is a website to compare the usage of progressive rendering and server side rendering.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2FJR6YeTk1khbZQmkvxD%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fgiphy.com%2Fgifs%2FJR6YeTk1khbZQmkvxD&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="250" frameborder="0" scrolling="no"><a href="https://medium.com/media/a737d8dcfb92bb4b3e519fa6a68e0b55/href">https://medium.com/media/a737d8dcfb92bb4b3e519fa6a68e0b55/href</a></iframe><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2Fj0Yp9YGPxVBm03YICC%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fgiphy.com%2Fgifs%2Fj0Yp9YGPxVBm03YICC&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="261" frameborder="0" scrolling="no"><a href="https://medium.com/media/bc5c7526ea3ee7614bcebdd639c0a8b0/href">https://medium.com/media/bc5c7526ea3ee7614bcebdd639c0a8b0/href</a></iframe><p>We can also see the results from perf profiling. It shows a clear performance boost in content load up of the website.</p><figure><img alt="Perf profiling with progressive" src="https://cdn-images-1.medium.com/max/734/1*Aoc2yfcqfuhnz1PjzTIJGQ.png" /><figcaption>Perf profiling with progressive</figcaption></figure><figure><img alt="Perf profiling without progressive" src="https://cdn-images-1.medium.com/max/734/1*Wy1xcwAV1yra1WlizfPYlw.png" /><figcaption>Perf profiling without progressive</figcaption></figure><p><strong>That’s all folks!</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4f7759cbf3fb" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Writing smart contracts on Remix!]]></title>
            <link>https://medium.com/@saksham2410/writing-smart-contracts-on-remix-84d4f57a247?source=rss-703e3bdfe2da------2</link>
            <guid isPermaLink="false">https://medium.com/p/84d4f57a247</guid>
            <dc:creator><![CDATA[Saksham Gupta]]></dc:creator>
            <pubDate>Wed, 20 May 2020 17:03:59 GMT</pubDate>
            <atom:updated>2020-05-20T17:07:15.298Z</atom:updated>
            <content:encoded><![CDATA[<h3>Writing smart contracts with Remix!</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*K2FGMxW0XFSzK2H9S9eLAw.png" /></figure><p>We can use any type of code editor to work with solidity, but in this story I will be working with remix. You can access remix from <a href="https://remix.ethereum.org/">here</a>. I personally like to use remix a lot because it’s got a lot of built in tools for both auditing and analysing your code and in general it just kind of works nicely.</p><p>So, after navigating to that link, You’re going to immediately see a bunch of code inside of a code editor. Yeah there’s a lot of code there and we don’t really understand of any of it just yet. So, let’s just delete all of the code and start from scratch.</p><p>We’ll start off by writing <strong>pragma solidity ^0.6.8 .</strong></p><p>Now this is just a declaration to tell the compiler the version of solidity we are using, so that it doesn’t break in the future when new changes are added. It tells the compiler, <strong>‘Oh! So this code is using an older version and I have to compile it according to the rules of that version’, .</strong></p><p>Now, we’ll define our contact Test and the syntax is much similar to the JavaScript syntax you might be familiar with. In fact, solidity is very similar to JavaScript but contains a few <strong>‘Gotcha’s’, </strong>so we’ll start by defining a public string initialMessage and a constructor function along with the setMessage function.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/03a36519626cf9c4394d5c03a70d136c/href">https://medium.com/media/03a36519626cf9c4394d5c03a70d136c/href</a></iframe><p>There are two types of variables used in solidity, storage and memory.</p><p>The first is “<strong>storage</strong>”, where all the contract state variables reside. Every contract has its own storage and it is persistent between function calls and quite expensive to use.</p><p>The second is “<strong>memory</strong>”, this is used to hold temporary values. It is erased between (external) function calls and is cheaper to use.</p><p>Now we’ll try to compile and run it an <strong>In-browser Fake Network.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/365/1*xxai9GMzwfLayo05NuDtag.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/362/1*kdXgbEzhugVQxiXr8-Bhvw.png" /></figure><p>First, you have to Activate Two Modules from the Plug type Icon. <strong>DEPLOY AND RUN TRANSACTIONS</strong> and <strong>SOLIDITY COMPILER. </strong>After doing so, click on Compile and check for red flags (if any).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/367/1*KM_tf71afaba1rK-EPiACw.png" /></figure><p>Select the JavaScript VM option in ENVIRONMENT dropdown, so that we can create a Fake Network in our Browser JavaScript .</p><p>Select any account from the dropdown menu, all these are fake accounts. (Notice that you have 100 ethers in all accounts to start with )</p><p>Let the value of GAS LIMIT be 3000000 for now, i’ll explain what this means in a while.</p><p>Select the file in which you made your changes in CONTRACT dropdown option.</p><p>Enter a “ string “ to give the constructor argument and click</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/372/1*yWZ_KjbVRlCZGQS_AtJJEQ.png" /></figure><p>on deploy the network.</p><p>Now you’ll see your contract deployed with the function buttons. You can try them out by setting a message and getting the same message back with the initialMessage function (The constructor function is made by default in remix).</p><p>Now, if you check you can see that the account you used has a reduced balance from 100 ether. This is the cost of modifying something.</p><p>The <strong>Gas Limit</strong> is the maximum amount of Gas that a user is willing to pay for performing action or confirming transaction</p><p>The <strong>price of Gas (Gas Price)</strong> is the amount of wei that the user is willing to spend on each unit of Gas.</p><p>So, the interesting part is, calling a function is free of cost and it cannot modify the contract’s data. It can return data and runs instantly. However, sending a transaction to a function can modify a contract’s data. It takes time to execute and returns the transaction Hash (See the console).</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=84d4f57a247" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>