User:Dan Bron/Style

From J Wiki
Jump to: navigation, search

My thoughts and personal preferences w.r.t. programming style.


Style is defined as that critical aspect of writing^*^ which cannot be defined.

* Yes, "writing" includes writing programs


Please see Doc/Programming Style in APL


Aspects of programming style:

I wrote on the "zig-zag order" thread on the Forums: My style is to use @: unless I __mean__ @. That is, unless @ would produce different results, and I want those results (e.g. {.@+.). It's a simple rule which sustains the principle of least surprise. Also, in the general case, @: is faster (because it lets primitives see as much data as possible). The trade off is that it's longer and not as pretty (it makes J code murkier and scanning less fluid).

Oleg Kobchenko responded with a dissenting opinion in the same thread: OK. But, you cannot offer such justification with every piece of code.

And in a stranger it may create the same impression as using redundant parentheses between relational and logical operators in SQL or C.

Which can tell that you either not sure or do not care. And "least surprise" may just be the cute word to camouflage that.

I now respond: (depends on how you __think__ of the process; i.e. model it in your head: assembly line vs. batch processor analogy)