Below you will find pages that utilize the taxonomy term “programming”
Posts
About Fast Compilation of Go
Is Go Fast? Go is faster than interpreted languages like python in terms of sheer execution since it’s compiled to native executable format.
Go is slower than other compiled languages like C,Rust in terms of execution. This is primarily because although compiled go runs with a ‘runtime’ which does some housekeeping (scheduling and multiplexing goroutines, managing/freeing memory (GC) etc). This overhead is much smaller than a virtual machine required for languages like java but is an overhead nonetheless.
read morePosts
Did you read the logs?
Logs Logs (in a very degenerative sense) are a series of events/statements that act like the breadcrumb for the things that happened. Degenerative as I am referring mostly as application or software logs. (More pure meaning would be let’s say database logs which are used for replication process or a series of events for active state machine replication). I want to talk about the logs (application logs, system logs).
For interested reader, I highly recommend I heart logs which talks about the power of logs in a distributed systems - how a series of immutable logs help us chronologically capture a series of events and computing/coming to consensus/committing transaction etc on top of it.
read morePosts
Geo Routing (Craigslist Example)
Geo-Routing (Case Study on Craigslist) When you open craigslist.org it does a couple of redirection before finally landing on the subdomain closest to your city. Having separate sub-domain and listings for those particular cities is partly how it seems to handle the distribution of the content. (making it more scalable)
Give it a try: https://craigslist.org
Here is the journey of the request:
curl -I craigslist.org HTTP/1.1 301 Found Location: https://www.craigslist.org/ redirected to https://www.
read morePosts
ChatGPT Notebook - A Chrome Extension
Trend of LLM Large Language Models continue to find new use cases. Though they started off as smart chatbots developers are using the open source models (thanks to corporates like Meta who open source models and no thanks to OpenAI) and fine tuning them to be used for specific domains. It’s so obvious that in the future these LLM are going to be our personal copilot, our wingman each tailored to each individual.
read morePosts
Literate Programming
Literate Programming Python notebooks are so ubiquitous in the Machine learning community. All the cloud providers have dedicated services to run these notebooks: Jupyter on AWS, Jupyter on Azure, and Google Collab. These are popular largely because of how we can accommodate both code and instructional text in the same file. With each individual cell as an executable code block or a properly formatted markdown text, this makes it much easier to present information, document the information and make it a better educational material.
read morePosts
SQL Injection - 101
SQL Injection Starting off with one of my favorite xkcd comic
SQL Injection is a way where a user is able to send some ‘code’ as part of the input data to the server all the way back to the database. (UI layer doesn’t sanitize/validate, API layer let’s the malicious ‘code’ reach the database because it’s not mindful in how to separate ‘query’ and ‘data’).
Taking the example from xkcd:
read morePosts
Currying in functional programming
Currying Currying is an idea of decomposing a function and making the expression more clearer. (Note: it’s just expression decomposition and not execution)
Example In Go: package main import ( "fmt" "strings" ) func main() { fmt.Println(someComplexOperation("hello", "there", "programmer")) fmt.Println(someComplexOperation("hello", "there", "manager")) fmt.Println(someComplexOperation("hello", "there", "CEO")) // Currying this function // By looking at the fuction we see that it can be decomposed, first step of computing from first 2 arguments // can be done and reused.
read morePosts
Loop Iterator variable scope in golang
Per Iteration Vs Per Loop In most of the languages, the loop variable (iterator) has a per iteration scope, meaning in each iteration a new copy of that variable is made. But in golang it’s the same variable that has the scope throughout the loop. All the changes (increments) apply to the same placeholder and if you are temporarily capturing them and spawning go routines or creating a function placeholder (for later execution) you start to see unexpected consequences.
read morePosts
Struct Embedding, JSON Encoding in GO
Embeding a struct (just writing the type) creates a “has a relationship” with the parent. If the child implements any interface parent can directly invoke those methods. If there are more than one embedding and they implement a common method it’s okay as long as we don’t attempt to directly invoke it on parent (trying to do so results in compilation error - ambiguous selector) While encoding json (marshalling), encoder internally checks if the type implements json.
read morePosts
Database Connection Pooling
DB Connections are expensive Normally following things happen when your backend service talks to a database:
service initiates a connection to DB using the database driver
db does the authentication and establishes a network session (tcp) if succeeded
program/service performs some db operation (CRUD) which follows authorization (if user/role is allowed to perform the requested operation)
Now if the service decides to close the connection, it has to do these all over again which is quite an expensive process.
read morePosts
Debugging driven development (is bad)
We have pretty powerful modern IDE and tooling around debugging (including structured logging and so on). It’s so easy to yield to this paradigm of programming. Now I think it’s quite a bad thing. Here are my reasons:
(disclaimer - my reasons against debugging only when considered as a primary approach to coming up with solution)
too much reliance on debugging (if something goes wrong step through) takes away a key thing (thinking from first principles).
read morePosts
How I work
I have been working as a professional software engineer for over 4 years now and along the way I have picked up some heuristics about how should I take the task in hand.
Clarification
Getting a crystall clear clarity of what you are going to implement is of paramount importance. Pay as much attention to details as possible. It’s okay to conduct few more meetings with teammates on getting clarification rather than doing a root cause analysis for a misunderstood or a buggy code down the line.
read morePosts
Parallelism, Concurrency And Golang
Concurrecy Vs Parallelism (Go-lang Example) This is the general understanding of concurrency vs parallelism.
Parallelism: Having multiple threads do similar task which are independent of each other in terms of data and resource that they require to do so. Eg: Google crawler can spawn thousands of threads and each thread can do it’s task independently.
Concurrency: Concurrency comes into picture when you have shared data, shared resource among the threads. In a transactional system this means you have to synchronize the critical section of the code using some techniques like Locks, semaphores, etc.
read morePosts
Idea of 'closure' in functional programming
Closure The inner function has access to variables which were in the enclosing scope even after that ’ennclosing scope’ execution is over. (Inner function gets a copy) This is my attempt to understand why is this such an important concept in functional programming, why is it named so and so on… Functions are first class citizens In functional paradigm of programming functions are considered as ‘first class citizens’. This means functions can be
read morePosts
What is good problem solving?
Problem Solving is the gold
We all focus on problem solving. We are in pursuits of so many activities which aim to identify the problems, propose a solution to them, build the solution and hopefully create some value out of it. But what is good problem solving? Especially in the realm of computer science.
The greatest part in ‘problem solving’ is not actually the solution. Its the break down of the problem.
read morePosts
An Essay On Technical Sophistication
Building Technical Sophistication As A Developer Idea and concept wise it’s something we all developers are quite aware of. I first came through this exact term, “technical sophistication” in Michael Hartl’s article in Learn Enough Society. The basic idea is as developer one requires a certain set of skills which can elevate their overall vision and can see things in a broad sight. One need not be technically proficient at everything but having good understanding of fundamentals enables us to debug and reach the solution faster.
read morePosts
Learn enough to be dangerous!!
Recently I came to know about a wonderful online learning resource called Learn Enough. (https://www.learnenough.com)[Learn Enough] is an initiative by (https://twitter.com/mhartl)[Michael Hartl] who is popular for his highly acclaimed Ruby on Rails tutorials series, which was, at one point, Wikipedia founder (https://en.wikipedia.org/wiki/Jimmy_Wales)[Jimmy Wales]s’ favorite book. I came to know about learn enough through one of the links in StackOverflow answer where I was reading through some answer on UNIX. After going through some of the articles on (unix, git, dev-environment) I was amazed at the simplicity and the narrative way of teaching.
read morePosts
Declarative vs Imperative programming
Imperative programming focuses on ‘how’ and Declarative programming focuses on ‘what’.
Examples
C#
//Collection of integer objects List<int> collection = new List<int> { 1, 2, 3, 4, 5 }; //imperatively checking and creating a list of odd numbers List<int> results = new List<int>(); foreach(var num in collection) { if (num % 2 != 0) results.Add(num); } //doing the same 'declaratively' by using LINQ var results = collection.Where( num => num % 2 !
read morePosts
Database Connection Pooling
DB Connections are expensive Normally following things happen when your backend service talks to a database:
service initiates a connection to DB using the database driver db does the authentication and establishes a network session (tcp) if succeeded program/service performs some db operation (CRUD) which follows authorization (if user/role is allowed to perform the requested operation) Now if the service decides to close the connection, it has to do these all over again which is quite an expensive process.
read more