What does writing idiomatic code mean? Let us say you are using Python to populate a list with numbers. One way to do this is nos = [] for i in range(5): nos.append(i) Another is nos = [i for i in range(5)] The second one is the idiomatic code. It leverages the Pythonic way of … Continue reading Idiomatic code
Tag: programming
Sherlock Versus Calvin Ball
We can classify software development into: 1. Maintaining and enhancing existing software. 2. Software development from scratch. Given a choice between the two, developers usually gravitate towards from scratch development. Developing something from scratch is an intensive creative work where you have the freedom to shape the product the way you see fit. Hence, it … Continue reading Sherlock Versus Calvin Ball
Concurrency Models
We can roughly classify concurrency models into: 1. Thread based concurrency. 2. Event based concurrency. Imagine that you run a store with only one customer service representative. As soon as a customer walks in, the customer service representative greets the customer with a quick hello saying – “If you need any help, give me a … Continue reading Concurrency Models
Ode To Queues
If you have a producer with an uneven rate of production and a consumer that cannot keep pace with the producer at its peak, use a queue. If you have a workload that need not be addressed synchronously, use a queue. If your customer-facing application is riddled with workloads that can be deferred, move these … Continue reading Ode To Queues
Naming Things
There are only two hard things in Computer Science: cache invalidation and naming things. -- Phil Karlton Even though the above might have been in jest, naming variables while writing code is a head-scratching experience. Should I make it short? Should I make it descriptive? If descriptive, how descriptive? These thoughts keep running in one's … Continue reading Naming Things
Switching programming languages
Many are apprehensive about switching programming languages. It is OK to have preferences—I am heavily biased towards statically typed languages with great tooling support—but being dogmatic is not something one should aim for. What could be the downsides of switching programming languages? I am disregarding the psychological aversion to change and sticking to hard facts. 1. One … Continue reading Switching programming languages
Conventions
Most programming languages have conventions. These could be for naming or code patterns. How does this help? A simplistic view is that it helps to keep code consistent, especially when multiple people work on it. A deeper way to look at this I believe is in reducing the cognitive load. In cognitive psychology, cognitive load … Continue reading Conventions
Anti Features
When evaluating new technology, framework or library; a lot of importance is given to the salient features. While it is very important to know the positives, the negatives usually tend to be glossed over. Being aware of the shortcomings of a framework gives one the ability to anticipate problems down the road. For example, let … Continue reading Anti Features
Build Versus Buy
Consciously or unconsciously, as software engineers, we perennially take build versus buy decisions. It might be as trivial as copy-pasting code from somewhere versus racking up our brains to write our own; using an already available library or creating one from scratch; using a time tested framework against designing one; building a piece of software … Continue reading Build Versus Buy
Look ma, no schema
Due to the plethora of NoSQL databases available, schema-less is a tantalising option these days. While starting on a new project, NoSQL databases look attractive but reality sets in when the maintenance problems start creeping up later. If you are doing anything with data, you need to know the schema of that data. What … Continue reading Look ma, no schema
Unit test – purist versus practical
Whenever you ask a question on unit testing in a forum, there is always that one person whose only job is to point out what you are doing is not unit testing but integration testing. It is important to know the difference but it is more important to not lose sight of the goal, ensuring … Continue reading Unit test – purist versus practical
Selfie
Let us say that you want to execute a job periodically, what comes to your mind first? If you are familiar with Linux, I can hear your screaming cron. Well, no doubt about that, cron is great, but what if I told you there is another approach which you can take to execute periodic jobs? … Continue reading Selfie
SQS versus Kinesis
A lot of people are confused between SQS and Kinesis. In some ways, both act as a queue, but there is a massive difference between the two. SQS is a queue, adheres to FIFO and promises at least once delivery. Kinesis is a distributed stream processor. A simplistic and hand-wavy way to think of Kinesis is like … Continue reading SQS versus Kinesis
Nothing is sacrosanct
There is an interesting bug opened against Kafka. For those of you too lazy to click on the link and read through the description, I am reproducing it here in full.It appears that validation of configuration properties is performed in the ConsumerConfig and ProducerConfig constructors. This is generally bad practice as it couples object construction … Continue reading Nothing is sacrosanct
Designing for failure
In the world of software, failure is a certainty. Servers go kaput, databases go down, processes go out of memory, things break all the time. You can categorize software as good or bad based on how they behave in these adverse scenarios. I am not trying to imply that software has to be resilient to … Continue reading Designing for failure
Go lang
Last round of the recently concluded stripectf was in Go lang. This gave me a good opportunity to familiarize myself with the language. Even though my native programming language is Java, I have worked professionally in JavaScript, Perl and PHP; dabbled in Python for my personal projects and can manage to read Ruby, Lisp(and it's … Continue reading Go lang
Mental model of systems
One beautiful Sunday evening our quartz jobs running inside tomcat server started to freeze. At the same moment, tomcat went kaput. I sshed into the server and started poking around the logs. No error in logs. Hmm, ok. Checked the system health, again stats looked hale and hearty. Now, what do I do? I started to reason around … Continue reading Mental model of systems