Recent Articles

async/await subtleties

Jan 3, 2019   #async/await  #Promise  #Exceptions  #try/catch/finally 
ECMAScript’s new async functions and generators simplify working with concurrent I/O code. While they work hand-in-hand with Promises, there are some subtleties that either seem to be underspecified in the language or not talked about much. For the purpose of this post, I assume you’re already familiar with the async keyword and its usage in Javascript as well as the await keyword for awaiting the result of an async function. Also, beware that though here you may find ways to use them that you didn’t know about earlier, but that doesn’t mean you should use them. Read More ...


Dec 14, 2018   #Integers  #Brahmagupta  #Number line  #Modulo arithmetic 
My son is learning about integers at school. It is quite a challenging topic to come to, especially as, thus far, for him, trying to understand it purely based on the familiar is both a necessity and a tough challenge due to the novelty of the idea. First off, it is not a big deal if kids are unable to grasp integers initially. They eventually do, but given that integers weren’t “natural” enough to be invented for millennia1, it is perfectly normal to not understand them from the get go. Read More ...

Hodja on Debugging

Sep 10, 2018   #Naseeruddin Hodja  #Debugging 
I loved Naseeruddin Hodja stories when I was a kid. Heck I love them now too. They give me a good laugh and, as is common with good humour, manage to point at some truth once in a while. One of these is a story where Hodja is searching for something in the garden. His wife asks him what he’s searching for and he replies he’s searching for his ring. She then asks him about where he’d lost it. Read More ...

Filter Theory in Physics Notation

Sep 7, 2018   #Quantum Mechanics  #Signal Processing  #Filters 
I happened to have picked up quantum mechanics from Feynman’s lectures and Dirac’s book before I got around to my main stream theory of linear filters during my B.Tech. So I went through a somewhat weird path of understanding the math around filter theory based on the quant-mech math I’d picked up. I do think it is clearer than the way linear filter theory books deal with the topic, especially due to an explicit notation for a “signal” in the abstract that is independent of “a representation of a signal”. Read More ...

Channels with async and await

Apr 6, 2018   #CSP  #Javascript 
async and await are, I think, the best thing to happen to Javascript, though I’d very much like something like sweet.js so I can invent it when I needed it most. However, I mostly see them being described in terms of promises. Here, I show how you can implement CSP style channels using them without using promises. A basic channel A basic channel can be thought of as a port that supports a post(value) method, with the value being delivered to whichever end points are consuming values from the channel. Read More ...

Warranties for Smart Contracts

Mar 6, 2018   #Smart contracts  #Solidity  #Blockchain 

(Cross posted from Imaginea Labs).

The distributed ledger protocol used by blockchains has resulted in systems where we do not have to place trust in particular parties involved in maintaining these ledgers. Moreover the ledgers are programmable with “smart contracts” - transactors whose state changes are recorded and validated on the blockchain. A collection of smart contracts describes a system that is expected to ensure certain invariants relevant to the domain are upheld. For example, an election system is expected to maintain voter confidentiality. While the code that describes these “smart contracts” is open for anyone to read, those who’re participating in the systems run by these smart contracts are not in general competent to evaluate them, with the OSS community being the sole eyes on the contracts being deployed. In this post, I examine how these smart contracts can provide “warranties” that are easier to ratify and describe clear and automatic consequences of violating the warranted properties.

Read More ...

Blockchain apps must be closed systems

Blockchain tech, especially smart contracts, are the hot new “internet”. Post the creation of Bitcoin, we’ve seen the rise of the public smart contract system Ethereum and several private systems like Linux Foundation’s Hyperledger. These distributed ledgers have become the brand new foundation to build apps on. This is as app developers hope to leverage the additional trust that these ledgers are supposed to provide by virtue of their distributed nature.

(Cross posted here from - Blockchain apps must be closed systems)

Read More ...

Forget password

Apr 29, 2017   #Authentication  #Signin  #Passwordless 

Can we have a signin/signup flow that is email-based and passwordless similar to a “forgot password” flow but where the URL will work only for the initiator, and only once per signin? This is the scheme I’ve implemented on Patantara and I describe its innards here.

Read More ...

On tech interviews

Feb 23, 2017   #Interview  #Algorithms  #Einstein  #Puzzle solving  #Peter Wason 

Recently, many techies have spilt words against doing the Google interview process. Broadly they feel their real and demonstrated abilities are not being valued. The most famous of these cases is Max Howell - the developer of homebrew - being rejected in the interview. Following Google, Amazon and the like, much smaller companies have also begun to subject interview candidates to such “problem solving exercises” - either on a whiteboard or within test environments such as HackerRank where you can be rewarded for coming up with the wrong answer quickly instead of the right answer slowly. These same candidates would speak up against these companies as well, had they interviewed there. Is there a real problem with this interviewing technique or are these candidates crying sour grapes?

Read More ...

Did you guess or did you estimate?

Feb 7, 2017   #Estimation  #Fermi problem  #Model  #Precision  #Measurement  #Prediction 
When asking software engineers for an estimate of the time required to build something, I often find them guessing the time taken instead of doing the work to estimate it. Yes, estimates come with their own caveats but, like planning, if you don’t estimate well, you may not have an idea of what you’re actually dealing with. Here is something that I did with my kid yesterday that illustrates the difference between estimation and guessing. Read More ...