Tuesday, 22 May 2018

Introduction to C++ : Starting C++ Series Part 1

A few of you maybe aware of the book on Python I wrote, and published, last year?  And I've had at least one reader get in touch for a second part.  Unfortunately my gaze has passed over Python and returned to where I live.  The world of C++.

I have a particular problem with the C++ developers I'm meeting of late, they're either simply not C++ programmers, being an actual mix of good and bad C programmers or just not programmers at all (in one case).  Then even when they are very good C Programmers, there's been a mix of the up-take on ideas and feature benefits of modern C++ itself.

Its to and for these fair folk I have begun to write about C++, a new book, based on my own real experience but tempered with where I believe teams and individuals are going wrong when converting their skills to modern C++.

For the programmers reading here now, it starts with a chapter zero... Lets take a sneak-peek....

Chapter 0: Introducing C++

It is incredibly hard to introduce the C++ programming language without at least the most cursory glance at its direct predecessor C. C was created by Dennis Ritchie whilst at Bell Labs sometime between 1969 and 1973, in 1978 Dennis co-authored a book, the book, on the C Languages with Brian Kernighan. Together known as K&R, Kernighan and Richie's book was a great success,
spreading C into being, arguably, the most widely used programming language at the time, and still in that top ten league today.

The success of this first publication, its relative low price of entry into the fast developing world of C for an ever growing number of different machines, really did set C as the language to learn for a very long time.

"C has all the basic elements for expressing computation, it has iterations, it has data types, it has functions and that's it. It doesn't get into the game of expressing abstractions" - Bjarne Stroustrup.

So the world was until 1980, when a talented programmer by the name of Bjarne Stroustrup;  working just down the hall from Brian Kernighan at AT&T began a project. He called it "C with Classes". Intended as a natural extension to C, it inherited a large part of the C language syntax as well as many of the mannerisms of C and general purpose computing from the late 1970's.

The concept of "C with Classes" was to furnish users of C with a way to allow the representation of abstractions, if one wanted to represent a car in code they could define something called a "Car", it could have internal values to represent it's speed, direction of travel, the fuel level, everything that we think of as a car could be expressed within a class. In C one has no such way to encapsulate such functionality with any form of familiarity.

Certainly in C you can have a set of variables which represent the exact same things, you can name them to have a meaning of "fuel level", however they are not within anything known as a "Car" you as the programmer has to remember where all these values are, what they are called you have no easy of recall to get back to the values you are using, the concept of a class (what today we also call an object) was one of the major drivers behind the work being carried out.

The name however, "C with Classes" was not as succinct as one might desire, and indeed a friend of Stroustrup suggest he change the name of the language to C++, as the "++" function literally means to add one, an increment. The new language is an increment over the old.

Since then C++ has been ever evolving, in 1998 the first standard version of C++ was codified, from pre-existing attempts to unify the language by both specific vendors of tools for the language (such as Borland, Microsoft or Lattice) and industry bodies (such as ANSI). Published as ISO/IEC 14882:1998 by an ISO working group, C++98 drove home that C++ was at last truly diverged from C. A language in its own right, and something which had to be thought about differently.

I myself started to learn C++ in 1996, the difference in the community before the 1998 standard and afterwards was palpable, since then four other standard have been released. 2003 brought C++03, 2011 brought a working set of revisions ultimately called C++11, but also known as C++0x (due to the new standard taking so long to finalised, it was drafted and promised many times between 2004 and 2009 hence "0x). 2014 saw a further release as C++14, then 2017 saw C++17. The next revision is slated for 2020, it's name is yet to be decided, though good money could be placed on C++20.

From this release schedule we can see the acceleration curve, the faster and faster pace at which C++ has and is diverging from it's roots in C. It has matured, expanded and at each new update become more inclusive of functionality based on abstractions.

Today you can pick up modern C++ and it contains much more than the sum of its parts, you can express everything you could in 1978 in C, but so very much more.

Unfortunately, this success in expanding it's expressive nature, incorporating ever more abstractions and structures from computing, and every-day life, is tainted with some sadness, for as much as C++ strives and drives and builds every upwards, forever it has this seemingly unbreakable umbilical back to C.

You can pick up any C++ compiler from any vendor today, on pretty much any platform, and input a huge swathe of code written not in C++, but still written in C. You can elect to put this very book down right now, pick up a copy of the same book published by Kernigham and Richie in 1978 and produce code which works and work-ably solves some parts of the computational challenges you

However, none of that code will be expressed in the powerful, elegant, I think beautifully powerful manner in which C++ allows you to. Abstraction, encapsulation, expressive representation of the real world in code in a manner which betters your understanding of the topic (as the programmer) but also allows others, non-programmers, to comprehend the devil within the detail of programming a modern computer.

Thursday, 17 May 2018

Google Illegal Wire Tapping?

I find this truly disturbing...

I have literally just disabled my microphone.

Tuesday, 8 May 2018

V.E. Day

Seventy Three years ago, I know roughly where and what all four of my grand parents were doing... All were variously occupied fighting as part of the British effort of World War Two, I do not know whether they were aware of the cease fire or impending Victory in Europe, and indeed for one of my Grandfathers the war was not over; as he was aboard HMS Belfast, just refitting for redeployment to the far east and the on going war with the desperate but crumbling Empire of Japan.

In this post, I'll cover what little I know, to share that nugget of who these people where and what they were doing.  So from oldest to youngest.

We have my Nan, or Nanna, Kath.  She was a young woman by the end of the war, from a child at the out break, a hard beginning in life in the care system with both parents gone by wars end she was in the Land Army working the fields of Norfolk, though a native of London.  She was born in the shadow of Portobello Road, and to this day (despite living in Nottingham for over 60 years) has no qualms telling me I have a "funny accent".

As we sit on the evening of this sweltering Bank Holiday Monday, she sits in the Queens Medical Center, perhaps in the last ebb of her life.  Though she told me long ago she's not herself (suffering advanced dementia) and would rather still be plugging around in those fields even if the farmers wife was an utter bitch [her words, not mine].

This Nan, now the oldest of all of my forbares is the only one still alive, so with a ting of sadness, but always pride we turn to my other Nan.

Mabel, a professional nurse, with a specialty in Mental Health care, at the outbreak of war she soon took to serving the airfields of her native Norfolk (yes, how ironic both my grand mothers pull on the county of Norfolk, yet I've never ever been - at least not in my memory - maybe as a very young child).

As the war progressed the USAF called upon support from British medical services for the large number of airmen being injured in the 18th Airforce's Daylight bombing campaign.  Mabel was one of the few nurses directly greeting Liberator and Flying Fortress aircraft as they landed.

One particularly vivid recollection she shared was with meeting a Liberator crew and checking on the tail gunner, seeing him with his arm raised smiling nothing ill was thought.  Yet the pilot reported the young man could not be contacted.  Upon approaching more closely a line of cannon fire was obvious along the twin boom tail, splitting the emergency access open two airmen began to bundle the young gunner from his position, except he was not well, his smile was his last act, he had given his life and as they brought him forward they needed two stretchers for this young man, who's upper half now lay peaceful in the long grass his eyes piercing the very sky above.

V.E. Day saw Mabel still tending the wounded, from the daylight bombing campaign still being waged by the 8th Air Force.

More happily Mabel however had met my Grandfather George, whom had married her by special license and never let himself be parted from her all their lives, but he was at the outbreak of the war already a professional soldier, though not at Dunkirk, he was stationed in Scotland.  Famously he was the sergeant of the guard whom was in charge of Rudolf Hess when he deigned to fly to Scotland.

He had been on the 6th June 1944 on the Normandy beaches, as he had exchanged his army stripes for Royal Marine stripes and was a member of the Royal Marines Commandos, he recalled looking back after reaching the top of a French street and having lost half his men.

1945 saw him on the Western bank of the Rhein, near the first crossing of British Forces (the Black Watch carried the Union flag across the wide waters of the river) whilst the Commando's carried the Union Jack.

Finally, the movements of Les my last Grandfather, and the first to pass away, his movements can be quite clearly tagged for a large stretch of the war as he was in the Navy and only on one ship.  However, he started the war as a boy just entering his teenage years, his brothers went off into the Infantry, whilst he had to settle with the Home Guard.  And in 1939 and 1940 he was part of a crew manning a Z battery, a rocket anti-aircraft position, near Wilford in Nottingham.

Frustrated with "being left at home" however, in 1942 at fifteen (and I belief after "borrowing" details from his brother Bill's credentials, he enlisted in the Navy (unable to join the Army as Bill himself was already serving there, and the subterfuge required he join a different branch).

Basic training complete he was assigned to the company of HMS Belfast, just in time for her recommissioning; having his a magnetic mine and received a broken back the Belfast returned to the war (arguably) as Britain's most powerful cruiser.  And she remains with us today, the only large gun ship from the Royal Navy preserved for the Nation.

Indeed, he was witness to the Battle of the North Cape, about which he recalled "the Parson coming around to hand out hunks of boiled white fish and tea, the best tasting Christmas dinner after being stood in the arctic air, waiting all night for the flash of massive German guns".

He was also aboard the ship on D-Day, with the Belfast leading off the shelling on their section of the coast.  With one grandfather struggling up the beaches, another was literally off short lobbing covering fire to him; which amazes me.  However, it was not without threat on board ship, as he recalled 88mm shells fired at the ship from the French coast, with one passing clean through the forward funnel, from which he received a laceration to the forearm and one of the ships cooks lost their lives (though, my recollection maybe wrong, and this event may have taken place in 1943 in the Med verses the Italian Navy and therefore likely not an 88mm, but the cook did loose his life).

From this posting he also traveled the world, and as the war in Europe faded he had little respite as the Belfast was refitting and reconditioning, in order to sail and join the fight against the crumbling Empire of Japan, and by August 1945 he was in Sydney, Australia.

The Navy had set his skills base down as a ships electrician, however his home guard training did not go unnoticed, and he was actually a loader for a "pom-pom" gun.  This was on the left cheek of the then bridge structure - if you visit the ship today this area has been remodeled, but if ask a guide about the WW2 configuration of the ship they can explain where this battle station was.

But as a AA-gunner he did not relish the idea of facing down Japanese Kamikaze pilots, this however was to be his role, until the VJ Day.

There you go, there's a lot more detail I could add to this, if you're interested let me know in the comments below.


Addendum:  I have never set foot on my Granddads ship, it maybe too much for me.

Sunday, 6 May 2018

Donald Trump hits Rock Bottom

Just watching this travesty....

What he fails to mention is that when everyone has a gun they hang out of casino hotel windows gunning down festival goers, kids kill kids in the hall ways of schools and colleges, that murder suicide is through the roof and you can be shot dead for as little as looking at someone in the wrong way.

Donald Trump and especially the NRA have this attitude utterly and totally wrong, and I can't begin to express how god awful this man is.

But then, let us remember, he is "leader" of a country where we report mass shootings as "the worse in" and insert very short amounts of time.  This however is glossed over in US reporting of this to it's citizens.  Where as we hear that Stephen Paddock killed 58 people, "the worst mass shooting in the US since 1991".

The CNN version states "the deadliest mass shooting in modern US History".... Define Modern Mr Trump and Ms CNN... Because 1991 is not a long time ago, I mean I know you're in a country with a history we can list on the back of a couple of greasy burger wrappers, but please 1991 is not old, and 1992 on wards is not modern history, and how many mass shootings have there been in "modern history", in say the last five years?

Well we have:

  1. Stoneman Douglas - 2018 - 17 murdered
  2. Lass Vegas - 2017 - 58 murdered
  3. Sutherland Sprints - 2017 -  26 murdered
  4. Orlando - 2016 - 49 murdered
  5. San Bernadino - 2015 - 15 murdered
  6. Umpqua College - 205 - 9 murdered

That's six attacks, how many where terrorists?  None... Not a single one is a comparison to the Paris attack, not a single one of these attacks was in effort of a social political aim, they were murder, for jealous, revenge, homophobia, all by people whom had armed themselves without the need to leap through hoops of be part of a terrorist cell.

Normal everyday people killing people with whatever happens to be at hand.

Which takes us to Trumps commends about the London Knife Crime, he's right, this is a problem, it is the exact same problem as I have just mentioned are on US streets, people killing people with whatever happens to be at hand.  Except, a kitchen knife, a shiv, heck even a sharpened stick is in an utterly different; lower; category of concern that someone picking up a .38 pistol and pointing it at coworkers over a parking spot, or their YouTube video loosing advertising!

America you have a problem, a much larger problem than you realise, you are being brain washed into looking outwards, that the world around you is horrid, that you might have it tough, but "hey look at London, look at Paris".... Beyond Terrorism, which is clearly more common here in Europe where we have a land bridge to the middle east & north African unrest.... we do not have a problem here, and you are being made look idiots (more so than usual) as you're letting Donald Trump and the NRA pull wool over your eyes.

There are no mass shootings, nor mass killings, here in the UK, nor Paris, nor anywhere else, except by extremely rare nut jobs, and I mean extremely rare.  The only ones which come to mind are Anders Brevivik in Norway in 2011 and Derek Bird in the UK in 2010... Remember we're going on the "modern" moniker given by CNN... Five years, both these attacks happen outside that time frame!

Look for the next killing spree in the UK, one does not look to the same year, not even the same decade we have to go back to the Dunblane killings in 1996.

This is what the world means, yes we all get this behaviour in our populations, people killing people, since time immemorial, the difference is in the US the tools to achieve such aims are so so much more readily available.  They are not a "tool" to fend off a terrorist attack, guns just become a tool to carry out more attacks, more people killing people, in more places on more occasions.  When will the American people wake up and smell the cordite?

This whole situation beggars belief.

Control Minecraft with only your Eyes

A beautiful story, really liked this....

Wednesday, 2 May 2018

The Best and the Worst : Working with Genius Programmers

A long time ago, in an office far away from where I now sit, I once worked with a chap I still refer to as the best programmer I've ever met.
This was a guy who could take the whole code base, in Delphi, home and over a single weekend re-write it in Java.

This was a guy who I saw, from scratch, write a C controller for an embedded PIC to capture an image from a listed in compatible TTL driven camera and then an analyzer for the captured images which would detect and show motion, making for our common employer their best ever selling product a cheap security motion detection system, which didn't rely on relatively expensive high resolution cameras.

It was awe inspiring as a newly graduated programmer, whom had a huge background in DOS programming, but whom had never worked in Enterprise level development before.

I sat next to what I still regard as near genius.

This very same chap was also the worst programmer I've ever worked with.

Because he was so highly functioning he never needed to document his code, fine I hear you cry, good code should be self documenting; and you're absolutely right; the problem?  This guy also got bored so so quickly, so he used to tell himself stories in his code.

Yes, Robert Jordon eat your heart out, this guy wrote epic fantasy on a gran scale, across hundreds of thousands of lines of code, in Delphi, C, C++, Java and even in HTML which I saw him churn out, it was all a gobbledygook puddle of story telling rambling mess.

But the code worked, the managers didn't care that it was gibberish; at least not at first; because they could churn out product to the anticipating masses of customers.

Such a prolific talent, he had so many fingers in so many pies, he was invaluable, key man, the man, the one person every project started with.

The result?  Every single code base he touched was tainted with this un-maintainable morass of code.  Which an ever increasing march of cheap graduate programmers, like my then self, had to then decipher, maintain and coral.

Often the time it took to bring a project into some semblance of order would be three or four times more than it took that one original chap to write, this did not go unnoticed and managers rightly pointed their fingers to ask the question "How could you not keep up?"

I however was the first such junior person with a voice, I've always had a voice, and I pointed right back "How could you let us get into this mess?"

I dated to question, sweep, and change the code, I dared to spend time even just aligning the code correctly.  No JetBrains formatting (or resharping) tools, very few tools existed to cover the whole pantheon of mess we were now wrestling to stay a head of.

Daring to question, change, read and challenge the talented one resulted in his changing his ways, he returned to some of the projects I had lead re-working, he saw the structure and the discipline within he saw that you could quickly pick up and get to work without needing to load all the software into ones wetware in a laborious re-read.

This skill, this willingness, to press the boundaries is somewhere I've oft and continue to take projects, and I do ask those I throw code at to feedback to me where they think anything needs reviewing.

I deplore any project or maintainer whom takes the grounding that they must keep things secret and keep things safe.

Drop, the epic fantasy, you're not Gollem, share, review and open the boundaries.

Monday, 30 April 2018

Kdenlive : First Impressions

They say first impressions count and that's certainly true for any tool I utilize.  In what little free time I've had over the weekend, I've been starting to edit up all the clips I took of the workstation upgrade & rebuild.  This is my passage from the pedestrian Core i7 950 to a Xeon X5670.

I've elected to update my video editing software and Kdenlive seemed to be the answer to visual challenges I had at hand, and oh boy was I right.

Following a seamless download of the Appimage version, a simple startup and about ten minutes orientating myself, then about a further ten to just get used to the S X and M control core points I was applying effects to clips, setting up spacing in between others and saving to perform a test render.

I am utterly and totally so impressed with Kdenlive, this is the first time in a long while I've been equally surprised and delighted by a piece of software.