Thursday, 7 June 2018

Learning Python by Writing An Application (1)

I don’t read Slashdot as much as I used to, and so I have no idea if people still ask “What’s the best way to learn a new (programming) language”? The answer was and ever more shall be: read a decent introduction to it, then write an application with it. Not toy examples, but something you will use. Why? Because then you will have to get to grips with the file-handling and string-processing functions, as well as some basic UI functionality, as well as the specialist libraries you need for the task.

That’s what I’m doing for Python.

Assume you have a bunch of files in a high-level directory called MyFiles, on the drive of your working computer. You want to make a backup of this from time to time. If it’s small, the simplest thing to do is copy MyFiles onto an external drive. With a lot of files that could get time-consuming, so maybe a backup program will do. Except that backup programs often create their own special file structures, databases, or at the least, zip everything up. I don’t want to use a special program to manage the backup: I want to use Windows Explorer.

What I need is a clever copying program. I tell it the source directory and the backup directory, and it recursively scans down the source tree, copying only the newfiles and the new directories it finds. Then, if I’ve asked it to, it removes any files from the backup directory that I deleted in the source directory since the last backup.

That’s the sort of thing that Python is good for. So I downloaded JetBrains’ PyCharm Community edition (because free) and started. I know how to program, and I understand basic Python syntax, but what I don’t have is a lot of familiarity with all the libraries, and especially Tkinter, which is what I needed for the user interface.

How does one cut code without knowing all the libraries? Slowly, with various reference websites open in the browser. That’s what manuals are for.

This illustrates the difference between being a programmer, and being a productive (insert name of language here) programmer. Because I’m a programmer, I can break a task into activities the computer or user needs to do (‘get the spare space on the destination drive’), and it usually turns out that the tasks I identify correspond pretty closely with the functions available in the system libraries. Programmers tend to think alike.

I understand control flow, arrays, variable types and declaration, threading, and use of functions to make code readable and maintainable. (I know, you want to hire me already.) I learned that writing FORTRAN, C, and VBA. Writing long chains of macros and the queries for them in Access is programming of a kind as well, as is constructing chains of raw SQL. It’s all about organising the resources of the language to get done what you need to get done.

Faced with a new language, I look for how those things are done, as well as any other cool tricks or idiosyncrasies it has. And, because I’m a programmer, I Read A Freaking Manual first. (This approach will not work with LISP and other such languages. Those really do need to be learned from zero, or you will miss the point.) On a meta-level, I’m Dreyfus-Proficient. That’s the engineering training. I’m just not slick.

All that said, I wouldn’t go for a Python job because one of the requirements is muscle-memory of the main system libraries, and familiarity with whatever the job-specific libraries are. I don’t want to be one of those guys who bluffed about their skills.

I have the sneaking suspicion that I’ve written VBA in Python, and that a Truly Pythonic Programmer would do the whole thing in two lines of code, one of which is a recursively self-referential array of filenames, and the other of which would implement a beautiful wxPython interface in less than twenty characters.

‘Pythonic Programming’ is a Thing. It’s a style. TPPs can do in a line what RJPs need six hundred lines to do. But becoming a TPP takes serious study, not to mention the right examples.

Next post, I’ll talk about the program.

Monday, 4 June 2018

April / May Diary

April and May are not my most stable months, because birthday. I don’t know why, because I’m not regretting the past, nor do I wish to shut the door on it. My only problem is an extra inch on the waistline and the difficulty shifting it.

April started with Easter. So there was that. The diary says I had a cold at the start of the month, because it was effing cold.

I was at the time doing steep incline walks on the treadmill and focussing on using the hamstrings to move my legs (it’s not as easy as it sounds). Then I suddenly got a painful lower back, blamed something else I might have done, and a couple of days later realised, yep, it was most likely the hamstrings. Another visit to Petra the Sports Masseur, who inflicted six kinds of pain with her elbow and pronounced me cured. Which I was. Not doing steep incline walks again.

Towards the end of the month, what with Sis and I alternating weeks to get colds, we hadn’t had our monthly supper. So I jumped on the Interwebs... if you want to eat at Gymkhana starting between 6 and 7 in the evening, you have to book about ten weeks in advance. So I did that, and booked us in at Merchant’s Tavern for the last Friday of the month, and Pizzaro in Bermondsey towards the end of May. Pizzaro do a fried dolche de leche which may be one of the best desserts I’ve ever tasted.

We got an exciting works day trip down to Cardiff towards the end of April, and very pleasant it was too, on one of the new trains and with very few people on board. I spent most of the trip going over and over the same three or so pages of Nik Weaver’s Forcing for Mathematicians, and finally came away with a much better understanding of how Cohen Forcing works. It’s much simpler than all those complicated derivations of Boolean-valued sets would suggest. That’s the subject of another essay entirely. I vowed I would not pass off this mortal coil until I understood Cohen Forcing, and now I do.

‘They’ re-located us again in May, to an ‘Agile workspace’ along London Wall. Suffice to say, I have to find an armchair (!) when I need to get my coding flow on, and spend much of the afternoon at a sort of dining counter (!!). The actual desks and chairs are unusable. As are the second screens. So I’m back to using the laptop screen, no mouse and no external keyboard. Do you know how insensitive the trackpads on a cheap HP corporate computer are? There’s a clue in the question.

For my sixty-fourth birthday, I visited my friend in Utrecht, as I always do. On the way over, I made a side trip to Zandvoort and had a nice steak at Vooges, one of the many restaurants along the beach. Saturday the weather was grey, we walked around Amsterdam, had lunch in the Cafe de Prins, and supper in the Restaurant Griftpark in Utrecht. Sunday the sky was blue and the sun was hot, so we walked around the canal and had a light lunch at the Louis Hartlooper complex, and a few hours later I made my way back to Schipol and a slightly delayed KLM flight.

I saw Deadpool 2 at Cineworld; S4 of House, and the Jack Reacher movies on my DVD.

I read Tom Holt’s The Management Style of Supreme Beings; Robin Fleming’s Britain After Rome; Slavoj Zizek”s The Courage of Hopelessness; Will Storr’s Selfie; Filip Springer’s History of a Disappearance; L David Marquet’s Turn the Ship Around; Nik Weaver’s Forcing for Mathematicians; Michele Friend’s Pluralism in Mathematics: A New Position in Philosophy of Mathematics; Øystein Linnebo’s Philosophy of Mathematics, and his co-edited collection New Waves in Philosophy of Mathematics; looked at the book of Stik graffiti I bought a long time ago. The commendation goes to History of a Disappearance: it's not a person who disappears, but a Polish mining town. It's actually quite moving at the end.

I finished and tested the MVP of my smart sync Python program, about which a couple of posts later.

I’ve been looking at G-Shocks for a while, but never quite found the right one. Side note: for a Real Watchy G-Shocks are in the Premiership of watches, not at the top with Rolex and AP / PP, but Premiership material. Then Amazon did a deal on the AWG-M100-1AER, which I decreed to be my birthday present to myself and snapped it up. Amazon delivered it the next day. Non-Prime. Not bad.

And May ended hot. So that was okay.

Thursday, 31 May 2018

Like minded people: WTF?

Read any list of advice about how to improve your life and ‘finding like-minded people’ will appear. It’s a guaranteed sign of a half-assed list produced by someone with little knowledge of the human condition.

My birth year cohort was about 450,000 men.

I’m a lifetime bachelor. According to an ONS dataset I can’t find again, that’s one in ten of my birth year cohort. 1 of 45,000

I have an undergraduate degree from the mid-1970’s. Counting in the polytechnics, one in five of my cohort got one of those. 1 of 9,000.

I have a postgraduate degree. One in ten undergraduates did that in the mid-1970’s. 1 of 900.

I’m still working. Half my age cohort are doing that. 1 of 450.

I’m long-term sober. I can’t remember the last census count from AA, but it was less than 100,000. (Really. And even then, that’s a gross over-estimate of the number of ex-drunks with long-term sobriety). Out of an 18+ population of around 50 million. Which is 1 in 500.

So that’s me. Unique in my birth year.

We’re all equal, right? Well, if you want, but we’re all different. Some of those differences matter, and many don’t. Being a lifetime bachelor matters (as does being MGM’d as a baby, but that’s another story). That my degrees were in Philosophy of one kind or another, mixed with chunks of mathematics and logic, matters. Philosophers are not as other people. As for being long-term sober having worked the programme and done the Steps, you can’t even imagine the difference that opens up.

This is not a play for tragic status or for sympathy. I don’t want either. There are a bunch of other people whose experiences, on the way to wealth, artistic recognition or athletic success, separate them from everyone else except the other fifty people who went through the same wringers. I have nothing in common with them either.

My question is: who the frack are my ‘like-minded people’?

I have some friends. We can communicate. I think they might be insulted by the suggestion that they and I were ‘like-minded’.

So I have another question: why are ‘like-minded people’ important? Or is it a code? For, you know, being gay. Or fascist. Or an Aston Villa supporter. Or a Conservative in Rotherham. Or a train-spotter. Something that give my identity a distinctive flavour.

My identity, such as the poor worn-out thing is, has no particular flavour. So maybe there are no ‘like-minded people’ for me.

Monday, 28 May 2018

What To Do Now I’m 64?

Birthdays are probably exactly the wrong time to take a look at my life and figure out how to change it for the better, but that’s what I started to do. So here’s part of the inventory.

For a few years after about 2008, I had a picture of myself as an older man fighting to get out of the trough of a long relationship that ended badly, needed to get back into and then stay in shape so my blood sugar got back into sensible levels and I would not walk around in a brain fog. That’s why I started back at the gym in autumn of 2010. In 2014 I got my Over-60 Oystercard, and for the next many months, every time I used it I thought about my age and not wanting anyone to see I had the card. In 2015 I decided to get my teeth fixed, and took the braces off towards the end of 2016. While the braces were on, eating nice food in pleasant restaurants was sometimes actually painful, and every other activity was accompanied by a low-level non-stop irritation from the braces. I stopped going out for about the last eight months. When the braces came off, It took a while to get used to eating with unencumbered teeth. Which takes me to 2017.

I didn’t think of it at the time, but the orthodontic treatment gave me a picture of myself as an older man struggling with a problem of age. Wonky, misplaced teeth is not, I grant, a stroke, or a heart attack, or a broken hip bone, and that’s what makes my reaction worse thank you very much. Those would be Real Serious Events, not just teeth. However, you get your teeth straightened out at sixty-one and let me know how you handle it. That compounded with A Man Working Past Retirement (or Up To State Retirement Age), which I became in 2014. These are not good looks.

Start with the fundamentals.

I’m a long-term sober alcoholic. If I get to sleep sober, that’s a good day. Living sober gets easier but it never gets easy. Emotional sobriety is like a strict diet: it keeps me out of trouble, but people were designed to live with occasional dramatic episodes.

I have to watch my blood-sugar. So I have to be the older guy who still looks good (as one with anterior pelvic tilt can) in a tee-shirt. Sure, there’s a tinge of vanity-as-motive in there, but it’s mostly about the blood-sugar. Visits to the gym are necessary, not some indulgence.

I am in my mid-sixties working with ambitious people twenty or thirty years younger. Call my nephew when you’re doing that and keeping up. Even showing up for work every day is an achievement at this age. That’s where almost all my energy is going now, but it’s also where all of my money comes from. So. Prioirities. I don’t give myself enough credit for it, and I’m going to start now.

I’m not going to go on complaining about the iPhone zombies, Millennials, Boomers or any other darn group. They don’t behave as my generation did when we were their age, but then the precise conditions of really-existing post-modern capitalism at this exact moment in time are very different from the conditions prevailing when I was their age. Their responses to those really-existing conditions are exactly the ones Capitalism needs at this stage of its evolution. Anyone who complains is on the wrong side of the inexorable evolution of capitalism. (This doesn’t mean that the evolution of Capitalism is morally acceptable, just that it is inexorable, like the tides and volcanos.)

I’m going to stop trying to track the way the world is going. It’s a way of pretending to be involved in what’s going on when I’m not involved at all. And I figure I’ll be gone before whatever catastrophic social circumstances occur, and there’s nothing I can do to stop it, so why bother? Old people tend to be left alone by social revolutionaries anyway.

However, Brexit is Brexit, the EU is the EU, and the market is the market. I need to take a view on whether investments are the best place for my money. This is where I have to remember I’m supposed to be a strategist, or was, once.

I am a life-time bachelor. That isn't changing, and nor do I want it to.

I waste a lot of time on the Internet. This is to do with being frazzled at the end of a day: too tired to focus on a plot, or a book, or a project, not tired enough to crawl into bed at eight-thirty. Plus the feeling that out there somewhere in Internet land is someone who will say something that will give me a new direction. Nah. This means the hard work of shaking off an old bad habit and getting into some new ones. Or going to bed really early, as I was doing at the start of the year.

I know. It sounds like more of the same. Fine-tuning. The sign of a life that’s fundamentally sound. Not exciting, not fun, but sound. Which, given that I’m an alcoholic, is pretty good.

I have three behaviours that may or may not be symptoms of something I need to change. I don’t go on holidays; I can barely remember to do anything about the few social events that happen; and I have little to no enthusiasm for movies, shows and theatre. I’m not going to examine those in this post.

Monday, 21 May 2018

I turned 64 last week. This is a song about that...

Thursday, 17 May 2018

The Implicit Choice in the Maslow Hierarchy

"The hierarchy remains a very popular framework in sociology research, management training and secondary and higher psychology instruction.” So says Wikipedia. Judge an theory by the company that company that keeps it, and Maslow’s Hierarchy should be tossed in the bin for no more reason than that it is "a very popular framework in sociology research, management training and secondary and higher psychology instruction”. These are not reputable, hard-science, subjects. What they are, are normative theories disguised as descriptive ones. Morality passing itself off as science.

Maslow’s Hierarchy is the idea that people have a bunch of needs, some of which need to be met more or less well before we can go on to meeting the others. At the base of the pyramid he put physiological needs;: air, water, food, sleep, clothing, shelter. That’s the Rule of Threes: three minutes without air, three hours without shelter in extreme conditions, three days without water, three weeks without food. Those will kill you. Three days without sleep risks permenant damage to your mind.

Next is Safety, so that we’re not being raided by Vikings, dragged off to prison at two in the morning because we said something wrong, mugged when we take money out of an ATM, let go from work because the order book is looking thin, or getting beaten and abused by parents, teachers, policemen, or the other kids at school.

Given some safety, we can move on to Social Belonging as evidenced by having friends, intimacy, and being on good terms with our family of origin and our own family if we have one.

After that, we have Esteem, that our abilities and contributions are recognised by people whose opinions we care about, and that generally, the people around us think we are a Good Fellow. And then at the top, we have Self-Actualisation, which is realising one’s potential and abilities.

Notice that without the idea that these items are a) needs, b) ordered, and c) must be satisfied in order, this is just a list of stuff that we would like to have. It has no force.

The Hierarchy does not describe how we botch our way through our lives, grabbing an hour of self-actualisation at the gym, an hour of living death on the commute, eight hours of insecure employment (lack of Security) to pay the bills and the taxes that provide policemen and defence (Security, of a sort), before returning to a frugal meal and an empty bed (lack of Social Belonging), while trying to get a promotion, improve our professional networks (Esteem), and maybe get a drink with the Lads at the weekend (Social Belonging). Jeez, what a mess.

A number of things are not on the list: wealth or high income, exceptional athletic, artistic or intellectual achievement, religious vocations, or anything else that requires sustained, time-consuming dedication and the risk that all the effort might not lead to the winner’s podium or the award ceremony. These are examples of self-actualisation, but cannot be achieved without delaying other lower-order needs for so long it counts as abandonment. In other words, without some nifty verbal gymnastics, the Hierarchy is self-contradictory. You can’t have it all. Not without a lot of money, luck and a solid character.

But maybe decribing these compromises wasn’t Maslow’s aim.
Maslow studied what he called exemplary people such as Albert Einstein, Jane Addams, Eleanor Roosevelt, and Frederick Douglass rather than mentally ill or neurotic people, writing that "the study of crippled, stunted, immature, and unhealthy specimens can yield only a cripple psychology and a cripple philosophy.” Maslow studied the healthiest 1% of the college student population.
Maslow originally put sex in the physiological needs, and large numbers of puritans disagreed with him, or prissily said it was there because the survival of the human race. Some descriptions of the Hierarchy leave it out. Was Maslow on to something? Perhaps he thought that if a vigorous young man isn’t getting laid on the regular, he’s going to be distracted in the pursuit of his higher needs? I was a young man once, and I approve that insight.

That was what made me wonder if Maslow was pointing at something else, but happy to be lucratively misunderstood. I started this with the intention of explaining why the Heirarchy was nonsense. Then I wondered: what if Maslow was right? Not about how people manage to bodge and survive their way through the circumstances of their lives, but about what the circumstances of our life must be, to be satisfying as it is lived, rather than in retrospect when there’s money in the bank, awards on the walls and every Maitre d’ in town knows your name and face. What if the Hierarchy is actually a diagnostic tool rather than a truth about people?

C-Heads describes "the 21st century girl… a chick of many talents, one moment she’s in Europe, the next she’s in Asia. She’s working on several artistic projects at once and killing at every single one. She’s a mix of races – picking up different cultures as she travels. She’s the mysterious girl at the party you want to know her life story who everyone has their eyes on", and yet… what? She can go through the Maslow levels, tick or cross as applicable. When she finds herself arguing about whether this or that is really a need, that’s a cross. Now she can see what’s missing. And she may understand that, if she wants to go on killing it at every single project, then that's the price she pays.

Human beings are needy animals, and at any given time one or more of those needs will be going unmet. For many people, it’s far more than one and it’s every day of every week of every year. And the more lower-order needs go unmet, the shakier is the pursuit, and enjoyment, of the higher-order needs. The Hierarchy tells us where the structure of our lives and our selves is shaky. Reality tells us that the shakiness may just be the way it’s gotta be. Because The Hierarchy is impossible to satisfy from bottom to top. You have a choice: you can be satisfied and risk the occasional feeling that you haven’t made the most of what, if anything, God gave you; or you can aim to develop and exploit your abilities and talents, and accept the surety of dissatisfaction with this or that aspect of your life.

Thursday, 10 May 2018

What would you do with a million pounds?

We used to have a game at junior school called “What would you do if you had a million pounds?” Since one answer was always “buy a house” and for that sum you could have bought about eighty (!) of my parent’s houses, at today’s prices, make that “What would you do if you had eighty millions pounds”.

I’d buy my sister a house, and I’d give my nephew some money so he didn’t have to take the first job that came along just to pay the rent, but could go find a step on a career ladder. My mother already has a nice house.

That’s what everyone says, as well they should. I suppose I’d buy myself something in central London, maybe in Bloomsbury or Marylebone. Or maybe not. Maybe I would travel round the world, concentrating on large cities and villages by the sea, to find somewhere I really wanted to live. If there was such a place. Or maybe I’d find a university which would let me use their library and let me do a PhD. Or not, these days, given the state of the modern university.

Perhaps I’d back some start-ups, but I know that a lot of those are basically CV-enhancement schemes for BCBG Ph.D’s: the idea is that the start-up is flipped to a large firm who really wants the top talent. Anyone outside the in-crowd is a sucker who is not going to get an even break.

Establish a scholarship for a British philosopher of mathematics to study for a year abroad, to be awarded annually. Maybe.

I could buy art. That would give me a faux social-life.

What I would not do is buy a £15,000 watch. Or a £250,000 sports car. I might buy a few days at Silverstone driving fancy sports cars though.

I could become an eccentric recluse in my Amsterdam house by a canal, watching movies in a special screeening-room and having meals brought in from the nearby one-star restaurant. On the days I was not watching films, I would go to Zandvoort by limousine and walk along the beach. It’s a large beach. I’ve just spent a few minutes fantasising about a year spent working my way round the beaches from Italy, south of France, Spain-Portugal-Spain, France again, Cornwall and ending in Wales. Or something like that.

Maybe I’d get some sessions with a celebrity therapist just for fun and the possibility they say something that changes me. Jordan Peterson could tell me I deserve all the problems I’m having because I don’t have family.

We used to have fun with this game. It was exciting to think of what we might do. Not so much now. I have a feeling that I would do a number of worthy things with it, and get a decent flat in the upmarket section of a serious town. The catch with growing-up is learning all the downsides and costs: the young only see upsides and benefits.