TIL: Deploying Elixir Apps with Distillery

Out of the many positives of Erlang, the biggest being the light weight processes and a functional programming model coupled with immutability, the ability to do hot-reloads of the server (Yes, you don’t need a restart of the server daemon!). Doing this in Erlang is quite cumbersome but tools like exrm take a lot of pain out of this. However, distillery takes this one step further.

Creating a new update for your Elixir project using distillery is as simple as running …

$ MIX_ENV=prod mix release --upgrade

For a full brown amazing tutorial on the setup, detailed step-by-step walkthrough and the gotchas, go here.

A tiny note of caution: The tutorial works fine for the first upgrade (i.e going from 0.1.0-> 0.2.0) but not for the later upgrades (0.2.0-> 0.3.0). To have the workflow for continuous deployment work, have the build and the deployment in separate locations.

The gist below however will serve as a quick reference material for

  • setting up distillery & initializing the release mechanism
  • building a upgrade archive
  • deploying it to a production location
  • downgrade to a previous version if needed

Note: Most of the times it is not worth the hassle to handle releases in this method – a standard restart would work fine in most cases, however having a good release management system system will force one to think through the impact of the upgrade or downgrade. However, it is worth pondering over to understand the impact of measured upgrades for servers in the same way that database migrations work for schema and application server changes.

lingua franche

So have been working on and off my startup, have been playing with some swanky new tools too.


The absolute rockstar language. The LISP syntax is an absolute blast. The syntactic sugar does have some extremely valuable benefits. The code is a joy to read though.

My first small project to explore Clojure was to build a ledger of all my expenses. I generally make a note of each of my expense in my iPhone and then transfer the data to my Google SpreadSheet using my clojure project.


Its the BEAM dammit. Processes all the way through. The speed when the program is IO-bound is amazing! Best of all it feels very natural. With Python, the asyncio still feels a bit bolted upon.

Even though both the languages are very different in terms of the shape and the code forms, I found a couple of things very interesting. After my last post (2 years back), I think these two languages share more than 1 common feature to make to my toolset.

I have been playing around building a card based games engine via Elixir and here too the language has been an absolute blast. This code is not public yet.

Package Manager for the language

What made me fall in love with these two languages is how much work the package managers (lein and mix) help us accomplish. Creating a project, setting up unit tests, dependencies, extensibility with dependencies, adding a structure to them as part of the core tools, all accomplished via the package managers themselves makes it so very useful.

The similarity of programming structures

As I dig deeper, I find the similarity of the structures to express the problem in very similar – using hashmaps / dictionaries / maps to express structures, symbols to tackle your constants, immutability, pipelines (->> , -> in Clojure, |> in Elixir) – the code shapes up very nicely.

All in all lovely working these languages.

What should be my lingua franca of programming?

In a fast paced business environment with fast changing requirements, the tools for expressing and constructing a program become extremely vital for the productivity of the programmer. Given this assumption, the primary of these tools, the choice of programming language becomes extremely essential for productivity. Having worked in C and C++ and having seen a host of different languages I have formed a vague idea of where I am headed next. My attempt is to find out which language should be my lingua-franca of programming.

I am a clear advocate of the horses for courses philosophy, however, it is also important to work with a language that best shapes my thinking. I have here a list of languages I am acquainted with and hopefully a choice emerges and hope that one of these quickly becomes an arrow in my quiver (that I am able to build at least something substantial and useful with it). I had scribbled down the following languages and their pros and cons and hope to master one of them by the end of the year (a 10000 hours later…). Each of these languages have already been used in production and proved their value well already for other companies.

Here is my humble attempt to deconstruct the pros and cons of each language and use one of them before jumping headlong into one.


The grand daddy of all the “Programming in the Large” languages. In spite of its quirky syntax (read non-C typish), it is a revelation to work in a language where there is no mutability. In fact, once I worked in Erlang, it has forever changed my way of thinking about data problems. My typical PHP or Python code is now littered with a lot of small functions returning tuples where earlier I was prone to over-engineer with a lot of classes.

Killer app

  • ejabberd (/mongooseIM) – XMPP
  • CouchDB
  • Riak


  • Immutable programming model
  • Modules + Function overloading
  • Good set of BIFs
  • Interop with C (performance optimization)
  • Robust and scalable with OTP
  • REPL


  • Weird syntax (non Cish) – strict naming conventions (might be a win actually) – Elixir might be a big win here actually!
  • Low real world usage (might be an offshoot from above)
  • Slow
  • Not so great plugins for common usecases (webapps) – mysql


Scalable language or Scala we call is one of those languages which target the JVM directly. And being a hybrid language, it has found good reception among codistas.

Killer app

  • Play
  • Twitter – Finagle
  • Typesafe platform


  • Java interop – so support for Netty is directly available – Batteries included
  • LISP + Object oriented + Functional = multi-paradigm language
  • REPL
  • Touted as the future of Java
  • Compiles to Java bytecode so almost as fast as similar Java code


  • New language
  • Multi-paradigm – philosophy of 1 language – many ideals
  • Mix of immutable (val) and mutable (var) – tries to be too many things to many people


Go is a new language from Google which seems to have a C type syntax as well as the fundamentals of programming in the large systems.

Killer app

  • Docker
  • Google Infrastructure


  • Looks like C – small learning curve
  • Compiled
  • Backed by Google
  • Battle tested
  • Performance close to C
  • Goroutines


  • Not used by a lot of companies – hard to find developers in the market
  • Still very recent and not fully battle tested


Coming with a LISP syntax and a immutability as a core tenet it is a refreshing take of LISP in a JVM. Created by Rich Hickey, its driven very strongly by its creator, the language is quite opinionated.

Killer app

  • Datomic
  • Clojure Script


  • Java interop – Batteries included
  • LISP syntax – almost
  • REPL
  • Touted as the future of Java
  • Rich Hickey’s philosophy
  • Channels


  • New language
  • Lisp Style


My lingua franca now. It is very neatly done language and the fact that it is objects (dicts) all the way through is extremely refreshing.

Killer app

  • Django


  • REPL
  • Good / Fixed syntax
  • Simple modules
  • Batteries included approach – powerful glue, scripting and even a general purpose language
  • pip


  • Lacking multicore support
  • STM
  • Green threads


While not being in the same league as these full-fledged languages, Lua is one of those languages that can quickly turn an extremely well performing C / C++ code and turn it into a powerfully scriptable system without losing any of the performance

Killer app

  • Open Resty
  • Game programming systems


  • C / C++ support
  • Performance / Speed


  • Not a full-fledged language. Any errors bubbles up from the base language directly into Lua


All said, there are a few features I like in a programming language I like working with …

  • REPL
  • Modularization of code without having to resort to using classes. This is where PHP loses out for me.
  • Installable modules. Batteries included approach.
  • Variables naming with hyphen instead of underscores or camelCase. Feels more natural
  • Function naming with question mark. Makes reading and building boolean returning functions ending with a ? a natural read.
  • Garbage collection. I have seen C, C++ and Erlang’s immutability and any language that does not have me worrying about the trivial pursuit of hanging pointers is a big win!
  • Homoiconic systems. It becomes very easy when we start thinking about data and code not as two separate lines of thought (storage, DRY, versioning) but as two varying types of storage semantics only. Where processing (code) and data systems can both crash and need to be restored on demand, it becomes extremely useful when the code itself can be used to express infrastructure, data, configuration and other systems.
  • Clear and convention driven programming style. Telling me that it will work the way it looks (WYSIWYG) is simply a huge win. Quite simply, Erlang excels here for me. So does Go and Python.

My only crib. I wish Elixir was in the Python syntax instead of Ruby (of course taking nothing away from Ruby – its an extremely natural language – just a bit too Englishy and flexible for my taste).

Mental model of languages

“The better decision maker has at his/her disposal repertoires of possible actions; checklists of things to think about before he acts; and he has mechanisms in his mind to evoke these, and bring these to his conscious attention when the situations for decision arise.” 
(Herbert Simon, Nobel Laureate)

C’s mental model is of blocks of memory. C makes you go bare metal – there is a block of memory address blocks underneath!

Python’s underlying mental model is of dicts. Almost everything is a dict or a dict with superpowers!

Erlang’s mental model is of processes. Everything is around handling these processes, monitoring them, how they behave.

LISP’s mental model is of Lists. Everything is a list – function definition, function invocation, data … everything IS A list!

PHP makes you think in terms of HTML output (just kidding).

There is a line I remember – A language that does not fundamentally affect the way you think is not worth learning. Hmmm… time to do some serious work in these languages?

Language vs VM Wars!

Rant follows

Erlang has a weird syntax but again not that far away from being an acquired taste. Python was weird when I started. So was Perl and PHP not so much since. C, C++, Java are all the normal ‘looking’ languages.

These days when I keep coding in Python or PHP, I keep missing the enforced standards of Erlang…

  • first class processes
  • monitoring oriented programming
  • immutable variables
  • first class functions
  • light weight message passing
  • behaviors and OTP

However all of this goes for a toss when I start looking at long term hiring and building a team that can work in Erlang for the long term. And then when I saw Elixir it was neat epiphany. Will there be a time when we will move away from languages and to the Language Virtual Machines.

  • JVM has Java, Groovy, Clojure, Scala and many more
  • BEAM already has Erlang, LFE and Elixir

Now undoubtedly having immutable values gives a huge power to having a pauseless GC and the BEAM is probably better for it. Had the syntax been more “normal” looking, Erlang has many many ideas that definitely need to be heard and learnt by all. It is sad that Erlang does not have the batteries included approach of other languages (I am looking at you Python), but I think where infrastructure and message architecture is involved Erlang is the best bet for now. Except when a class or a struct is involved it is very rare that we try to reuse a variable for more than one purposes. So with some programmer discipline we can ensure that a variable is never used more than once. In that case can the GC of non-Erlang languages be more efficient?

There are so many ifs and buts but it would be nice to see a solid language succeed.

cloud computing is …

  • when computing is a utility
  • computing capacity can be scaled up and down on demand. And billed by usage
  • IaaS (Infrastcture as a Service) is cloud computing

Cloud is …

  • Cloud is everything else – anything that abstracts the user from the metal is a cloud
  • Technically your API or a website or an app that provides a vertical functionality is a cloud for anyone else consuming that resource
  • Cloud computing is directly geared toward computing in a cloud i.e computing on resources / interfaces you do not own
  • You compute on and using some interfaces, the black box is not your problem

truecaller is a social network in an app

Let me share a small story …

It was my birthday yesterday (yes, yes, yet another year down the hill…). Anyways so dinner was had with all my folks. Midway my cousin started prank calling my wife. Of course me and my brother being privy to the whole mischief decided to play along with the charade. Well… and the charade kept playing. In the meantime, my cousin installed a new app on my wife’s phone – viz truecaller. Curious about the app we started asking more questions, he told us that it was an app which would give the name of the person calling you even if the number was not present on your phone’s address book. He had my interest then and there.

Playing around with truecaller by searching through the application some things became very clear

  1. The phone number look-up was happening on the true caller server and not as a peer to peer search as earlier assumed by my cousin
  2. The application clearly was uploading the complete list of contacts from our phone to the true caller server which was not completely apparent from the application permissions
  3. Clearly, a lot of people either do not understand that this is the case or just do not care about privacy as long as the name lookup works perfectly

Once we started playing around with truecaller some beautiful insights started emerging…

  • It is simply a global yellow pages for phone numbers and people
  • Built completely using “crowd sourcing”
  • Has the complete “social-graph” and your connections
  • Phone numbers and even the data against the person – images and birthdays are being shared

But not once does truecaller state that its value is the above. truecaller’s simple selling point is “know who your caller is or find someone you know”. Now culturally, this is something that happens quite often in India that we first determine the caller and only then take the call. And truecaller fits this mindset like a glove.

In spite of the many buzz-words it covers, truecaller never for once succumbs to the buzz and sells itself as “X of Y”. Quite simply the app identifies itself by the user’s needs and not by the capabilities. Truly cutting the crap and bringing down the value to the bare minimum I think is truecaller’s best selling point at this point in time. My bow to the team for truly truly getting down to simplifying the message to the users.

Just thinking deeper on the different value that truecaller can reap from itself just on a few adjacency moves had me truly appreciate the full scale of the app’s accomplishment.

1. Fully connected and open Social Network

India had its telecom revolution in the 2000 but what we are seeing now is the beginning of a truly mobile revolution spearheaded by marginal costs of software, apps, operating systems and the Chinese manufactured hardware. In India where the penetration of the global social networks (FB, G+) is not at a level where they can cover the complete social spectrum, truecaller is truly riding on the Android-driven mobile revolution and is now almost a default must-have app on Android phones (WhatsApp being the other must-have app). If the privacy concerns are set aside for a moment, quite clearly truecaller now clearly has my phone number, list of all people whom I met or am connected to via my address book and the list of all calls landing on my phone (the hook which does the look up for the true called id of the number when I get a call).

What clearly is being missed is that truecaller has a hook into all your contacts and mobile activity without the user having to do any work explicitly – This sets it truly apart from all other social networks where the activity must happen via user intervention to get recorded on the site. It truly has all the things going for being a truly global social network – it is completely crowd-sourced, has the exhaustive social graph and is deeply embedded into your connections and activity. No wonder Facebook is pushing for the Facebook phone – to be right at the place where the connections are happening.

So to sum to it all up, the things that are going for truecaller for leveraging the Social Network

  1. Clearly leveraging the network effect – more the people that install truecaller, the better the performance and the accuracy!
  2. Does not require the user to do anything to become sticky – it already is hooked into YOU – you volunteered to give all the info away
  3. Forget privacy concerns what so ever
  4. Ads while searching for people using their phone number – monetization ready!

Whether truecaller morphs into a social network is a different question, but quite clearly it has all the elements going for it to leverage the network effects of a social network.

2. Phone address book online backup

Going by the fact that after installing and probably at regular intervals the data is uploaded to the truecaller servers – your phonebook is always available on truecaller. truecaller can even charge for restoring your addressbook and you are done! There are other parts of the security of this data but then being the online backup of your phone book is no mean adjacency value! Having gone through my share of pain to restore all my contacts for my phones, I can trully attest this would be a neat service to build. If there is a truecaller API, someone should just build it on top of it. Quite clearly, the network provider will become irrelevant here 🙂

Concerns that one should not forget though

Privacy is irrelevant

This is huge! What is not probably apparent that all your contacts and all incoming end points are on truecaller servers. Is this something apparent to all the users who installed trueapp? I for one am not sure if I would be comfortable installing trueapp on my phone. But the bigger concern is my phone number is floating on the truecaller servers as people connected to me already consented to give truecaller all access to their address books. The weakest link can reveal all data and connections.

Eaves dropping

With the new revelations like PRISM – all that PRISM has to do is get a hold on truecaller servers and all data will be clearly accessible


I understand that there has been no spamming till date. But can we trust truecaller with never selling out the contact points

Safety of data

There might have been attacks on truecaller. Every government or an oppressive regime would be looking in eagerly to hack into truecaller to get details of people, their location even probably and of course any one fighting against the regimes.

Zara – Fast Fashion

How Zara grew into the world’s largest fashion retailer


More about Inditex than Zara. The process is … Fast Fashion

Inditex’s 8 Brands
Inditex is the fashion company that owns Zara and many other brands – totaling 8.

  • Zara
  • Zara Home
  • Bershka
  • Massimo Dutti
  • Oysho
  • Stradivarius
  • Pull & Bear
  • Uterqüe

The Zara template: Trendy and decently made but inexpensive products sold in beautiful, high-end-looking stores.

Inditex rivals: Arcadia Group, H & M, Mango

Process model / innovation

  • processing of customer reactions,
  • the quick-turnaround design teams,
  • the logistics platform
  • Mostly outsourced and Spain based industrial process
  • Trendiest items are made closest to home so that the production process, from start to finish, takes only two to three weeks.
  • Extremely agile – Constant feedback, alter supply based on demand. customer is always determining production
  • No advertising. The shops / real estate is the marketing. Invest heavily in beauty, historical appeal and location of its shops
  • Zara’s designers are completely anonymous; some would say this is because they are copiers rather than designers.

Stock is always fresh. This process has changed consumer behavior. In Zara, everything is a impulse buy – it is good and cheap – so no need to save for a leather jacket.

“With Zara, you know that if you don’t buy it, right then and there, within 11 days the entire stock will change. You buy it now or never. And because the prices are so low, you buy it now.”


  • …neighborhoods share trends more than countries do…
  • You open more and more stores, and you don’t have flexibility of the last-minute response

Project Management learnings

These learning are from the Pearl City Project of PCC of 2012. Some of the learnings I took. Jotting them down before I forget.

By handling a Multi-contract approach there will be huge leverage on slippages.

Difference in IT and other industries

  • No visibility on IT industries. So we need this visibility & metrics to measure the visibility.
  • Interface requirements might change.

Project Management Essentials

  • Align with strategy and stakeholder needs
  • Establish clear objectives
  • Balance resources with constraints of budget, effort, cost, schedule
  • Execute!

Must haves:

  • Execution Strategy: Who will do it, What, Where, How
  • Execution Plan: When will it be done
  • Everything has a design basis. Ask why?
  • Do follow books. Lots of paper work. Help project control.
  • Build craft centers
  • Strengths – Database and Information systems.
  • Everything is quantifiable. Metric -> Deviation.
  • Keep track of assumptions during the course of project.

Types of contracting

  • Cost Plus contracting.
  • Unit rate contracting.

Object classification of projects
(What is the content of the project and purpose?)

  • Dimensions
  • Inherent complexities
  • Project span

Briefly about Cloud Computing:

  • Data Center Electicity Consumption vs Consumption of Services
  • Service consumption is seasonal and bursty
  • If infrastructure provisioning is minimal, then building the team is going to be important.
  • Re-engineering AppStack modules to SOA
  • Every App Developer is a System / Service Integrator
  • Utility model ala electricity
  • Objective is to be lean and mean & to optimize costs

Global Delivery Model #toread

What are imaginary numbers?


The complex numbers allow us to consider scalings and rotations as two instances of the same thing; and by ensuring that negative reals have square roots, we get something where every (non-constant) polynomial equation can be solved: C is the algebraic closure of R.

Quora and StackExchange are fast turning out to be my personalized wikipedia. Unlike the sterilized quality of answers in wikipedia, the learned folks on Quora and SE reaching into their experience and sharing their personable answers, it is (they are) fast becoming my personal treasure trove of knowledge.