Saturday, September 24, 2022

Software Development as Meditation

Meditation

There is a sense of peace, relaxation when you are at a meditation retreat, you close your eyes, listen to the breath and feel the flow of air through your nostrils.

You concentrate.

Interruptions are not welcome, but your mind, being what it is, will naturally take you places. It's like the 2-year old with a five-second attention span. And so you are taught to gently bring your attention back to the breath when you discover this mind wandering.

I'm told that even seasoned meditators (if that's a word) of decades of experience will feel this mind wandering, it cannot be helped. But it can be managed. It may be simply thinking of bills, projects, taxes, relationships, weight, upcoming trips, food, discomfort, pain, parents, spouse or children. This stuff just bubbles up and you think of it.

Writing Down the Bones

Then Natalie Goldberg came along and said that you can use writing as a form of Zen practice. Exploring the mind through writing. I enjoyed one of her books, Writing Down the Bones. I enjoyed it enough to buy  my own hard copy - since I normally get all my books nowadays either from the public library, or ebooks from Kobo.

I love writing, and Natalie taught me to put the pen on the page and simply go, without stopping for a page or two, not thinking but allowing the pen to move and the words to come out. For me, this was a step up from the breathing and I rarely found my mind wandering. However, a couple of pages was my limit since my hand would get tired. And typing is not the same thing.

Morning Pages

And then I read Julia Cameron's book, The Artist's Way. No doubt these two are friends, and the influence they have on each other is recognizable. In Julia's book, the free-form, flowing, writing is called Morning Pages. You're supposed to do them in the morning, first thing, before you get busy with other things.

I actually practised Morning Pages for close to a year, and then almost as suddenly, I skipped a session, then one became two sessions, then a whole week went by without a single Morning Page written, and at this writing, in September, the last time I wrote a Morning Page was probably in July. Morning Pages were an interesting exercise and it's hard to say if I got anything out of it. One thing it did was detract from my real writing because after Morning Pages, I was too mentally tired to sit and actually write anything. In looking back at that exercise, two full pages, long-hand, each morning, I could have completed a novel. If only I had that discipline for real work.

Software Development

I'm intrigued by puzzles. I enjoy working on those cast iron chain link puzzles where the solution is removing an item, or untangling the links, from the complicated mess. Some of the puzzles, mostly gifts, I have been working on for many years, and still no solution. Clearly I don't work on them daily, or for hours at a time, but suffice it to say that I keep them close and when I feel drained, they are curiously satisfying, even in their incomplete state.

I think that's why I found Architecture enjoyable. Drawing complicated shapes in 3D was a skill I developed and I could literally spend hours working on a single item. Days even. So when my career gravitated to writing software for a living, this was not work to me. This was being paid to have fun. This was something that I could do, even if I wasn't being paid.

Software development in its purest form is problem solving. Once you're past fighting with the tools and can concentrate on the problem, then the fun begins. It can be a challenge if you're still learning how to use the tools while trying to solve a problem. It's something like trying to design a bridge but not knowing anything about structural forces and the mechanics of materials.

Project Euler

There's this great website, Project Euler, which presents mathematical problems to solve, most which need some computer tools to complete. Some are easy, and others not so. The challenge is to look at the problem, understand it, and then take a crack at it.

Here's number 1 on the list of problems, possibly the easiest one and can almost, with enough time on one's hands, be done by hand.

Copyright Project Euler (https://projecteuler.net/)

Meditation

Why meditate? I think that there's some misinterpretation in a lot of literature that paints meditation as a singular activity that requires some notion of clearing of the mind. Wikipedia describes the activity as requiring focus to train the mind to achieve an emotionally calm and stable state. Many practitioners describe a fuzzy practice which needs stillness, while there are few who indeed say that mindfulness (a practice) can be achieved even when walking.

I believe the closest way to describe what the purpose of meditation is, is as an escape. Some practice that allows you to remove yourself from the stressful continuity of daily life. In a way, sitting quietly and concentrating on the breath can help achieve this. But so too can sitting and writing some computer code. Even if it's your daily job. As long as it's not focussed on the result, but on seeing the puzzle move ahead.

Coloring books

As an Architecture student I had a lot of sketch books where I could scribble down ideas - after all, the language of Architecture is drawing. Later in life, I found that I could zone out by colouring and so I have colouring books. The difference between the sketch books and the colouring books is that one is unguided, and the other one is guided. When you're colouring, you can focus on layering colour between the lines, the shape is already there. And if you concentrate hard enough on the process, and feel the colour pencil, and look at the layers of colour bringing the image to life - the still black outlines become fleshed out with colour - then you can use colouring as a form of meditation as well.

So here's the solution, in the Python programming language of the problem above.

sum = 0

for number in range(1, 1000):

    if (number % 3 == 0) or (number % 5 ==  0):

        sum += number

print(f'The answer is {sum}')

That's the brute force method of getting the answer.

There's even an Excel way to do this, here's one solution.


In that solution, all the numbers from 1 to 1000 are in column A. Then we use an IF() statement in Excel in column B to see if that number is divisible by 3. And we use an IF() statement in column C to check if that number is divisible by 5. Finally, if there is a "Y" in either column B or C, we put that number in column D. The answer is to sum all the way down to row 1000.




No comments: