I am convinced that most code is not understandable to most people,
regardless of the language it is written in. When I look at how the
computer industry has progressed, I see this more and more. People write
huge amounts of code, don't document it very well, then other people use
arbitrary bits of it and things sort of just freeze at that point.

Personally, also, when I read code in any language, I do not feel I really
understand it until I see what it does to representative data.

So clear descriptions, simple data, and good labels are where I would focus
most of my efforts in making code readable. And I would also expect that
most of my code is going to be unread by most people (and I'll get dinged
for utterly random stuff by people who do read it).

I think the point of readability is: you are going to need to be able to
fix it, yourself, when it breaks, so you need to make it readable for
yourself. And for that purpose, coming back and trying to read it a month
or so after you've written it can be a good exercise.

Also, I've found that documenting code is a great way of making code
simpler. It's quite often the case that it's easier to change the code to
be easy to document than it is to document some coding quirks that
originally seemed to be a good idea. So if you want readable code, another
good thing to do is have a technical writer (or at least someone reasonably
literate) work with the programmer to document it for some audience.

Of course, the most important thing is making sure that it works.

Thanks,

-- 
Raul




On Thu, May 15, 2014 at 5:23 PM, Kip Murray <[email protected]> wrote:

> How does one write understandable J?  I offer my newt adverb below which
> uses spaces to promote understandability.
>
> Another technique might be Linda's "bottom up" style of first showing
> pieces then putting the pieces together.  What are your techniques?  Please
> illustrate.
>
> We would like at least to understand our own code when we come back to it!
>
>    NB. Newton's method
>
>    newt =: 1 : 0
> t =. y
> h =. 1 % 512
> whilst. t ~: s do.
>    s =. t
>    t =. s - +: h * (u s) % (u s + h) - u s - h
>    h =. h % 2
> end.
> t
> )
>    (2 - *:) newt 2   NB. Find root of 2 - *: near 2
> 1.41421
>    (2 - *:) newt _2  NB. Find a root near _2
> _1.41421
>
>
>
> --
> Sent from Gmail Mobile
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
>
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to