Posts

On Abstractions: Simplify by omiting unimportant details and writing deep modules

Image
Modular Design Good software is almost always decomposed into modules that are relatively independent of each other. Independent modules makes congitive load easier on the developer working on the software. In an ideal scenario this independence is hard to achive. A good guiding principle to create best modules is to write deep modules. Deep Modules  Shallow Modules

Browser Rendering Phase

Image
A browser render at 60fps. We often call it framerate . A second is 1000 millisecond. That's ~16.66ms spent to render each frame. If this rate is maintained by the browser everything on a website will seem silky smooth. When this framerate drops, users experience jank. A jank is when there is any stuttering or choppiness in motion on screen - for e.g., scrolling, transitions, animations. This negatively affects user experience (UX). Jank is the result of the browser not being able to budget its compute within the 16 ms for each frame. To understand how tight that time window here is a fun fact. The duration of a blink is on average is 100–150 milliseconds according to this  UCL research . That is way less time than a blink of an eye. What's going on behind each frame render? In this post, I attempt at an oversimplified articulation of 6 stage before a frame is rendered. I try to walk through the entire length of that 'rendering' process without getting into too many de

Nullish Coalescing Operator??

The || (OR) operator  The || (OR) operator will return the right operand if the left operand is falsy (false, 0, empty string, null, undefined, NaN). When to use? Use || when you want to provide a fallback for any "falsy" value. ?? (Nullish Coalescing) operator The ?? (Nullish Coalescing) operator will only return the right operand if the left operand is null or undefined. When to use? Use ?? when you want to provide a default value for null or undefined, but consider 0 and empty strings to be valid values. Example

til: localhost & 127.0.0.1 are not same origin 🤯

The IP address for localhost is traditionally 127.0.0.1, so you’d expect http://localhost:9999 and http://127.0.0.1:9999 to be the same origin. BUT. The origin comparison only compares the string values of the scheme, host, and port, and knows nothing about what host an IP address maps to. In my example, “localhost” and “127.0.0.1” are different strings, and therefore the request isn’t a same-origin request.

Writing is a practice; Documentation a product

Lately I've been trying to contribute to open source and I've realized that most communication that I have are written communication. I have to write down my thought process, my implementation detail, test cases, and to some extent even pseudo code as comments on a pull request before submiting a decent change.  This is contrary to what I am used to when working in a corporate environment. I am familiar with meetings scheduled with my mentor/senior/lead/peers/team where we go through stuff verbally & through screenshare. It's quick and easy(just like fast food but not necessarily healthy). All that communication is lost in the ether once we click on 'End Call'. No trace remains of all that useful knowledge that was communicated over the call. My writings aren't great I am aware. Yet these ill-formed bits of written communication help me tremendously to construct my thoughts better. Also, if I am neck deep into a change I still have access to the trail of com

Identity in Javascript

"Proof by analogy is fraud." ~ Bjarne Stroustrup

What really is a Hypertext?

Image
The word 'hypertext' appears almost always among Web jargon that is abbreviated such as HTTP, and HTML. What is it? How significant is Hypertext to the Internet? 🔦 Background A lot of us will never be able to fully appreciate the effects of implementing Hypertext as an Information Management System on the Internet. Before hypertext became popular the Internet was just a vast repo of scattered & isolated information items(or objects) that was hard to search & navigate. Hypertext brought  order & organization to an Internet that was difficult to use and disorganized due to its distributed & decentralized nature. P.S Hypertext comes under the field of Information Mapping which then comes under the field of Information Management. 💡What was the necessity for Hypertext? The first 'browser' was developed to combat information loss at an org due to people leaving & make information discovery possible for new people joining the org. The org here was CE

🆘Intterupts got me thinking..

I was unaware of an infinite loop in a  Go  program I wrote. Thankfully, I knew Ctrl + C could get me out of this never-ending program execution. But I was curious about the way  Ctrl + C   interrupts my program execution.  What makes them so powerful is that they can stop the execution of a running program.  So, why does this mechanism exist? These are my findings, When I  Ctrl + C  on a running  Go  program it exits as follows,  exit status 0xc000013a                               Signals are an integral part of operating systems. The signalling mechanism is commonly known as interrupts .  Ctrl + C  is one such interrupt. Processes generate signals in three basic situations: Unexcepted situation occurs. Use of key combinations like  Ctrl + C  or  Ctrl + Z  on the console by the user. Timer expires, the CPU usage limit applied to the application is high etc. Common signals that I have encountered, Signal Name Signal Number Singal Action * Description SIGHUP 1 Term Hang up detected o

jest: javascript testing framwork

Image
"Jester's privilege is the ability and right of a jester to talk and mock freely without being punished." In this post, I will be playing with some of the tools under a jest.js ' belt that helps him deploy his privilege.  A basic building block of the jest.js program is a test. A test is a series or a singular combination of expectation  followed by a matcher . The simplest way to explicitly specify an expectation is using the expect method. When Jest runs, it tracks all the failing matchers and prints out error messages based on that.

Crypto crypto everywhere but not a token to bet your life on

Over 7000 cryptocurrencies are in existence as of today - which one will survive?  Let's make an attempt to weed out some noise from the crypto landscape so that we can focus on the signals.  Firstly,  Metcalfe's Law  states that the value of a network is proportional to the square of the number of its users. This will be a good indicator to predict less erroneously the one crypto that will rule out the rest. Scarcity is another metric. Scarcity leads to novelty. Humans love to possess novel things. So cryptos leaning to scarcity in the near or far future could be a way to go. The metric to go by, in this case, would be Maximum Supply . It is the best approximation of the maximum amount of coins that will ever exist in the lifetime of the cryptocurrency. The total number of BTC will never exceed 21 million. The hard cap is a limit that is written in Bitcoin's source code and enforced by network nodes.

JavaScript - Values,Types, Operators. Things that you should not take lightly.

Understanding the behavior of operators on values is an important aspect every beginner should take care of. Doing so will not only help you in the longer run but also help you understand certain unexpected behavior your code might put forward to you. While learning any programming language it is quite common that you might skip the fundamentals and directly dive into advance concepts and start writing code. Well, that can prove good for some who has good grasp and observation skill, it is not recommended for the others. In this post we will be looking at values and understand how they constitute what we call as data. Then we will discuss data types which are nothing but categorization of values into different types such as Numbers, String, Boolean etc. Now we have the basic building block and then we look into the manipulation of data types using operators.   VALUES When you type your name into a program the computer stores it in the form of bits. So anything meaningful tha

Python implementation of UDP

Image
User Datagram Protocol is one of the oldest protocol in existence that has been used extensively in client/server applications. Based out of the principal communications protocol, called Internet Protocol (IP), UDP is an alternative for TCP which stands for Transmission Control Protocol. Queries regarding which among the two protocol can be a better choice should be determined only after answering questions based on the context for which you are writing the code for. Since UDP is known for its unreliability, it is important that you use it right. Without any error checking or error correction involved in data transmission  UDP is often used in video chat applications because a fall in a packet or two doesn't affect final outcome.  The following post will be focused on developing a client server application that will implement using Python. The program can be passed arguments namely - "client" and "server" and the program acts accordingly.

virtualenv, isolated Python environment for developer dilemmas.

Image
Virtual environment generally refers to self defined instances of software. Installing packages in Python requires system privileges and leaves the system Python installation altered. All this may lead to unintentional upgrade of an application and thereby causing dependency issues and errors. Developers need not suffer this situation anymore. All we need to do is install one Python package system-wide, and we call it " virtualenv ". Once  virtualenv  is installed, you have the power to create any number of small, self-contained “virtual Python environments” where packages can be installed and uninstalled and with which you can experiment, all without contaminating your system-wide Python. When a particular project or experiment is over, you simply remove its virtual environment directory, and your system is clean. This eliminates the common developer dilemma - Project X requires version 1.x.x  but Project Y requires 4.x.x . virtualenv  is a tool to create

Request for Comments (RFC) downloader using Python "urllib".

Image
A  Request for Comments  ( RFC ) is a type of publication from the  Internet Engineering Task Force  ( IETF ) and the Internet Society (ISOC), the principal technical development and standards-setting bodies for the Internet. This was one of the code that I started with while learning Python Network Programming. This tutorial focuses on how to use the "urllib" library and how to connect to a particular website and connect to it. We also see how the python script that we write gets the source code of the page that we request and displays it on the terminal. The code for the "rfc downloader" is as follows and it can also be found on my Github repository. The program takes in the value of the RFC that you want to display on your terminal as a command line argument and then executes so make sure you supply a valid RFC number for executing it. For instance we give the argument value of "400" and we see the output in the terminal, we also go to

Basic Logging with Python (create .log files)

Image
There are a lot of things that you program does while being executed. and it is highly likely that your code in execution might face a plethora of pitfalls while its journey. It is always wise to have your code speak for itself and that it maintains its own personal diary of what checkpoints it has crossed and where exactly did it face any error during execution - some people call it as the LOG. Logging is the means of tracking events that happen when some software run. We as developers add logging calls in our code to indicate that a particular event has taken place. There are a set of logging functions for our simple logging usage. I've mentioned then as follows. debug() info() warning() error() critical() To use the above methods we are required to import the package called "logging". The above mentioned logging functions are named after the severity of the events that they are used to track.  Following are the most important levels : DEBUG is nothin