Sunday, July 12, 2026

Why People Dislike the Caps Lock Key (Explained Simply)

Imagine a key on your keyboard that:

  • You almost never intentionally use,
  • But if you touch it accidentally,
  • Your typing suddenly LOOKS LIKE THIS,
  • And you don’t immediately realise it,
  • Then you must stop, fix what you typed, turn it back off, and resume your task.

That’s Caps Lock.

Here’s why people end up hating it:

1. It Causes Mistakes More Than It Helps

Most users don’t write entire sentences in capitals.

They barely use Caps Lock for its original purpose (typing paragraphs in uppercase). Yet:

  • The key sits in an extremely easy‑to‑hit position,
  • Touch it accidentally → everything becomes CAPITALS,
  • Meaning you must stop your workflow and correct text.

It’s like having a “spill coffee on your keyboard” button placed right next to Shift.

2. It Duplicates a Function You Already Have

Anything Caps Lock can do, Shift can do better:

  • Want one capital letter? → Hold Shift.
  • Want several? → Hold Shift for as long as needed.

Since typing all-caps text is rare, a “toggle” mode for capitals became unnecessary. For many people, Caps Lock is an entire key dedicated to something they never do.

3. It Interrupts Flow and Costs Time

For fast typists, programmers, or anyone working in text-heavy tools:

  • You’re typing quickly
  • Your finger brushes Caps Lock
  • SuddenlyTheTextLooksWrong
  • You pause, sigh, backspace, fix it, turn caps off, resume…

These micro‑interruptions are small but frequent enough to be maddening. Over an entire day? You’re losing minutes. Over years? Hours.

4. It Doesn’t Provide Immediate, Obvious Feedback

Some keyboards have no Caps Lock indicator light or it’s somewhere out of your natural field of view.

Result:

  • You don’t notice the mode changed
  • You type for several seconds before realising
  • More text to fix

This is the same reason people hate “Insert” mode — the toggle behaviour is easy to enter, hard to notice, and has big consequences.

5. It’s a Legacy Key From an Era That No Longer Matters

Caps Lock comes from typewriter days where:

  • SHIFT literally lifted metal type bars
  • Holding it down was physically tiring
  • So a lock was required

Modern keyboards don’t need this. We inherited a physical key designed for 19th‑century hardware, even though today it just gets in the way.

6. It Occupies Premium Keyboard Real Estate

Caps Lock sits in the left‑hand home row cluster, directly under A, where your pinky often rests or moves. Many people would rather put something useful there:

  • Ctrl
  • Escape
  • Backspace
  • Another Shift
  • A macro
  • A language switcher
  • A compose key
  • Or simply nothing

Because ergonomically, it’s one of the easiest keys to strike — which is exactly why it causes accidental activation.


🟩 Simple Summary (the “explain it to an uninformed person” version)

People dislike the Caps Lock key because:

  • It’s easy to hit by accident
  • It messes up your text when activated unintentionally
  • Most people never intentionally use it
  • It duplicates functionality that Shift already handles
  • It interrupts typing and breaks flow
  • It exists mainly due to historical design, not modern needs

That’s it. No conspiracy, no deep philosophical reason — it’s just a key whose problems outweigh its benefits for most modern computer users.

Saturday, January 10, 2026

My philosophy on human well-being

This is a change from my normal technical ramblings, but I've put in here instead of starting a separate blog.

A Philosophy of Universal Potential and Cultural Progress

The Core Principles

  • Universal Human Potential: I believe that all people, regardless of where they are born or what their background is, have the same capacity for reason and progress. There is no inherent hierarchy between different groups of people; human potential is a universal constant.
  • Judging Ideas, Not People: I make a clear distinction between an individual and the ideas they happen to hold. Ideas—whether they are social, political, or religious—are like tools. Some tools work better than others to solve the challenges of living together. To question or criticise an idea is not an attack on the person; it is an essential part of finding better ways to live.
  • The Timeline of Progress: History shows that human societies do not all move at the same pace. Some societies are currently governed by rules and laws that others moved away from long ago—such as the merging of religion and law, or the restriction of basic freedoms for certain groups. I see this as a matter of where a society sits on the timeline of development, rather than a permanent feature of the people themselves.
  • Objective Standards for Well-being: I believe it is possible to measure how well a set of ideas is working by looking at the results. A society that values the freedom to speak, the use of evidence, and equal rights for everyone produces a better quality of life than a society based on rigid dogma or the absolute power of a few. These are not just "local" preferences; they are principles that improve life for everyone, everywhere.

Why These Views are Mislabelled as Racist

In modern conversation, these observations are often met with accusations of racism. I believe this happens because of a few common misunderstandings:
  • Mistaking Culture for Ancestry: Many people today treat a person's cultural or religious background as if it were an unchangeable part of their physical identity. Because of this, they see a critique of a specific practice as an attack on an ethnic group. I believe humans are capable of outgrowing old ideas, and no one should be defined solely by the traditions of their ancestors.
  • The Belief That All Practices are Equally Valid: There is a common view that it is wrong to suggest one way of organising society is better than another. By arguing that certain values—like individual liberty and secular law—produce better results for human beings, I am challenging the idea that all customs are beyond criticism. To those who believe we must never judge another society's rules, any attempt to do so looks like a form of prejudice.
  • Focusing on Power Instead of Principles: Some critics focus entirely on who has more power in the world. They feel that if a group has been treated unfairly in the past, we should stay silent about the flaws in their current laws or beliefs. I believe this approach is a mistake because it leaves the most vulnerable people within those groups without a voice. We should want the same high standards of freedom and safety for everyone, no matter their history.
  • Optimism Misunderstood as Hostility: My view is rooted in the belief that because the problems we see in the world are caused by flawed ideas rather than flawed people, they can be fixed. By identifying where ideas are failing, we open the door for change. Accusations of racism often stem from a viewpoint that doesn't believe people are capable of moving beyond the limitations of their current environment.

Saturday, April 19, 2025

Restoring linux mint 22.1 after major disaster, what to reinstall and setup

After a disaster trying to set up citrix on linux mint 22.1, I reinstalled. I use my mint machine for various aspects of C++ development so need a wide range of tools. Below are the steps I took that got things back in working order. It is a shame that no distro I know of is actually geared for C++ program development.

- The install was unattended unlike in the past when I have had to tell it to use the network, ntp, etc, this was odd. Also, I note that mint 22.1 uses a repo called noble, not jammy. - Welcome screen, driver manager install nvidea driver 470. Tried install but it took ages. The progress bar moved and eventually got there. Had to reboot. - On reboot had to call up welcome screen again, because I unticked that show at startup box, then launched update manager. Declined option to switch to local mirror because in the past I could not get that to work, so just clicked on apply update, then install updates. Eventually it finished and did not demand a reboot, so went on to system settings.

- System settings go to power manager display and change every setting to never. - Software manager, spends a while generating cache..... Then shows a list of featured apps, we want some of them , so picked inkscape, because alfresco needs it, virtualbox, calibre, gimp, then went for categories.

- Accessories: htop, unrar

- Games: wine, mame, quadrapassel, seemd to hang on this, so rebooted

- Graphics: handbrake, shutter, VLC, dia, Gthumb, shotwell, xsane, evince, handbrake-CLI, ksnip

- Internet: openSSHserver, this install also hung, so will revert to using the command line. Rebooted.

- Apt install: Wireshark, deluge, chromium, samba, transmission, gftp, nginX, tor

- Office: vim, libreOffice, emacs, sigil

- Programming: meld, nasm, cmake, clang, git-Gui, gfortran, flex, bison, valgrind, maven, yasm, automake, kcachegrind, rustC, ddd, doxygen, flatpak-builder, intlTool, protobuf-compiler, pylint, python-is-python3

- Science and education: gnuPlot, gnuPlot-x11

- Sound and video: lame, k3b, audacity, mpV, mplayer, menCoder, flaC, id3

- System tools: tmuX, ncDU, ansible, gPart

- Misc: nmap

I eventually found out what entries to add to /etc/fstab to get my NAS mounts back. I have now backed up that file to my secondary drive.

- apt install postgres, postgres-client, unixodbc-dev, odbc-postgresql, meson, lcov, nlohmann-json3-dev, libreadline-dev/

Discovered that the postgres GUI, pgadmin4, is not supported on Mint 22.1 yet so installed dBeaver. Found out that by default dbeaver turns off visibility of all databases other than 'postgres'. Found the tickbox under settings to fix that.

And now, at long last, it looks like I am back in business.

Additional installs (26-Apr-2025)

iotop, gparted, clang-format, matplotlib (via pip)

Don't try to set up citrix on linux mint 22.1

I have spent all of Good Friday and most of Easter Saturday recovering from the disasterous step I took, trying to get citrix to work on my recently installed linux mint 22.1. My advice for those on that distro is "don't go there!". Citrix depends on an ancient Gtk library but the debian install file does not contain it. At version 22.1 it is no longer supported. The citrix version I downloaded was dated March 2025. So it is quite annoying that citrix have still not dealt with this issue. There is a web of dependencies that took ages to chase down, only for me to end up in a right old tangle where eventually I was forced to reinstall linux mint. I even tried a project I found on github where someone tried to solve the problem via a flatpak but that didn't work out either. Citrix need to get their act together. Luckily, I have an old laptop with an older version of linux mint which is just about serviceable, even though it creaks and groans a bit. It does run citrix ok so I will have to stick with that.

Sunday, February 18, 2024

Jenkins, git and ssh in a corporate environment

I reinstalled a later version of jenkins in order to dodge a CVE and found that git clone would no longer work. The terminal that started jenkins was getting messages prompting for the git ssh passphrase. The jenkins job just sat there on the git clone command without making any progress. I puzzled over this for ages. The previous version of jenkins had been working fine. I restarted the ssh agent but it had no effect. I googled to find out how to change my ssh credentials such that I had no passphrase (ill-advised though that may sound) and found articles claiming it was impossible. Well, it turns out it is possible. I did it and the jenkins problems went away. I don't like having an empty passphrase, it seems like bad practise, but hey, ho, needs must. So here's how I reset the passphrase to be empty: the ssh-keygen -p command prompts for the current passphrase. Enter it, then when ity asks for the new one (and confirmation) just hit return. Job done.

Friday, June 23, 2023

How to display markdown files from the linux command line

It took quite while to track down how to do this. When you google for it you find GUI commands but not much for the command line. There are several tools but I have chosen one that works with what is available via the standard Red Hat repo for RHEL8. I use it even though my own machine is running mint 20.1. Going for something that is easy to install on RHEL8 means there is more of a chance that it will work in a corporate environment. The command is called mdo and it is written in python. It can be pip'd into your virtual python environment. It requires prior installation of another component called rich, which can also be pip'd in. This is the great attraction of utilities written in python. They can be pip'd into your virtual environment and thus do not require root access to make them available. These components are on github at https://github.com/eyalev/mdo and https://github.com/Textualize/rich .

Monday, August 29, 2022

Many forks on github projects

When a project is not updated very often or goes by for years with no official updates, forks can proliferate. Then people who arrive at the site may want to know which forks are active. Luckily, there is a github project for solving this problem! It is called ActiveForks. If you go to https://techgaun.github.io/active-forks/index.html you can enter the name of the github project and you will get a table of results, with the ability to sort on any of the presented columns.

Monday, August 01, 2022

Windows and directories that cannot be (easily) deleted

If a directory contains nodes whose full pathname is greater than around 255 characters then Windows has tremendous difficulty deleting such a directory. But luckily, there is an easy way out. The 7-Zip command comes with an additional executable, 7zFM.exe which is the 7-ZIP File Manager. I recommend you put an icon for this on your desktop. It works a bit like a file explorer with one significant difference. If you click on a directory and enter shift-delete then it will delete that directory even if other commands fail due to the 255 problem.

Sunday, March 27, 2022

Function parameters that are fundamental types passed by value and const

The rule is to not do this in the header file. Some people say don't do it in the cpp file either (I am in that camp) but this does seem to be a matter of opinion. See the abseil article https://abseil.io/tips/109 for a discussion.

[[Addition: April 2025]]

I went to ACCU 2025 where there were talks on contract assertions, a feature that has a bearing on this area. As of April 2025 contract assertions do not distinguish between function parameter values on entry and any modified value on exit. So there is no way make clear if a post condition variable refers to its value before or after. In other languages such as Eiffel, which have DbC built into the language, there are ways. Apparantly, this will be dealt with in C++, maybe by C++26. But in the meantime when one passes a fundamental type by value and does not use const in the cpp file, the value can be altered during function execution, since C++ is a pass by copy language. With such modifications it is possible for a post condition to inadvertently test a modified value. The standards committee are aware of this issue and suggest a remedy that I don't like at all. They say one should decorate such parameters with const. Since preconditions and postconditions are expressed on the function signature this means putting the const there. For symmetry I suppose they would also say that they must also be in the cpp file. I really don't like this, so my position of function parameters that are fundamental types passed by value stands. I will just have to wait for c++26.

Windows, X11, cygwin, fonts and Xming

For years I used the X11 server that is part of cygwin. It seemed to be a bit flakey but there didn't seem to be anything better. Every now and then I would run into a problem where it would seem to work but xterm would complain about missing fonts. So, I downloaded and installed xming-fonts (from https://sourceforge.net/projects/xming/files/Xming-fonts/7.7.0.10/Xming-fonts-7-7-0-10-setup.exe/download) on my local node (not the node that was running xterm) and that fixed the error. These days I no longer use the cygwin X11. I use XMing: see http://www.straightrunning.com/XmingNotes.

Monday, May 31, 2021

Software Development links and comments

Intro

I am in the process of decommissioning my website and moving my notes on software development and suchlike to my blog here.

ACCU

I am an active member of ACCU (the Association of C and C++ Users). It's been a long time since I had anything published by them. There are a couple of articles a few book reviews.

C++ Coding Guidelines

Many years ago I started to write a book on this. It was never published. I did discuss an early draft with Addison Wesley but they did not show any interest. I discussed this with some ACCU people and the theory put forward was that maybe they had been approached by other authors on the same subject. About a year later Sutter and Alexandrescu had their guidelines published. Their book is very good and I recommend it. Their book is much better than what I was working on.

In a corporate environment I would never bother with a coding guidelines document these days. They are never read, never enforced, and can become out of date very quickly. They are also a rich source of arguments and ill-feeling. There has to be a better way. There is. It is called clang. I would have a jenkins job to use clang-format to format the code. That would take care of all whitespace and brace arguments. And I would use clang-tidy static code analysis (SCA) to find the more serious coding issues. There would be a jenkins job to ensure that the code was always SCA-clean. clang-tidy is not the easiest program to run since it needs to know what compiler options are used and that includes macros and the places where to look for include files. I have found that it helps to write a python script to take care of these things. It is worth the effort.

Sourceforge

Here are my own projects, hosted on SourceForge. They are old and have fallen into disuse really. If I was going to maintain them I would probably start by relocating them to github.
  • LAUM - Development has stalled. I hoped it would eventually it will be a suite of applications to help in the administration of groups of machines. The whole thing has been made a bit obsolete by docker and kubernetes.
  • FRUCTOSE - wrote an LGPL'd C++ unit test framework. The main motivation was a simple, header-only framework that does not depend on boost. However, these days I recommend that people go with the Google unit test framework (gtest).
  • Cyclic Logs - wrote a GPL'd package to provide cyclic logfiles. I think this does still have a practical use in environments where the disk space is constrained.
  • DepDot - wrote a GPL'd command (perl script) to show cyclic dependencies among libraries.

TeX

I am a keen user of TeX, via the LaTeX variant created by Leslie Lamport. I have been a member of the UK branch of the Tex Users Group for several years. I tend to produce most of my documentation using LaTeX. This allows me to produce PDF and postscript files (via DVI conversion programs) and RTF files (via latex2rtf). The RTF format is an open format but due to its close integration with Microsoft Word for Windows it is useful for people that require documents to be in a Microsoft format. I used to use latex2html to create web pages from my LaTex documents, but have now found that HeVeA does a better job and is much faster. It is written in oCamL. For many years I experimented with alternatives to using LaTeX directly, flirting briefly with DocBook, and other approaches. I now conclude that there is just no substitute for writing in LaTeX directly.

CORBA

I feel great nostalgia when I think of CORBA. I liked it for a very long time. I was interested in CORBA right from the beginning (i.e. when the standard was so embryonic, CORBA would not even interoperate with itself!). Despite the complexity of the standard, I still think CORBA had a lot to offer. I have used several ORBs, some open source, some proprietary. My favourite used to be MICO but unfortunately the support for multithreading is still not finished and development petered out around 2017, so TAO (the ACE ORB) is now the winner. I have also looked at JacORB by Gerald Brose. The best proprietary ORB (IMO) was Orbix from IONA (now owned by Progress).

For those interested in CORBA I recommend heading over to the web site of Ciaran McHale (, a former IONA consultant whom I have worked with before. He has a free book there which I think provides a great practical introduction to programming with CORBA.

However, despite the nostalgia I have to admit that CORBA has had its day. The Rise and Fall are well documented by Michi Henning, see https://cacm.acm.org/magazines/2008/8/5336-the-rise-and-fall-of-corba/fulltext. Unfortunately there does not seem to be anything trying to replace it, except possibly ICE from ZeroC. It is Open Source, which is obviously a good thing, but be advised that the the license is GPL and so does not permit use in proprietary products (a separate license agreement is available with a purchase cost). If I was ever asked to work on a project where there was a need for some kind of service interface I would probably make it a web interface. That's the current fashion at the time of writing (2021) and there are umpteen frameworks. I would probably choose gRPC with Web Assembly. I would never use SOAP and I would be wary of REST.

Free Software and Open Source

Projects that I have contributed to include:
  • DoxyPress
  • PoCo
  • ACE
  • OpenSSL
  • I did some work on ESNACC, an extended version of SNACC, an old ASN.1 compiler. ESNACC started because SNACC was an old orphaned project with no support for either C++ or DER and PER (SNACC was old BER only). Sadly, work on ESNACC gradually fizzled out.

I have been an associate member of the Free Software Foundation for many years.

I admit that I am not consistent when it comes to the ideals of the Free Software Foundation. I agree with the FSF in the same way that I agree with vegans. I know that unless one is a vegan one is supporting the animal food industry, which is full of cruelty and suffering. But I just can't go vegetarian, let alone vegan. I won't go into the reasons here. I know that I am supporting animal cruelty and I am not happy about it, but it is not going to change any time soon. In a similar way, despite the good things I find in the FSF, I am, unfortunately, supporting the proprietary software industry. My job involves the development of proprietary software and this has been the case my entire working life. That is not going to change (i.e. I am not going to have a change of career). I find the best I can do is to promote open source in the workplace. I know this is a rather feeble thing. After all, we know that Free Software and Open Source are different movements with different goals. But in my opinion the software industry as a whole will never understand the importance of Free Software. They are beginning to understand Open Source and that's better than nothing.

ASN.1

I really like ASN.1. I was first introduced to it way back in 1984 when the encoding standard was called .X409. It was used on Prime Computers for some of its client/server software and proved to be a boon when the protocol had to change, due to the use of sets and version numbers. Sadly, I have not seen it used much since, except of course in a few standard internet protocols.

I found out there is effectively a replacement for ESNACC, asn1c, which seems to be significantly better than either SNACC or ESNACC. I haven't played with it yet. I wonder if I ever will.

There is a useful book on ASN.1 that you might find interesting.

Heroes of software

There are so many potential heroes for a computer geek to look up to, but my favourite is Alan Turing. He is regarded by many as the father of computer science. He is particularly admired by many of us in the UK for his work at Bletchley Park. Turing's work there was part of the outstanding effort in decrypting German messages during the Second World War.

Thursday, October 22, 2020

Java has finally got strong crypto

For a long time now America has treated strong crypto as akin to munitions; a deadly weapon that must not be allowed to fall into the wrong hands. For the background to this, see the wikipedia page at https://en.wikipedia.org/wiki/Export_of_cryptography_from_the_United_States

The wikipedia page indicates that this attitude was significantly lessened in 1992 but the sad fact is that is persisted well beyond that for java. The Oracle release notes for JDK8 at https://www.oracle.com/java/technologies/javase/8all-relnotes.html say that the restricton was removed in January 2018, in update 161. The change was also backported to JDK7 in update 171.

This means that java projects using JDK8 had better move to at least this update version if they have not already. Of course, users of OpenJDK probably never had a problem and certainly don't now.

The way I ran into this problem was during work on a trade feed that uses the FIX protocol. The FIX session was secured with TLS1.2. everything was fine until one day the remote side changed from a weak crypto algorithm to a strong one. Our side failed with a mysterious SSL handshake error. This came from the mina package, as used by quickfixj. Mina which doesn't seem to handle this situation well at all. We had to turn on packet level logging via the JVM option -Djavax.net.debug=all to see what was happening. The log showed that the remote side wanted to use a strong algorithm but that many algorithms on our side were disabled. At the time the latest JDK8 update from Oracle was update 251. I switched to that and then all those messages about unknown algorithms disappeared and the algorithm preferred by the remote side was accepted. Everything started working again.

Saturday, September 05, 2020

Windows password change through different levels of RDP

There is conflicting and incomplete information on how to change your Windows password where RDP is involved. It turns out that the thing to do changes depending on how many levels of RDP are involved. Here's what I found:
  • No levels of RDP. This is the simple case. Just Ctrl-Alt-Del then click on change password.
  • One level of RDP. Just Ctrl-Alt-END (that's END, not Del) then click on change password.
  • Two levels of RDP. You need to send Ctrl-Alt-Del to the machine at the end of the RDP chain but typing that will do it on the top level machine. Ctrl-Alt-END will do it to the machine at the second level of RDP. So you have to use the OSK command on the target machine to get an On Screen Keyboard. Then type Ctrl-Alt and click on the Del button on the OSK display.
If you google to find out how to solve this problem the most common reply is Ctrl-Alt-END. Here people are assuming there is only one level of RDP. It is very annoying that what you have to do depends on how many levels of RDP there are.

Monday, August 31, 2020

Case-insensitive ext4: just say no!

I am dismayed to learn that ext4 was changed in linux kernel 5.2 to be case insensitive (strictly speaking, to allow it as an option). This is truly terrible and will come back to bite us all. See this kernel.org posting for details. But here are just a few thoughts: Is it really going to be case insensitive? I doubt it. There are some environments in which there is a requirement for filenames to contain both uppercase and lowercase characters. Java springs to mind where the filename maps directly to the class name. Of course one could start to code entirely in lowercase but what about those classes that have already been written? What happens when the source is moved to an ext4 partition that has this feature? I strongly suspect that when they say case-insensitive what they actually mean is case-preserving, like MS-Windows. The fact that this has not been called out shows that the functionality has not been considered very deeply. People have two confused two unrelated issues: the issue of filenames supporting case and the issue of applications making the case of filenames irrelevant or not. If the filesystem is case-preserving then applications will still need to cope with this by being case-blind where they think this is what the user wants. Putting this into the file system itself is completely wrong. IMAO. There are several changes being made to linux which I don't like and this is another in a growing list:
  • systemd. I notice now that more and more linux software that is available through a distro's package management system is dependent (transitively) on systemd. I anticipate a day where practically every package has this dependency.
  • The Out Of Memory (OOM) Killer. I've already blogged about this.
  • btfs not supporting datetime last accessed.

Saturday, October 26, 2019

Building open source C++ libraries on Windows for 32 bit and 64 bit

In my experience, most open source C/C++ library projects don't do a good job of providing the ability to build the library in all four builds, i.e. all combinations of release mode and debug mode with 32 bits and 64 bits. These days it is usually just 64 bit and sometimes it's just 64 bit release. To get all four build modes one has to start hacking but there is a little gotcha that nobbles me every now and then, so I thought I would blog about the solution so I never have to strain my brain to remember it in future. I can just go to my blog.

Add a new configuration from the configuration manager. Pick Win32 from the pick list and say you want to inherit from the 64 bit configuration (that's so you get all that the 64 bit configuration has). This configuration will claim to be 32 bit but there will be a problem. The linker will be set for 32 bit but the compilation will be in 64 bit. This is not apparent from the settings dialog. So when you build you will see an error like:

fatal error LNK1112: module machine type 'x64' conflicts with target machine type 'X86'

To fix this, edit the Visual Studio project file, removing this line from the 32 bit sections:

<AdditionalOptions>%<AdditionalOptions> /machine:x64</AdditionalOptions>

That's it!


Saturday, March 16, 2019

I have converted at long last to 1TBS

After decades of firm adherence to the Allman brace style I have finally changed my mind. I am now in the 1TBS camp.
Here is my reasoning, it is all a matter of my own personal opinion of course. The stuff below is not trying to make a logical reasoned argument for 1TBS in general, just why I changed my mind.

IMO Allman is useful to show where code blocks begin and end in legacy code where functions ramble on and on as they grow uncontrolled and undisciplined over the years. Such source often contains a random mixture of tabs and spaces.
It is quite hard to see where the scope blocks are under these conditions. Reformatting Allman style makes such code clearer than it would otherwise be. Using an Allman style on new code allows it to grow in an uncontrolled way where blocks just get bigger and bigger, rather than being refactored. When this happens the use of Allman means the blocks that would otherwise start to become much harder to see stay reasonably visible.

So that's why I used to think Allman was good. It allowed blocks to be more easily seen in ancient crufty code and it allowed new code to become crufty while still preserving some ability to see the blocks. But I have now decided that this is not a good reason to prefer the Allman style.

We all know that advocates of 1TB say it makes the code shorter, and it does. And shorter code has become much more fashionable over recent decades. The shorter the code the smaller the blocks and once a block becomes only a few lines the Allman style makes such blocks unnecessarily longer. I see this in Java code where 1TBS is the dominant layout style and shorter functions are practised much more than in C++. Maybe it's because alot of C++ code is ancient and in the dim and distance past it was more normal to write long, rambling unfactored functions. Java hasn't been around long enough for such cruft to accumulate to the same degree. Plus it came along later during which time shorter functions became more fashionable. When was the last time you saw a Java function that rambled on for hundreds or even thousands of lines. I wouldn't be surprised if you've never seen one. But we've all seen it in C and C++.

So, if I ever get the luxury of working on a new C++ project and I get any say in things like layout style, I would advocate 1TBS. The project would have short functions and the minute a function looks like growing to the point where the blocks start to become less visible it would have to be refactored. This is not just a matter of making it look pretty. The argument for refactoring would be that the result would be easier to test and it would be easier to reason about code coverage, as well as being easier to understand. This is already standard practise in Java, thank goodness.
It ought to be standard practise in any programming language.

During my conversion to 1TBS I have been working with python. This is a language where the issue has been designed away. How jolly sensible. Why don't all new languages learn from this? Python seems to be the only one. Every time some new language comes out it is inevitably based in C++ regarding layout. Java copied this and so has almost every other language since.

There is another factor which led to my 1TBS conversion: I have been working on a project where Allman is the standard, but with a twist. Single statements must not be surrounded with braces. We all know how potentially dangerous that is. It can lead to the dangling else problem, and has done on that very project, a fact revealed by a clang-tidy analysis.
It can also cause a problem when a developer changes the code to make the block more than one statement. These issues just don't arise when one uses 1TBS.

So, how is this change in belief going to affect my programming life? Hardly at all, unless I write stuff on my own (e.g. updating my sourceforge projects or creating new ones). After all, I am in an environment in which
1TBS is forbidden and its use would probably harm the code base as it would make the blocks in long rambling functions even harder to understand than they already are. I can't even use 1TBS in the java code, since Allman is mandated there as well.

Sunday, January 06, 2019

A great C++ blog I've found

I've found a great C++ blog and I thought I just had to mention here it. There are lots of goodies about C++17 and C++20 and it keeps track of well known players in the industry and what they are up to, e.g. people like Barnje Stroustrup, Herb Sutter, Nicolai Josuttis and John Lakos. The blog mentions high profile features and plans for C++ including things like the inclusion of Howard Hinnant's date library into the standard and the adoption of contracts. I encourage everyone to take a look.

Saturday, December 29, 2018

The insane OOM (out of memory) Killer

In the late nineties I worked on AIX for the first time. Back in those days there were several flavours of Unix available, all with their differences and idiosyncrasies. Linux was a fledging and fitted on just one CD. I came across a feature of AIX which I thought was crazy - the OOM (out of memory) killer. In this variant of Unix malloc always succeeded, even when there wasn't enough memory. The idea was that malloc returned a pointer to heap memory but wouldn't actually start to use it until the first reference was made. At the point at which it did then memory had jolly well better be available. If it was then all well and good. If not then the OOM killer came into play. The OOM killer would choose a victim process and kill it. The result was that memory would be freed and the access occurring at the time would succeed. Sounds insane, right? Right. I laughed and thought that this one feature rendered AIX useless compared to the other Unixes and would lead to its demise. How wrong I was. Fast forward a few years later. It was added to Solaris. Sigh. Fast forward to today. It has been added to Linux.

The OOM killer is a kernel development that mirrors what happens when banks try to innovate. It's what I call "the conspiracy of crappiness". It goes like this: some group or other tries to innovate but comes up with a really bad idea that doesn't work well and everyone hates it. The competition discover the move and for some inexplicable reason they copy it. Now everyone hates the competition as well and none of the players can be distinguished in this area. Bank charges on current accounts is an example. So is charging for withdrawals at ATMs (although customers have objected so vehemently to that one that there has been some back peddling). Well, in the world of Unix we now have the OOM killer.

There's a good article at LWN, that explains why this is insane. There's another article that gives tips on how to mitigate the nastiness, but surely that it yet another testimony to the fact that it is nasty. I also came across this article that discusses the nastiness and has an excerpt of .an amusing article that discusses the fairness, or otherwise, of how the victim is chosen. Here is the excerpt:


An aircraft company discovered that it was cheaper to fly its planes with less fuel on board. The planes would be lighter and use less fuel and money was saved. On rare occasions however the amount of fuel was insufficient, and the plane would crash. This problem was solved by the engineers of the company by the development of a special OOF (out-of-fuel) mechanism. In emergency cases a passenger was selected and thrown out of the plane. (When necessary, the procedure was repeated.) A large body of theory was developed and many publications were devoted to the problem of properly selecting the victim to be ejected. Should the victim be chosen at random? Or should one choose the heaviest person? Or the oldest? Should passengers pay in order not to be ejected, so that the victim would be the poorest on board? And if for example the heaviest person was chosen, should there be a special exception in case that was the pilot? Should first class passengers be exempted? Now that the OOF mechanism existed, it would be activated every now and then, and eject passengers even when there was no fuel shortage. The engineers are still studying precisely how this malfunction is caused.

Update: 27 March 2022

Since that aircraft analogy I have found an article on the perils of overcommit which gives a more dispassionate assessment, but still concludes it is a terrible idea: https://www.etalabs.net/overcommit.html

Sunday, December 02, 2018

I can't stand the JBoss Application Server

I wonder which application server people chose when working on Java projects that need to publish dynamic web pages. I have used tomcat in the past and found it to be pretty good. But for the last few years I have been in an environment where JBoss was chosen. JBoss comes with all sorts of enterprisey EE things such as a JMS implementation and whilst initially this may seem attractive I have decided that I don't like it. I would now recommend that any project that needs JMS and dynamic web pages avoids an enterprise application offer. Instead I think it is better to chose the web page and JMS solutions separately.

Years ago I wrote a book review for ACCU on a JBoss tutorial book. I gave the book a bad review because it was largely XML fragments concerning JBoss configuration. But I now see that this is what struggling in a JBoss environment is all about. I still think the book was wrong to have such large XML sections though. The precise XML needed to make JBoss do what you want seems to wibble depending on the exact version of Jboss you have and also possibly on what colour socks you are wearing. But it gets worse. Recently (wrt the time of writing this, December 2018) JBoss went proprietary. Red Hat now calls it JBoss Enterprise Application Platform or JBoss-EAP for short. Not to be confused with the old open source version which was just called JBoss. In an attempt to deal with the confusion Red Hat renamed the old one to Wildfly and open source development is now done under that name. Wildfly does seem to be much better than JBoss but it's all relative; it is still derived from JBoss and so still suffers from the tremendous environmental difficulties caused by obscure and constantly changing XML configuration.


So, for people who want JMS and web pages with dynamic content, I recommend ActiveMQ and Apache Tomcat respectively.

Saturday, November 25, 2017

Veracrypt instead of Truecrypt

Back in June 2014 Truecrypt died, but I and many others were able to build it from the source. I blogged about this before. Recently I had to access a couple of truecrypted volumes but found that my copy of truecrypt no longer worked. It relied on an old version of GTK that was no longer on my system. After some fruitless attempts to restore the required version of GTK2 I decided to try out VeraCrypt, which is the successor to Truecrypt.

Veracrypt is everything that Truecrypt was, and more. Fully open source, multi-platform strong encryption with optional plausible deniability and compatibility with Truecrypt. After installing yasm and libfuse I was able to build Veracrypt from source with no trouble at all. And it works. It was able to read my old truecrypt volumes. It also works on my Windows laptop. Wonderful! I have now switched over to Veracrypt.