Overload Journal
Total Page:16
File Type:pdf, Size:1020Kb
A ower Language Nee s Power Tools Smart editor Reliable with full language support refactorings Support for C++03/C++ll, Rename, Extract Function -:(r):- Boost andlibc++,C++ 7 Constant/ Variable, templates and macros. Change8ignature, & more Code generation Profound and navigation code analysis Generate menu, On-the-f y, analysis Find context usages, with Gluick-fixes& dozens 0 Go to Symbol, and more ofsmart checks GET A C++ DEVELOPMENT,:rOOL THAT YOU DESERV ReSharper C++ AppCode CLion Visual Studio Extension IDE for iOS Cross-platform IDE for C•• developers and OS X development for C and C•• developers Start a free 30-day trial jb.gg/cpp-accu Find out more at www.qbssoftware.com QBS SOFTWARE OVERLOAD CONTENTS OVERLOAD 160 December 2020 Overload is a publication of the ACCU ISSN 1354-3172 For details of the ACCU, our publications Editor and activities, visit the ACCU website: Frances Buontempo [email protected] www.accu.org Advisors Ben Curry [email protected] Mikael Kilpeläinen [email protected] 4 Questions on the Form of Software Steve Love Lucian Radu Teodorescu considers whether the [email protected] difficulties in writing software are rooted in the Chris Oldwood essence of development. [email protected] Roger Orr 8 Building g++ from the [email protected] Balog Pal GCC Modules Branch [email protected] Roger Orr demonstrates how to get a compiler that Tor Arve Stangeland supports modules up and running. [email protected] Anthony Williams 10 Consuming the uk-covid19 API [email protected] Donald Hernik demonstrates how to wrangle data Advertising enquiries out of the UK API. [email protected] 13 What is the Strict Aliasing Rule and Why Printing and distribution Do We Care? Parchment (Oxford) Ltd Strict aliasing is explained. Cover art and design 20 Afterwood Pete Goodliffe Chris Oldwood explains why he thinks Design [email protected] Patterns are still relevant. Copy deadlines All articles intended for publication in Overload 161 should be submitted by 1st January 2021 and those for Overload 162 by 1st March 2021. The ACCU Copyrights and Trade Marks The ACCU is an organisation of Some articles and other contributions use terms that are either registered trade marks or claimed programmers who care about as such. The use of such terms is not intended to support nor disparage any trade mark claim. professionalism in programming. That is, On request we will withdraw all references to a specific trade mark and its owner. we care about writing good code, and By default, the copyright of all material published by ACCU is the exclusive property of the author. about writing it in a good way. We are By submitting material to ACCU for publication, an author is, by default, assumed to have granted dedicated to raising the standard of ACCU the right to publish and republish that material in any medium as they see fit. An author programming. of an article or column (not a letter or a review of software or a book) may explicitly offer single The articles in this magazine have all (first serial) publication rights and thereby retain all other rights. been written by ACCU members - by Except for licences granted to 1) Corporate Members to copy solely for internal distribution 2) programmers, for programmers - and members to copy source code for use on their own computers, no material can be copied from have been contributed free of charge. Overload without written permission from the copyright holder. December 2020 | Overload | 1 EDITORIAL FRANCES BUONTEMPO Debt – My First Thirty Years Reflecting on code often reveals gnarliness. Frances Buontempo reminds herself about all the tech debt she’s ever caused. I still owe our readers an editorial, and know I have cutting corners. Computer graphics also cut corners, tending to rely on accumulated a huge debt over the last several years. representations made from a mesh of triangles, going in straight lines Fortunately, you don’t seem to be charging me rather than curves. This also means you can do the mathematics once for interest, so there is hope. As soon as you charge several vertices and speed things up [Wikipedia-2]. Cutting corners can interest on a debt, it is possible for the debt to keep be a good thing or a bad thing; it depends. growing and become impossible to pay back. In contrast, cutting the mustard is always good. When mustard was grown Charging interest, or at least excessive interest, is sometimes referred to as a main crop, it “was cut by hand with scythes, in the same way as corn. as usury. Anyone taking advantage like this is sometimes called a loan The crop could grow up to six feet high and this was very arduous work, shark. By lending money to someone who is desperate, needing food or requiring extremely sharp tools. When blunt they ‘would not cut the a way to pay rent, or similar, and then threatening them with violence if mustard’” [Guardian]. Maybe tech debt is like blunt tools? By leaving they don’t repay causes debt, and despair, to spiral out of control. Not a behind software that’s hard to use or difficult to understand or change good place to be. you’ve made life difficult. Even a skilled coder won’t be able to be very What’s this got to do with programming, you may ask? Almost nothing, effective if armed with a blunt scythe. in one sense. And yet, tech debt is a term that gets banded around, so Describing a dangerous or confusing system as debt seems odd. We perhaps it’s got everything to do with programming. Why do we describe decided to get some new lighting in our house and the electrician ran a confusing, hard to maintain code as debt? We haven’t borrowed money safety test first. We were half expecting a can of worms, or some kind of to cover it, so can’t be charged interest. We may have cut a corner or two, spaghetti wiring situation. Hooray for a way to test things before touching in order to get something out the door quickly, leaving a problem to deal anything live. I am pleased to report the house doesn’t need re-wiring and with later. I say later, but it often turns out to be sooner. With untested the electrician’s insulated snips worked but we need to have some ‘tech edge cases, things may blow up regularly. Without useful logging, you debt’ fixed before it is safe to get new lights installed. Without going into can’t figure out what happened. If the so-called quick win, cut corner, or too many details, let’s say words like ‘Why would anyone do this?’ and tech debt, means people have to down tools and fix things on a regular ‘That’s very confusing!’ and ‘Why would anyone connect the earth wire basis, you have in fact slowed everything down. Cutting corners is very to live?’ were banded about. Similar statements can end up as tech debt different to being in debt. Such short cuts are more like being in danger. Jiras, and the engineers being told the customer’s priority is new lights, so I recently described cutting corners as being like a Koch snowflake these debt tickets will have to wait until later. As a customer, I want it to [Wikipedia-1]. Now, to build this ‘snowflake’, you start with a triangle and be safe to change a light bulb, so please fix the dangerous stuff first. Just cut out the middle of each side replacing it with a smaller triangle, and saying. Letting engineers talk directly to customers is often the best way. continue ad infinitum. This, in some sense, is the opposite of cutting There are conventions for which coloured wire connects where for reasons: corners, since you add more corners each time, and tend towards to make the wiring safe for people to change, replace and extend in the something 8/5 times the original area. Cutting corners in code does often future without a huge wiring diagram and user manual. Describing cutting involve slapping extra bits in, copying and pasting code, wedging in a few corners and brazenly ignoring conventions as tech debt seems to miss the booleans and if/else code paths and the like. Such short cuts are more point somewhat. Conventions and protocols often exist to keep us safe. like spare parts gaffer-taped on. Now, cutting corners comes from the idea Now, not all coders regard themselves as engineers, and in fact some code of trespassing across a farmer’s field, or driving on the wrong side of the isn’t written for customers. Many of us have personal projects, and some road at a bend, rather than sticking to the legal route. You could suggest of us might be regarded as hobbyist programmers. I have frequently illegal practices aren’t necessarily wrong and there are some perfectly sketched out a few lines of code in a new language I’m learning, knowing legal cases where cutting corners makes life easier. If you smoke roll-ups, full well it’s an untidy mess, or just for trying things out, like rough notes. cigarette papers with the corners cut are much easier to roll – letting you I am a beginner so haven’t discovered or understood the conventions tuck the paper in more easily. Or more seasonally, wrapping presents is initially. Does that count as being tech debt? When I first started learning something of an art form. I recall my Father telling me once about some Python, I sketched out lines of code in the repl, and became frustrated at way to calculate the smallest amount of wrapping paper needed, and having to type them all over again when I revisited my noodling.