=?UTF-8?B?4oCYIHZzIGVhY2g=?=

I understand that it’s bad practice to use internal K functions that can be monadic or dyadic, but what about the simple aliases? For example, ‘ vs each. Which one is considered better style? Also how about over and scan vs / or ? Personally I use each but / and \ which seems inconsistent. Unfortunately I’m the only Q developer at my company (no one got fired for choosing Q?) so I haven’t been able to see much actual Q code. Any opinions would be appreciated!

Thanks!

Sturm Mabie
cryptm.org/~sturm

https://code.kx.com/v2/basics/exposed-infrastructure/ sets out the basic picture. 

Many q keywords are simple wrappers. They are defined to make the language more approachable. It is tempting to regard them as ‘trainer wheels’ to be discarded on graduation. But ‘good q style’ is to use them: to write sum and raze rather than +/ or ,/. 

Recommended stylistic practices sometimes conflict, and must be weighed against the intent to write clearly. For example, prefix and infix syntax is preferred to bracket notation: less ‘visual noise’. The each keyword iterates a unary, so count each x is better than count’. But combinations of iterators are usually best written concisely, so count’‘’ is clearer than 

((count each)count each) each x

Why? Arthur Whitney refers occasionally to “Three Principles of Coding Clarity” – might provide some insight.

This, in my view, is why the many practices I’ve seen proposed as rules for clear code are fragile guides at best. In æsthetics it is helpful to distinguish principles, and futile to legislate.

HTH

Stephen


Stephen Taylor | Librarian | Kx | +44 7713 400852 | stephen@kx.com

There is also (count’) style that may come handy in some cases.

WBR, Andrey.

???, 18 ??? 2019 ?., 11:11:29 UTC+3 ??? Stephen Taylor ???:

https://code.kx.com/v2/basics/exposed-infrastructure/ sets out the basic picture. 

Many q keywords are simple wrappers. They are defined to make the language more approachable. It is tempting to regard them as ‘trainer wheels’ to be discarded on graduation. But ‘good q style’ is to use them: to write sum and raze rather than +/ or ,/. 

Recommended stylistic practices sometimes conflict, and must be weighed against the intent to write clearly. For example, prefix and infix syntax is preferred to bracket notation: less ‘visual noise’. The each keyword iterates a unary, so count each x is better than count’. But combinations of iterators are usually best written concisely, so count’‘’ is clearer than 

((count each)count each) each x

Why? Arthur Whitney refers occasionally to “Three Principles of Coding Clarity” – might provide some insight.

This, in my view, is why the many practices I’ve seen proposed as rules for clear code are fragile guides at best. In æsthetics it is helpful to distinguish principles, and futile to legislate.

HTH

Stephen


Stephen Taylor | Librarian | Kx | +44 7713 400852 | ste…@kx.com