I’m Still Here

Not much has been happening with me lately.

I had MRI and CT scans on Tuesday and both turned out OK, so on Wednesday I signed up for the study of whether prophylactic radiation is actually effective in keeping small cell cancer out of the brain.  The study is randomized but not blind, and I’ll find out on the 3rd or 4th whether I’ll be getting the radiation.

I’ve been a bit lackadaisical about finishing my C++ rational number library.  I think it’s ready to go, but I still have a bit more testing to do.  If anybody would like to suggest a change in the design, please do.

A Database Access Library

I’ve been yakking about how I’m working on a database access library, so maybe I should show you my current design to prove it. ๐Ÿ˜Ž  This should be the last of the dorky programming posts for a while.

The C++ standard library has nothing like the java.sql.stuff.  There are some third-party libraries out there, but they seem kind of klunky to me, and I suspect that they don’t scale up to real world use cases.  This makes C++ a really bad choice for use in the good old “business data processing” domain.*

I wanted a design that more closely matches common C++ idioms (container/iterator for example) so that coders wouldn’t have to learn a whole new way of thinking.  It’s by no means an exact match (cursors are not really iterators, for example); but I think it’s the same general idea.

I’m not ready to share any code yet.  Indeed, some of it might embarrass me. ๐Ÿ˜Ž  For a variety of reasons, it’s been a couple of years since I’ve worked on it; and I need to review some ODBC ugliness that I’ve forgotten to finish the SQL/CLI implementation.  I haven’t even started on the Web client business which needs to be part of the proof of concept since I claim that I can make it work.

If there’s anybody out there who thinks this is basically a good design and would like to run with it themselves, I’ll happily share what I’ve got so far (probably about 1500 lines of code, not really a big deal yet).  I’m currently stuck on conversions between C++ and SQL types, which is central to making cursors work and depends on some ODBC stuff that I can’t remember.

My goal of getting WG21 to publish this in a TS will probably never be realized, but I think it’s worth doing anyway.  I’ll implement the rational number that I mentioned in the previous post first just to have some fun and get back in the groove; then I’ll see whether I can restart the work on the database library.**


*Business data processing will probably never be more than a niche market for C++, but that’s where the bulk of my experience is and so it’s what I know most about.

**My local PBS affiliate is starting up its quarterly pledge fortnight, so I shouldn’t have much TV to watch for a couple of weeks. ๐Ÿ˜Ž

Rational Math

Back when I was a C++ newbie, I decided to write a rational number class because I thought it would be a good exercise.  I revised it and added features over the years as I learned new stuff (I/O manipulators, for example).  I looked around my computer for it this morning and found a version that I wrote over a decade ago when I still didn’t have even a C++11 compiler to work with.

About 11 or 12 years ago, WG21’s numerics study group was thinking about publishing a Technical Specification (TS, a kind of warning about possible future standardization) that would propose some new number types (fixed-point types, an unbounded integer, things like that).  I confidently raised my hand and said that I had a rational number that I could add and proposed what would eventually morph into this*.  That “Numbers TS” is no longer in the works, so my rational number died.

I think I’ll revisit that to bring it at least to the C++20 level and implement it using the bigint class that I mentioned in the last post to avoid overflow.  I also want to put the I/O manipulators back just because I think they’re Really Cool. ๐Ÿ˜Ž

That should keep my brain working for a little while longer.


*Starting with the “[rational.math] Rational math” section, that’s what much of the C++ standard reads like.  It’s most definitely not a tutorial. ๐Ÿ˜Ž

Big Numbers

The code that I’ve posted about so far has been pretty light-weight.  Here are a couple of open-source classes that I hope could be useful in actual production code.

I have an unbounded integer and a big decimal that are intended to be C++ equivalents of SQL’s NUMERIC and DECIMAL types for use in a database access library that I’m working on.  They’re basically for storing big numbers and maybe doing a little bit of arithmetic.  The efficiency of my implementation might not be good enough for serious numerical work.

That’s particularly true for division.  I’m not as competent as I’d like to be in numerics; and when I tried to read about multi-word division in Knuth Vol. 2*, my eyes glazed over; and I had to revert to the good old “long division” routine that I learned in fourth grade.  I get a first trial divisor for each new digit of the quotient reasonably quickly; but if I guess wrong, which is likely, it takes linear time to get from that point to the right value.  If there’s a numerics expert out there who knows of a good way to do multi-word division, and if it turns out that I can comprehend it, I’d love to hear about it.

The two documentation papers, all the source code for both classes, and the open-source license are zipped up here.


*Knuth, Donald E., The Art of Computer Programming, Volume 2: Seminumerical Algorithms, Third Edition

The Amtrak-Related Code

Here’s the post about the three programs I mentioned the other day about Amtrak timetables and on-time performance.  They’re programs I wrote mostly for myself to use, not to create pretty output, but to be quick and dirty ways to get me information for planning trips.

All are pretty clunky.  You first have to load raw data from the Web into your browser, then save the data in a file on your machine, then use that file as the input to a program that you run from a command line.

Most folks reading this blog probably aren’t programmers; so if they’re interested in this at all, they probably don’t want to have to compile the code for themselves.  I’ve compiled them for both Linux and Windows; the Linux version should run on a Mac.


The timetable generator

Before you worry about my code at all, check out Christopher Juckins’ timetables.  He has both current and historical timetables that are pretty PDF files of the sort that Amtrak used to publish and might be much more to your liking.

My code generates timetables that look like (but bigger):

29-30 timetable

or:

2150 timetable

One advantage is that you can create timetables with different trains for each leg of a round trip:

321-302 timetable

but that takes a bit more work on your part.  Also with a bit more work, you can create timetables for trains 421 & 422, the Texas Eagle through cars to Los Angeles, and for the Portland section of the Empire Builder or the Boston section of the Lake Shore Limited, where Dixieland Software doesn’t provide the raw data in a single file.

The documentation is here; the open-source code, if you want to play with it, is here.

If you want to just run the program, the two executables are here.  The file without any extension on the filename is for Linux; the one that ends in “.exe” is for Windows.  Just unzip the one that you want and stick it in some directory on your hard drive that’s in your PATH environment variable; then in the documentation, click on “Instructions for use” in the table of contents.

The raw data for this comes from Dixieland Software.  If you’re only creating one or two timetables, it’s probably easier to just type the URL in your browser; if you might want to generate timetables for lots of trains, I’ve put my little HTML form at https://www.cstdbill.com/train/atksked.html so that you can just load that once into your browser and bookmark it.  (Dixieland Software uses just HTTP, not HTTPS, but you’re not transmitting any secrets, so I wouldn’t worry about it.)


Two on-time performance analyzers

This is actually a library that generates an HTML table showing minimum, maximum, median, mean and standard deviation of late times for particular trains at particular stations, or the likelihood of making connections between two trains.  (This is what finally goosed me to write the trivial statistics library that I mentioned in the previous post.)  The two programs I’m talking about here are extra added attractions.

The documentation is here.  If you’re a programmer who wants to play with the open-source code, there’s a link to a zip archive in the introduction.

Most of the documentation is geeky programming stuff; so if you just want to run the programs, go straight to “Two Programs that Use the Library” in the table of contents.  You’ll find links to the executables there.


A simple SQL database

Here are some musings about a possible design for an Amtrak-related database.  Although this is intended for testing the database access library that I’m working on, I’ll include it here because it’s about Amtrak.

My current design is here.

If anybody can think of anything else I should add to it, I’d love to hear about it; although it’s not about making reservations and shouldn’t have any PII in it.

Also, I currently have no clue where to get the data to load the consists table.  If anybody knows where I might find that on the Web, please let me know.  If it’s a secret that you don’t want to disclose in a comment, you can contact me privately at was@pobox.com.


A Trivial Statics Library

A while back I wrote that I’d have some posts about some C++ code that I was working on, but then cancer got in the way.

I’ll begin with an open-source library of abecedarian statistics functions, just the minimum, maximum, median, mean, variance and standard deviation of data points that are strongly ordered.  I started with just standard containers of built-in numeric types, but quickly went over the top trying to make the library as generic as possible while keeping it simple for the built-in types.  I was basically just having fun with that.

[user documentationdoc., code and license]

I’ll have the next couple of weeks free, so I’ll try to get more examples ready for posting.  I’ve written:

– A program for generating Amtrak timetables.

– A program for analyzing on-time performance of Amtrak trains.

– A program for guessing the likelihood of making connections between Amtrak trains.

And in support of a database access library that I’m writing:

– An unbounded integer type.

– A big decimal type.

– A preliminary design for an SQL database of Amtrak trains to test it.

The database access library is nowhere near being ready for prime time yet, but I have some preliminary user documentation for the current design.

If there’s any interest, I might stick it all out on github Real Soon Now.

It’s Official

I’ll be hosting a meeting of the ISO standards committee that I serve on.

It took a little longer to set up than I had expected; but our meetings can be a little complicated.  (I hope the hotel’s sales rep. didn’t get too exasperated with me.  I try to not be one of those 20% of customers they spend 80% of their time with; but details, details don’tcha know.)

We’re expecting to have about a hundred people show up with maybe twenty or thirty more Zooming in.  The meetings are scheduled for five and a half days with Monday and Saturday mornings being plenary sessions where we handle a variety of administrivia and take formal votes.  The committee’s real work is done in smaller breakout groups, some of the groups dealing with as many as twenty or so papers during the week.

I’m looking forward to actually hosting a meeting.  I’ve gotten a great deal more from my participation than I’ve given over the years; and now that I’m retired and getting older, I think it’s time for some payback.

Issaquah Trip Report, day nine

day −1
day 0
days 1 and 2
day 3
general remarks about the meetings
days 4 to 6
days 7 and 8

2023-02-11 08:30-8:00:

Today begins my trip home, but that won’t start until this afternoon.  This morning is the final half day of the C++ standards committee, a plenary session where we take formal votes and wrap things up.

I lost a pair of glasses somewhere yesterday.  I was hoping that somebody would find them and turn them in, either to the front desk at the hotel or to one of the folks in charge of the meeting…no such luck.  Fortunately, what I lost are my “computer glasses” with the same prescription as the near prescription on my bifocals; and I can see my computer screen just fine as long as I’m only about a cubit from it.  I think I need to get some new glasses anyway because my eyes seem to be getting worse.

10:00:
Well, that was fast.  We finished our work and took the 32 formal votes in just an hour and a half.

The next two meetings will be in June in Varna, Bulgaria, and in Kona, HI, USA in November.  I’ll take Amtrak to the east and west coasts, respectively, and fly from there.

We have 2024 meetings tentatively scheduled for Japan, Sweden and Poland.  I’ll probably participate in the Japan meeting via Zoom since I refuse to sit in an airplane long enough to get there in person.

The hotel had no way to call me a taxi, but the very nice woman at the front desk called an Uber using her app; and I paid her the cash.  I have a cell phone, but I don’t have any special apps on it.  I guess this old dude needs to get with the program.

11:15:

After checking one bag to Chicago at the train station, I went to a restaurant in the Embassy Suites and had the Reuben sandwich.  It was edible, but I could detect no 1000 island dressing.  I guess the cook layed on hands and intoned “1000 island”.

12:00:

King Street Station has no place to sit at a table and work on a laptop; but on the third floor is some kind of arts and education council office, or something, which has a couple of such places; so here I sit, one of three folks doing a bit of writing.

Train 8 started boarding about 16:40 or so and departed on time.  I’m in room D this time, so the electrical outlet is near the window where I’ll be plugging in my power strip.  I’m riding backwards this time, but that doesn’t bother me, and I’m on the fireman’s side eastbound so I won’t have the sun in my eyes going through big sky country.

Like the westbound trip on train 7, this train has only one coach.  The TA said that it’s OK during the light travel season, but they’ll really need a second coach, and probably a second revenue sleeper, before long.

We were out of Wenatchee only about fifteen minutes late.  It turns out that Wenatchee is a crew change point for the engineers, but not for the conductors.  Normally, engineers and conductors work, not particular trains, but particular sections of track.  Why only the engineers change in Wenatchee I have no clue.

We have about a two hour dwell time in Minot, which I’ll talk more about tomorrow.  For now, I’ll try to use this time to post the report for day 9.  It might not be proofread as well as it should have been.

Issaquah Trip Report, days seven and eight

general remarks about the meetings
days 4 to 6

2023-02-09:

I didn’t get a good night’s sleep last night and felt pretty wiped out most of the day.  I spent a little time in the Evolution Working Group (EWG), the subgroup that considers changes to the core language.  All I remember is something called a “pipeline operator” which would inject arguments into following function calls.  I couldn’t figure out what it was good for or why anyone would want it.

Mostly I rested up for an evening session of the numerics study group where we continued the discussion of floating point rounding that slopped over from the evening session on Tuesday.  It turns out that there are quite a few cases where the behavior is not at all intuitive.

The last thing on the agenda was a paper of mine.  About a decade ago or so, I had in mind a database access library in C++ that would be the rough moral equivalent of the java.sql.stuff; but I soon had some medical issues and couldn’t pursue it, and so nothing ever came of it.

One thing I needed, and implemented, was a C++ type that could give me a round trip to and from SQL’s NUMERIC and DECIMAL types which are fixed point decimals.  A few years ago, the numerics folks were thinking about publishing a numbers TS.  The rational number in §7 of that paper was my work; and I thought that my “big decimal” type was a kind of number, too, and so maybe a more generally useful version of it (written against C++23, has NaNs and infinities, etc.) could also go into the TS.  It turns out that there’s not much interest in that any more, so I won’t be pursuing that any further.  I think that was the right decision since my target audience is good old “business data processing” which isn’t really the market for C++.

2023-02-10:

I spent today in EWG where it was “safety Friday”.  We spent the morning talking about various ways to mitigate the problem of uninitialized local variables on a function’s call stack.  There seems to be consensus for the rule that local variables without explicit initializers should be zero-initialized (like globals are), but it turns out that there are corner cases where that could change the meaning of some code, and static analysis tools would no longer be able to flag the potential bug.  We’ll need to think about this some more.

Just before lunch, we took the customary group photo.  As I write this, it’s not online yet; but I’ll embed it when it is.  I’ll be which is the bottom picture among these three.  I’m the old fart on the right of the first row who’s sitting on his walker wearing a St. Louis Cardinals baseball cap and an N95 mask (because COVID isn’t over yet).

After lunch, we talked about “type and resource safety”.  From the paper by Bjarne Stroustrup:

  • every object is accessed according to the type with which it was defined
  • every object is properly constructed and destroyed
  • every pointer either points to a valid object or is the nullptr
  • every reference through a pointer is not through the nullptr
  • every access through a subscripted pointer is in-range

Those are informal rules that C++ coders have always been expected to follow, but it’s not really possible for static analysis tools to enforce them completely.  There seems to be a strong consensus for some kind of framework that would improve the situation.

Tomorrow morning will be a plenary session where we take formal votes.  That should end by noon, probably before; and then I’ll be on my way back to King Street Station where I’ll board Amtrak’s Empire Builder for the first leg home.