!A code full of nulls

I recently switched out to a functional based approach on how we communicate absence of value to the function caller. Given in C hash CSharp it’s usually null but that needs more care than letting the compiler guide us. In this article I will cover the functional equivalent of communicating absence of value functionally using types instead of nulls in languages where its predominant. It will provide you insights into how it’s a more safer way to ensure that when your system crashes the next time it’s definitely not because of a null pointer exception....

January 12, 2025 · 6 min · 1158 words · Lakshya Singh

Reversing Wheel File

Let’s talk about wheel today, definitely hoping it was a ferris wheel but its going to be python’s wheel for now. A wheel file is a relocatable package format for distribution of python packages for easy, quick and deterministic installations. All the packages published on pypi have under their Download files section a tar file and whl file. For example you can head over to Django and download its wheel file which can then be installed simply by doing...

June 14, 2024 · 4 min · 744 words · Lakshya Singh

Union/Sum Type

Let’s take an example of operating system information as a data structure to better understand sum types. Struct Our bare minimum struct to represent an operating system contains a few common fields that would exist in each of the operating system. typedef struct { char organization[]; int releaseYear; float version; int is_opensource; } os; It’s missing one thing though the type of operating system like macOS, linux, windows, etc. Enum We will add in a new field into our structure to represent the type of operating system by using an enum....

January 20, 2024 · 7 min · 1301 words · Lakshya Singh

Kotlin Coroutines

Coroutine A coroutine is an instance of a suspend-able computation. It is conceptually similar to a thread, in the sense that it takes a block of code to run that works concurrently with the rest of the code. However, a coroutine is not bound to any particular user level thread. It may suspend its execution in one thread and resume in another one. This scheduling of coroutines is handled by the Kotlin dispatchers similar to go runtime...

January 14, 2024 · 8 min · 1522 words · Lakshya Singh

Goroutines

A goroutine is a lightweight thread of execution managed by the Go runtime. To start a new goroutine we use the go keyword go f(x, y, z) The evaluation of f, x, y, and z happens in the current goroutine and the execution of f happens in the new goroutine. Goroutines run in the same address space, so access to shared memory must be synchronized. The sync package provides useful primitives, although you won’t need them much in Go as there are other primitives like channels....

December 24, 2023 · 4 min · 843 words · Lakshya Singh