The sculpture shapes the sculptor.

Parenting aint easy. Certainly it is often something your kids teach you. Even worse, it often starts with “<INSERT_KIDS_FRIENDS_NAME>’s dad lets him do <INSERT_CURRENTLY_PROHIBITED_ACTIVITY>”. In this constant battle to shape your offspring into a model citizen, with the values you value, and turning him/her into a self-sustaining organism, one applies tools that enhance particular features, remove the superfluous or the undesirable.

Yet every action, it is said, has an opposite and equal reaction. So it is unsurprising that when one tells a child *not* to do “something”, the natural neural triggers in the child’s brain ensure that that “something” will be done; if one encourages a particular activity for personal development, that task is instantly seen as boring and burdensome, and there is an immediate reflex deployment of many avoidance strategies. The situation is actually worse than it appears. For while you may have some illusion of power to manipulate your child’s development, there is at the same time, a stealthy manipulation of your own choices by your child. While trainers from one store may look, feel and work exactly the same as in another while costing an order of magnitude more, these manipulations transiently distort your own understanding of value, in favour of your child’s.

Suffice to say, I am a cheapskate: won’t pay money for CAD tools, (or trainers) and use only Linux. I am constrained in my ability to accept change: won’t use Python and FreeCAD. I try and bend my life to my will. Yet in trying to do so, I change, I waste time, and life goes on as before, impervious to my efforts. Rather than using available tools for developing 3D objects using a GUI, I thought it may be possible to sculpt 3D objects using Perl. I have taken great deal of inspiration for EWILHELM and NERDVANA who have made efforts to bring CAD to Perl programmers. My own recent efforts attempting to twist OpenSCAD (“The Programmers Solid 3D CAD Modeller”) to work with me using Perl are ongoing. I can use Perl to create OpenSCAD scripts fairly easily: CAD::OpenSCAD is the result. This module can generate said scripts and do almost everything that basic OpenSCAD scripts can do, with some Perlish enhancements.

It is helpful for me: I now able to generate complex gears more easily than in my old CAD tools using Perl by leveraging OpenSCAD’s ability to do all the heavy work. But most of these might have been possible using the OpenSCAD scripting language alone, without Perl.

But I needed it to be better. OpenSCAD has limitations. The shapes it uses are not “self-aware”. I can change an object’s shape, location and orientation, but can not query that location and orientation. The points and facets of the shape are not accessible. It is also slow for complex tasks. But the programmer might be able to create an object that allows these parameters to be accessible. To mould CAD::OpenSCAD into something more useful, I could use Perl to create all the points and facets of an 3D object, in the form of a Perl Object. These points can then be manipulated to sculpt the polyhedron, poking dents into that shape, or pulling part of its surface outwards. The Perl Object can then generate the 3D script with these modified parameters, for consumption by the hardworking OpenSCAD backend.ScadHead.png

But as I do this I find myself learning about 3D coordinates, facets, structures and their manipulations. The difficulties of the past are replaced by new ones, deviating me from my original goals. Talking about which, can I just ask, will designer trainers really help improve grades? Asking for a friend’s parent.

3D Object Scripting using OpenSCAD and Perl

Control. That’s what we all desire and very rarely acquire. The natural restlessness that occurs when you watch one of your offspring flicking from one movie title to the next, barely glancing at the summary before rejecting it, is one of the reasons I don’t like family movie night. My daughter’s grip on the remote is as strong as her decision making skills are weak; I struggle silently to hold back any outburst that would expose my failing parenting abilities once again. I have to distract myself with thoughts of the good old days when the TV had only 4 channels and Teletext was the closest thing to internet. Desiring such regression is now getting much of a habit for me. But we change what we can, accept what we can’t and trust, often foolishly, that those blessed with control do the best for all of us. Ah, look. Another teen fantasy horror romance movie. Thanks a heap, Netflix.

It is no surprise that we seek this control in many things, in work, in politics, in family life, in code. Other people satisfy this need, making powerful tools that does everything one might want; thank you guys, you are legends. But even so, this appears not enough. I occasionally try 3D design and use cleverly engineered CAD tools to make useful shapes with my clumsy gestures on a mouse and clicks on a keyboard. Occasionally I try my hand at coding in Perl. Perhaps I could blend the two. Both Perl and OpenSCAD are scripted tools which themselves can produce textual yields. Python is already used to enhance OpenSCAD, and there is perhaps no reason for Perl to match or even exceed this capability. It should be possible to generate .scad files and even post-process the STL files that follow.

CAD::OpenSCAD is a module I started recently. A simple tool that can generate .scad files in a Perlish way. I also used this to learn Object::Pad but in way that will be open to criticism I am sure. I avoid signatures to allow for polymorphism. I avoid multiple classes for for now simplicity until it is more clear what a final class structure should be. Experimenting with this has been interesting. What has been fascinating is is how easy it is to generate scripts that can let another program do all the heavy lifting. But this is a project in its infancy; I have barely scratched the surface of OpenSCAD can do.

image

OpenCASCADE is another interesting project being explored, this time by Michael Conrad, introduced to me in a Reddit post. His work has just demonstrated to me how little I know. OpenCASCADE has many features not available to OpenSCAD. Indeed, there are many CAD tools that are more capable; I am hoping that its scriptabilty, and a hybridisation with Perl would allow more sophisticated features for programmatic object generation and data visualisation.

Objective Decisions

Prioritisation of Panic

Let me start off by asking the folk on this platform one question. Imagine a scenario that you had lost something important with multiple potential negative consequences. For instance losing a bunch of keys including your car keys, your house keys, your changing room locker keys and a USB stick. What would be the greatest cause for alarm? I suspect that while there may be many possible answers aligned with each individual’s life priorities, the real men in this group know that the most feared is the reaction following the revelation to the wife. For while any calamitous occurrence may be approached objectively, with rationality, reflection and hopefully recovery, this particularly troublesome phase involves heightened emotions, reactivating Mrs Saif’s indelible memories of my many past failings. Objectivity, while desirable in principle, has to deal with such a tainted history.

I won’t elaborate further on my survival. I have survived. Barely. Indeed, over the years I must have acquired as poor an ability to remember traumas, as Mrs Saif is good at recollecting them. I haven’t figured out whether it is a natural self defence mechanism shielding me from PTSD, or whether it is a blessing that with age comes a little deafness, poorer eyesight, slower reactions and a reduced residual capacity of my intra-cranial hard-drive. But either way my poor wife’s vain attempts at reforming me, making me a better me, is met with the resistance caused by my irritatingly chilled attitude, constantly in perpetual denial of any need to change, and being so easily distracted.

This experience may help understand the general antipathy or indeed apathy towards any radical change from that which had been established over years. Objectively, a modern object orientated infrastructure within the core appears desirable. But such a goal is not a well defined endpoint. While there are a number of excellent bolted-on frameworks in CPAN, there are differences in priorities and performances. Entry of this form of modernisation into the core without upsetting core values is always going to difficult.

But this work is even more difficult for the poor core developer working on this task. He relies on feedback, without which he finds himself providing a valuable community service without any indication of what the value of his efforts is to that community.

So I decided, while watching a rubbish, inane but ludicrously popular game show, that for once I will make an effort. Not a personal resolution to be more responsible (apologies to Mrs Saif). I am too old for that malarkey. I will use Object::Pad. I will try and replicate this game in an attempt to learn this new way of programming. I will try two things…Firstly by emulating this game using easily identifiable objects, secondly converting a module I have been using into one using Object::Pad. Then I will report back my personal experience of this style of coding. As a disclaimer, I have only ever used classical packages in Perl so am unable to compare with Moose, Moo, Venus etc. I am also as messy at coding as I am in my head.

Deal or No Deal

Version001.png

A simple game where the player has to only answer one question to win money, while captivating one half of the audience, and mystifying the other half at how this could possibly be called entertainment. It seems simple enough to code. We have a “Game Board” object, containing a series of “Box” objects. The boxes each contain a random “Money” Object. A “Banker” object and the game board interact with the player via Objects representing the “Display” and the keyboard “UI” derived from old packages I have lying around. These objects may each have methods for drawing or undrawing themselves, or sending a message to the player, and responding to the players choices.

My effort has been so far remarkably smooth. Using signatures, auto-magically generated setters and getters has made this a remarkably straight forward and efficient process. The game is not yet complete…the biggest attraction of this game is not the challenges it poses but the “banter” and the suggestion that there is any skill or strategy involved. A reasonable algorithm for identifying what the banker should offer would also be interesting. My next post, once this game is completed, is a little review of how the whole experience has been for me, the visible benefits and drawbacks if any.

“`

Justifying Embarrassing Errors.

I remember when one one of my grandchildren helpfully decided reorganise a bookshelf whilst by himself. Upon being discovered, sitting in front of an empty shelf with books strewn all around him, his instinctive reaction made me feel proud to be his grandpa. He looked up and said, “Oh dear! Oh dear! what happened?”, as if this calamity had occurred spontaneously, astonishing him as much as the angry parent who was going to have to tidy it all up. It is hard to hide amusement when you watch your kids have to deal with their kids.

Advanced Disaster Management Strategy for Grandchildren and Programmers

You see, he had acquired the first step in Advanced Disaster Management Strategy for individuals who have caused the disaster and know it. Display Of Surprise, is good for buying time, creating a flicker of doubt in the prospective accuser, and allowing the next phase to be implemented. Such is the lot of us amateur programmers, who in attempting to display what they had felt was a masterpiece, are discovered having produced mangled unintelligible rubbish. The ever-helpful Perl programming community are able to step in and gently point out that usingperl-untidy was not such a good idea.

The next phase in ADMS in any project, is to Identify Someone Else to Blame. At first glance it might appear difficult in solo projects, but inevitably all projects have dependencies, and one can always say “If only $target_for_blame was able to cope with my advanced needs…”. This target could be a module on CPAN or the language itself.

But eventually you get found out. You get found out because the people you are sharing the code with know a lot more, have experienced bad coding practices, and spoken out against these before. Personally, I have a sneaky suspicion they have done dodgy coding themselves, no matter how much they deny it. But here we are, red-faced, mumbling, shuffling feet and looking at the floor. The next phase starts. You start Justifying the Errors. The old “feature-not-a-bug” strategy. “I wasn’t trying to create obfuscated code…I was trying to make it more compact”.

The eventual “recovery phase” requires a reluctant re-write. It is true that Paella v0.07 grew in size by 80% to v0.09 without adding any significant functionality. This was purely to try and make the code a little more legible, object-orientated, structuring subroutines into packages, such that it may be easier to reuse elsewhere, perhaps allow others to re-spin the code and many other potential benefits. I tried to do this, without grumbling all the time. It was difficult. You see the purpose of the project was discovery, but progress was being held back by the desire to satisfy the tidy-minded observer.

“Mummy is being really Mean, grand-dad,” said the little monster.
“It’s ok, mate,” I tell my offsprings offspring. “Mummy is only grumpy because she doesn’t understand. Her mummy is the same with me.”
“Does gramma tell you off too?”,
“You betcha!”
“I was only trying to fix it, like you said”, sniffles follow.
“Shhhh! I know, but hey, who needs to keep things tidy, when we have more important things to do…?”

You almost feel obliged to encourage the little beggars.

Making time to waste.

Over the years that I have existed in four dimensions, I have come to accept that time is not a linear concept heading inexorably in one direction at a uniform rate. It didn't take an Einstein or Hawking to convince me either. Time is as malleable as the distortions applied by our consciousness, or imposed by those around us. Consider my youngest daughter's essay due to be handed in on Tuesday, a task assigned 4 months earlier. At 4,000 words, it represented roughly 6 words an hour allowing for eating, sleeping, work, weekend fun, and other essential time-devouring activities. Yet the "I have got plennnnty of time, chill, dad!" of a few months ago, has now turned into cries of despair, as she has to do an all nighter at her desk instead of being at some selfie-rich event critical to her mental well-being and social standing.

The same happens at work when I get hauled over to the management because something I have no control over happened that shouldn't have happened. It seems that the eternal role of some such individuals is to improve efficiency and productivity without actually doing anything efficient or productive themselves. A strategy that some favour is to highlight trivial events, hold someone responsible, persistently bring this up at various encounters and thereby have justification for their existence, rather than allow access to the time machine that would enable correction of this past undesirable event.

One thing that might help these recurring, seemingly totally avoidable, but absolutely inevitable episodes, maybe be a set of rules. I have recently discovered RRULES, EXDATES and RDATES that can be embedded into iCal objects to define repeats of events. Some may be be repeated forever, some being confined to certain days of the week, each represented in a human readable form but parseable by machine. In order to achieve as much flexibility as possible, the rule structure is as complex as it is comprehensive.

One has two options when encountering a novelty such as this. One could look through the extensive experience and expertise of the Perl community who would naturally have some way of parsing these rules; easy, efficient and most likely to work. Work such as iCal-Parser by Cedric Cellier and Data::ICal::DateTime by Flávio Soibelmann Glock. On the other hand, one could try and build one one's self.

RRULES can become complicated,

# every year forever
"FREQ=YEARLY",       

# every other week forever
"FREQ=WEEKLY;INTERVAL=2",

# first week every month excluding weekends until                               
"FREQ=MONTHLY; BYDAY=MO,TU,WE,TH,FR;BYSETPOS=1;UNTIL=20141129",

#  every three years on the first Tuesday of October that is not the 1st of October
"FREQ=YEARLY;INTERVAL=3;BYMONTH=10;BYDAY=TU;BYMONTHDAY=2,3,4,5,6,7,8",

Parsing this kind rule can become rather difficult. Generating them reliably to do what you mean without ambiguity is similarly tricky. Feeding back this rule to the user in plain English is something that can also be challenging. It helps to steal other peoples ideas, but often one is trying to crowbar these rules into a project that has already been started, and a more eye-opening, time-consuming failure-ridden approach is required.

Finding time to do the research is difficult when you have a day job and many other demands on the time. I am sure the reader will have many experiences of temporal field manipulation, or perhaps are experts themselves. Time is infinite, but the time allocated to us is finite. We may choose to rush through life collecting as many experiences as possible, maximising the utilisation of this limited resource to earn, spend, learn, teach, give, take, create or destroy. I am told I waste a lot of time. I write code other people have done better for no return other than the same joy my grandson may have from drawing something unintelligible to show me. Sometimes I do it just so that something else more important can be forgotten, for even a little while. One could (or perhaps should) choose to do nothing other than to savour time that we do have, giving ourselves time to do nothing more than be alive.

Time may be precious but it will not be contained, disappearing from our grasp whatever we choose to do or not do with it. For me whatever you with it, time is never wasted. As one who has someone very dear to his heart going through a serious illness, time spent just being with someone you love is the most precious, irreplaceable time of all. Wishing you all happiness, love and peace.