CHAPTER 5Debugging q Code

The provided information is valid for version 3.5 and later. The functionality has been tested using version 3.6, but principles will likely remain the same for later versions. In the first part of this chapter, we make a brief overview of the native errors we may encounter when using incorrect syntax. We then focus on how to debug the code when encountering errors and move on to advise on how we can structure our codebase better, and debugging tools available for execution trace and dynamic debugging. The key message is to de-myth the claim that it is not possible to properly debug q code, given the improvements in tooling around debugging introduced in version 3. All in all, though, writing code which has fewer bugs, as well as the ability to detect their location quickly, will highly depend on how modular the overall code structure is: small functions, with distinct – and noticeable – responsibilities will generally lead to more maintainable code. More tips on how to design your application and structure your code will be seen in Chapter 9.

5.1 INTRODUCTION TO MAKING IT WRONG: ERRORS

One of the common reasons heard among quants against using the q language is the limited ability to debug the code, especially when compared to conventional programming languages and their IDEs. Ask any Java developer about his or her opinion of q and this argument will be almost surely mentioned among the top three arguments (given one gets beyond a blind “no”). Indeed, ...

Get Machine Learning and Big Data with kdb+/q now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.