2021-01-14

Moore's law may have failed for individual CPUs, but progress is still astounding.

I bought a rasberry pi kit for a friend's kid the other day. He's sixteen and thinking of going into engineering but he doesn't have any mentors around the house.

Given that I don't know much about his home situation except that he has a game box (which implies a display) I got one of the kits that includes case, keyboard, mouse, pre-loaded SD card and all the cables. Given that I'm a bit of a cheapskate I looked back a couple of generation and got one based on a 3A+ instead of something more modern.

Frankly, however, I don't feel at all sorry for him becuase I'm flabbergasted by the raw power of this allegedly obsolete embedded board. It has four cores and each one is roughly as powerful as the machine I analyzed my dissertation data on. It has eight time as much RAM. It has only about sixty times the persistent storage becuase the cheap kit I chose comes with a "small" SD card. It has vastly better networking hardware.

There is only one metric where my old machine might have been better: back then I has spent a lot of my advisor's money on a 10,000 RPM fast-and-wide SCSI2 drive with a large and smart cache (for the era, natch),1 so I think I had better achieved bandwidth to persistent storage.


1 This was an informed choice, the software I going to run did a lot of logging and looking things up in disk-based databases as it processed large volumes of input into large volumes of output. It was generally IO bound on the big shared servers that were available at the lab. As a result of not being IO bound my PII desktop actually processed files faster than the big HPs. Even though I had given up about 10% of the available clockspeed to get that disk system and still squeak in under budget.

2021-01-12

Having it both ways

My better half and I decided we needed to buy a cardio machine. The only issue was what kind to get. We've both used treadmills, ellipticals, bikes, and rowers of various kinds in the past (and I've used climbers), but the selection of a single best kind of machine is no easy task. To make matter worse we have slightly different needs and goals. It comes down to my wanting a rower and her wanting a bike.

The good news is that hybrid machines exist. They have always been rare and in the past they've been pretty expensive, but when I started looking around I found that prices are way down. There are two models you can actually get for less than US\$800, when the last time I look for these things they mostly ran \$1500-2000.

On the other hand the market for bike/rower hybrids isn't a big one and these seem to have driven the higher priced options right out of the market. Unfortunately they are (to judge by specs and reviews) not as nice; adequate but in no way luxurious. I would have spent more to get a nicer machine if the option was open, but given what was actually shipping we got a Avari A150-335 Conversion II.

Assembly was not hugely difficult, but the instructions don't quite match the product actually delivered.1 I haven't had time to really put it through it's paces, but it does all thie things it says on the tin.

The belt drive is a little noisier and not quite as smooth as some higher-end rowers I've used in the past, but it's tolerable. The magnetic reistance means it is very quiet once you get all the bits in the right place. The range of resistance seems OK (though the fact that there are only eight settings is one of the things lost from earlier, more expensive options). The rail folds up fairly easily, though you need to make sure the seat is locked in place at least a little way from the console or it gets in the way.

The one oddball complaint I have at this point is the range of rowing motion in the front is somewhat limited: I have short legs and long arms and my reach on the recovery stroke is coming right to the cradle that holds the handle when you're not rowing. I don't think this is a show-stopper, but it came as a surprise.


1 This has been happening to me more and more frequently in the last few years. I get the feeling that the products are under continous development and accumulate a steady stream of small changes to reduce costs and or improve function, but the documentation doesn't always keep pace. Some manufacturers admit the changes up front with models name/numbers like Widget-Xtra-Special-5000/a15 where that last bit changes every few months. Others keep selling the "same" model so that you can only tell what you really have from the serial number. Sigh.

2021-01-06

Little things make a big difference

Of all the cool features I've read about that are in c++20, the one I find myself wishing for most often is the spaceship operator.

Sure concepts sound great, and improve the improvements to constexpr are going to make a big difference, but I write more class comparators than code that will be helped by those things. And it's almost all annoying boiler plate (which is why the spaceship opperator is a thing, after all).

2021-01-05

As if you needed another reason to hate the preprocessor

C++ inherited from c a compilation model that discards nearly all information about types and symbols. This is a mixed blessing. On one hand it simplifies a number of things and made c portable to a wide varienty of machines including some with minimal resources. On the other hand it means debuggers need added support to do their work and that reflection is not natively supported (in c) or requires special work (as in RTTI in c++). Unfortunately there are some very nice things you can do in the testing domain if you have reflection that are quite difficult without it.

This can be worked around in a number of ways, but most approaches make heavy use of the preprocessor: using function-like macros as well as the built in location macros (__FILE__, __LINE__ and their more modern counterparts). Indeed, your humble author once wrote a unit-testing framework for c and c++ in a combination of c-preprocessor and GNU make.1 More seriously Qt's native signals/slots mechanism and test framework make use of a variety of macros (Q_DECALRE_METATYPE, QCOMPARE, and so on).

Enter c++ templates. In particular templates taking more than one parameter. For example, say I'm using QTest and I want to perform a test of a computation that returns a three element stadard array of floats. I write something like QCOMPARE(actualArray, expectedArray);, compile (no problems) and run the tests which results in a hard crash in the bowels of qmetatype.h.

Oh yeah, I needed to declare the type to the metatype system.2

No problem. Scroll to the top of the file and add Q_DECLARE_METATYPE(std::array<float, 3>);, but that won't even compile (or if you're using Qt Creator the linter will catch it for you). Do you see why?

Q_DECALRE_METATTYPE is a macro. It's arguments are parsed as comma separated plain text. Which means the preproecssor reads that line as having two arguments where only one is expected. Crap.

To be sure you can work around this issue. My favorite approach is to use a type aliases like

using floatAry3 = std::array<float, 3>;
Q_DECLARE_METATYPE(floatAry3);

Keep in mind however, that this approach has its own trap: Qt's metatype system won't let you register the same type twice. The same underlying type, not the same name. Which means that you have to use a single name for each type to avoid inadvertent duplication, but you can't use the underlying typename for any multiple argument template types.

Anyway, the point is that you can't mix funciton-like macros with multi-argument templates without pain.


1 About all that can be said for it is I learned a lot and it worked well enough for me to use on some of my toy projects.

2 Not that you can tell from the crash or even from the stack trace in the debugger. All the behind the scenes magic that goes into QTest hides the origin of the error. I assume that most every QTest user has spent a frustring hour or so learning this the hard way.

The way I remember it...

Parent:
So it's to be torture?
The Albino:
[nods enthusiastically]
Parent:
I can cope with torture.
The Albino:
[shakes head enthusiastically]
Parent:
Don't believe me?
The Albino:
You survived grad school, so you must be very brave, but no one withstands The Toddler.

And later

Count Rugen:
As you know, the concept of the suction pump is centuries old. Really that's all The Toddler is except that instead of sucking water, she's sucking serenity, sanity and coolness.

2021-01-02

Honestly, I hadn't considered that

When considering becoming a first time-parent in ones forties it is a good idea to list as many of the ways that your life will change as possible and consider how you might feel about it.

I did my best when it was my turn, though I did not really appreciate the way need for extra time to accomplish anything would follow a rule of maximum inconvenience; for instance, she climbs happily into the car when we have time and uses a effectively infinite arsenal of delaying tactics when we're late. Arrgh!

But I didn't consider that this decision meant there would be someone to insists on celebrating my birthdays rather than letting them pass quietly by with only a slight grump to mark the occassion. Sigh.