What you don’t code is what counts

20161021-code

It can often be tempting to think that when programming, the most important element is the lines of code that you write. Poorly written code ends up being a nightmare to maintain. As a result, it ends up having a much higher longer term cost, if it ends up being used over many years. Thought needs to be taken when designing software, to make it easier to maintain and for the code to reusable. Copy and paste does not constitute code reuse, as a lecturer once told me at university!

 

There is also the question of how efficient that code is, and getting that important balance between optimising your code and maintainability. The more “optimised” a piece of code is, typically the more compact and potentially more challenging it is to read. Using code profiling can help to identify those bits of code where it really is worth spending the time to optimise it, and take the hit from a readability point of view. But there is something even more subtle about coding, and that is what you don’t code! I’m not referring to the process of refactoring which can have the beneficial outcome of reducing the number of lines of code in your code base. I’m instead referring to the code you (should) have never written.

 

How many times have you coded something which you’ve realised was totally unnecessary and you’ve spent time reinventing the wheel? Yes I put my hand up for this! With the advent of the web, and especially tools like GitHub, it has become much easier to share open source code. The result has been a huge number of open source projects on the web. It is becoming increasingly likely that elements of what you want to code are already out there, which you can use within your project. You can also contribute to that open source code too. The difficulty is finding what code to use!

 

Some open source projects are so well known, that they seem virtually part of the underlying language itself, because so many people use them. In the case of Python, this includes libraries like pandas for dealing with time series and NumPy for scientific computation. However, there is a whole plethora of libraries which you’ve probably never heard of, which could well save you hours in coding time. So how do you find out about these libraries? Well, Google is obviously one way. The problem is that you need to know what you’re looking for, before using any search engine! Another approach which I’ve found useful is to attend lecture events for finance, Python and data science more broadly, where you might hear about new and interesting libraries. Furthermore, seeing them demonstrated can be a great way to understand quickly, how useful they are. Newsletters can also be another useful way to learn about interesting libraries, for example I subscribe to Python Weekly, which I can very thoroughly recommend! I’ve also learnt a huge amount about code libraries from Twitter. Perhaps most importantly, personal recommendations about libraries have been beneficial of all.

 

Sure, this stuff might take time, but I’m pretty sure, this investment in time for me has saved a significant amount of wasted energy later on. It also means that you can concentrate on what adds the most value, rather than spending time reinventing what already exists. Over a year ago, I went to a Thalesians talk, kind hosted by AHL, where they discussed some of their technology including the arctic library for storing pandas dataframes in MongoDB. This summer, I ended up using that library, and it has saved me a lot of time. Even simply starting to use Python, was a result, of going to a lot of events and hearing how useful it could be! Whilst I’ve focused on finding software libraries and technologies which can be useful for you, the precise same logic applies to related areas, like mathematical techniques or trading more broadly. On that subject, I’m helping to organise a Thalesians talk in London on Monday 24 October with the Chief Scientist of Winton Capital, Prof David Hand (details here), which I hope you can attend!

 

Reinventing the wheel ends up sapping your time and energy, which could be spent on the more core elements of your project. The only perfect code, is that code, which has taken forever to write. Pity that no client will ever give you forever to deliver it!