The Boston Diaries

The ongoing saga of a programmer who doesn't live in Boston, nor does he even like Boston, but yet named his weblog/journal “The Boston Diaries.”

Go figure.

Monday, May 01, 2023

The Case of the Inconsistent Consistent Chirp

Bunny and I were plagued with the most insidious inconsistently consistent chirp over the past few days here at Chez Boca. There would be this distinct chirp. Just one. And by the time you think it won't happen again, it would happen again. And then … nothing. For hours. Or maybe the rest of the day even. But sure enough, it would pick up again—a single chirp, then silence, then maybe another chirp, repeat for a few minutes then, nothing more for hours.

When it first started, I thought maybe one of the UPSes was responding to some power fluctuation, but no, they squeal quite loudly, and none of them showed any form of distress when I checked. This was more of a short chirp than a loud squeal. And by the time I was tired of looking at whatever UPS I thought it might be and turn away, there was another chirp.

It was mocking us.

Between the two of us, we had narrowed down the possible source in Chez Boca, somewhere along the west wall of the house. The only things in the area that could possible chirp were:

But all these devices had been there for years before this chirping had started. It was weird as it was maddening.

I even went so far as to check the bathroom, as, from where I sit in the Computer Room, the chirp could be coming from there. The only three things in the bathroom that could possible chirp: the lights, Bunny's electric toothbrush and a small clock.

I discounted the lights—they're the original fixtures from the 70s—no strange electronics in there, and more importantly, no speakers to speak of. I did unplug the base unit of Bunny's electric toothbrush, and had the toothbrush itself in the Computer Room. The chirp didn't go away, and it wasn't from the toothbrush. Nor was it from the small electric clock (I too, brought that in to the Computer Room and cleared it as a suspect).

Then, late Saturday night, I was in the family room along with Bunny when it happened again. We were standing far enough apart that it appeared to be the floor lamp just by simple tiangulation. During an examination of the lamp, I happened to glance up, and there, above the door to the Computer Room, was a small, round disk shaped device stuck to the wall—a smoke detector.

Bingo!

Taking the unit down and reading the back, yes, it would chirp to indicate the battery needed changing. And neither Bunny nor I could recall when the battery in the unit was changed.

Heck, we both forgot about the unit being there at all.

Even worse, when I started telling this story to some friends at our regularly scheduled D&D game, they knew the punchline even before I finished. Sigh.

Now I just have to figure out why our ice maker is making hollow ice.

Wednesday, May 10, 2023

Proportional fonts for coding? No thank you

There's some back and forth in the Gemini community about coding with a proportional font. You can pry my monospace font from my cold dead hands.

I've been coding for nearly 40 years now, and it's always been some form of a monospace font, some pretty, like the character set for VGA on IBM PCs, and some not to pretty, like the character set on the TRS-80 Color Computer. Code in a proportional font just looks weird to me.

My first language was BASIC on the TRS-80 Color Computer, and due to limitations on the video screen and memory constraints, pretty much any non-trivial BASIC program ends up looking something like;

1445 X=FREE(PEEK(4670)):Y=FREE(P
EEK(4671)):IF X<2ORY<2 THEN PRIN
T"MESSAGE BASE FULL!":RETURN :EL
SE IFML>0THEN P$="10000000":GOTO
1450:ELSEIFPF=0THEN P$="00000000
":GOTO1450:ELSEPRINT"MESSAGE PRI
VATE (Y/N)? ";:GOSUB625
1446 IFCH$="Y"THEN P$="10000000"
:PRINT"YES":ELSEIFCH$="N"THEN P$
="00000000":PRINT"NO":ELSEGOSUB6
25:GOTO1446
1450 K=LEN(MF$)+LEN(MT$)+LEN(MS$
)+2:IFK>64THENPRINT"SUBJECT TOO 
LONG":PRINT"LIMIT TO ";64-LEN(MF
$)-LEN(MT$)-2:PRINT"TRUNICATING.
." :ELSE 1452
1451 IFLEFT$(MS$,5)="REPLY"THEN 
MS$=RIGHT$(MS$,LEN(MS$)-(K-64)) 
:ELSE MS$=LEFT$(MS$,LEN(MS$)-(K-
64)):GOTO1450
1452 GOSUB25:PRINT:PRINT:PRINTTA
B(5)"FROM: ";MF$:PRINTTAB(5)"  T
O: ";MT$:PRINTTAB(5)"SUBJ: ";MS$
1453 IFP$="10000000"THENPRINTTAB
(5)"PRIVATE MESSAGE":ELSEPRINTTA
B(5)"PUBLIC MESSAGE"
1455 IF ML=2 THEN 1465 :ELSE PRI
NT:PRINT"CORRECT (Y/N)? ";
1460 GOSUB600:K=INSTR("NnYy",CH$
):IFK>2THENPRINT"YES":GOTO1463:E
LSEIFK>0THEN1415:ELSE1460
1463 PRINT:PRINT
1465 PRINT:PRINT"ENTER MESSAGE. 
MAXIMUM OF 2000":PRINT"BYTES. MA
XIMUM OF 40 LINES.":PRINT"PRESS 
<ENTER> ON LINE BY ITSELF":PRINT
"TO EXIT.":PRINT:LE=0:EXEC&H10DA

Yes, you can pretty much get used to any type of formatting if you have to. Fortunately, you no longer have to.

The next few languages I picked up were various assembly languages, which are nearly always vertically aligned:

;--------------------------------------------------------
;	SPHEX4		Display a signed word as hex
;Entry:	D - word
;	U - buffer
;Exit:	U - U + 4 (or 5)
;--------------------------------------------------------

sphex4		tsta			; negative?
		bpl	sphex42		; nope
		stb	,-s		; save B
		ldb	#'-		; print leading minus
		stb	,u+
		ldb	,s+
		coma			; negate D
		comb
		addd	#1
sphex42		bsr	phex2		; print high byte
		tfr	b,a		; now print low byte
		bra	phex2

The decade or so of this left me with an “assembly accent” (which you can pick up on in this post). That, along with some other … quirks in formatting, makes it pretty easy to tell I've been working on the code. I've been developing my C style for over 30 years, and my opinion on “code formatters” is … well … if I didn't want opinions, I'd join a cult. More opinionated—if you have no coding style of your own, you have no soul and probably enjoy The Enterprise Agile being shoved down your throat [Tell us how you really feel! —Editor]. Or at least don't mind it.

But getting back to coding with a proportional font. The original article presents the same code fragment in a monospace font:

import 'dart:io';

/// Replaces typewriter quotes and double dashes in all '.gmi' files under
/// the specified path with their nicer unicode equivalents.
///
/// Usage: dart fix_typography.dart <root path>

void main(List<String> arguments) {
  final gmis = Directory(arguments[0])
      .listSync(recursive: true)
      .whereType<File>()
      .where((f) => f.path.endsWith('.gmi'));
  for (final gmi in gmis) {
    print('Fixing ${gmi.path}.');
    final lines = gmi.readAsLinesSync();
    var skip = false;
    for (var i = 0; i != lines.length; ++i) {
      var line = lines[i];
      if (line.startsWith('```')) {
        skip = !skip;
        continue;
      }
      if (skip) continue;
      line = line.replaceAll("'","’");
      line = line.replaceAll('--','—');
      line = line.replaceAllMapped(RegExp(r'"(\w)'), (m) => '"${m.group(1)}');
      line = line.replaceAllMapped(RegExp(r'(\w)"'), (m) => '${m.group(1)}"');
      lines[i] = line;
    }
    gmi.writeAsStringSync(lines.join('\n'));
  }
}

(Typos mine as this is transcribed from an image; also, sans syntax highlighting.)

And in a proportional font:

import 'dart:io';

/// Replaces typewriter quotes and double dashes in all '.gmi' files under
/// the specified path with their nicer unicode equivalents.
///
/// Usage: dart fix_typography.dart <root path>

void main(List<String> arguments) {
  final gmis = Directory(arguments[0])
      .listSync(recursive: true)
      .whereType<File>()
      .where((f) => f.path.endsWith('.gmi'));
  for (final gmi in gmis) {
    print('Fixing ${gmi.path}.');
    final lines = gmi.readAsLinesSync();
    var skip = false;
    for (var i = 0; i != lines.length; ++i) {
      var line = lines[i];
      if (line.startsWith('```')) {
        skip = !skip;
        continue;
      }
      if (skip) continue;
      line = line.replaceAll("'","’");
      line = line.replaceAll('--','—');
      line = line.replaceAllMapped(RegExp(r'"(\w)'), (m) => '"${m.group(1)}');
      line = line.replaceAllMapped(RegExp(r'(\w)"'), (m) => '${m.group(1)}"');
      lines[i] = line;
    }
    gmi.writeAsStringSync(lines.join('\n'));
  }
}

To me, the proportional font crushes the indentation too much for my liking, making it harder for me to “see” the structure of the code. Of course, the original image has low-contrast vertical bars showing each indenting level, but I suspect that's an IDE-specific thing to help show the structure (I'm not a fan of IDEs for various reasons). And using color for information isn't exactly nice to the color-blind. Why not italic for variables? Bold for keywords? You're already using a proportional font, you might as well use font properties for visual information, but I digress. It just looks too scrunched up for my liking.

I think this just comes down to it's totally alien to my way of thinking

Obligatory Picture

Trying to get into the festive mood this year

Obligatory Contact Info

Obligatory Feeds

Obligatory Links

Obligatory Miscellaneous

Obligatory AI Disclaimer

No AI was used in the making of this site, unless otherwise noted.

You have my permission to link freely to any entry here. Go ahead, I won't bite. I promise.

The dates are the permanent links to that day's entries (or entry, if there is only one entry). The titles are the permanent links to that entry only. The format for the links are simple: Start with the base link for this site: https://boston.conman.org/, then add the date you are interested in, say 2000/08/01, so that would make the final URL:

https://boston.conman.org/2000/08/01

You can also specify the entire month by leaving off the day portion. You can even select an arbitrary portion of time.

You may also note subtle shading of the links and that's intentional: the “closer” the link is (relative to the page) the “brighter” it appears. It's an experiment in using color shading to denote the distance a link is from here. If you don't notice it, don't worry; it's not all that important.

It is assumed that every brand name, slogan, corporate name, symbol, design element, et cetera mentioned in these pages is a protected and/or trademarked entity, the sole property of its owner(s), and acknowledgement of this status is implied.

Copyright © 1999-2024 by Sean Conner. All Rights Reserved.