Debugging in C

I've spent a horribly long time tonight staring at nested stack manipulation code now to get algebraic expression parsing (mostly?) working. I hate unary minus; life is pretty good except for that ugly little weiner with its binary operator twin, and then BAM weird compromises in your code.

For most errors, I rely on testing (even if just firing a test script through the language, as I'm doing with tbasic) and debug mode with verbose stderr logging. But this is C, where the slightest mistake can be EXC_BAD_ACCESS with no clue where. So then I need a debugger…

% make && lldb -o run -- tbasic -d test1.bas

[update: Forgot the -- before the program, which prevents lldb from reading those params. Command lines without parens are easy to get wrong!]

I don't really do much serious with lldb, I just need to see where an error occurred, backtrace (bt), and sometimes print some variables, to usually be able to solve a crash. It's a little frustrating that the lldb environment is so primitive, though, doesn't even have stdout, stderr (weirdly \<stdio.h> is callable), so how do I call utility functions? Had to rewrite some functions to take default NULL values.

Anyway, let and print (and error, my idiosyncratic stderr print) work, there's not a lot left in BASIC then I can get back to more serious things.

What I'm Watching: Struggle: The Life and Lost Art of Szukalski

A Netflix documentary on a largely-forgotten sculptor and artist from the early 20th C. I've seen a few of his pieces in underground comics and books, and had heard his Yeti conspiracy in SubGenius tracts but hadn't connected them previously. This film takes as primary source his bragging which exaggerates his influence, which in reality largely ended in WWII.

George DiCaprio, Leonardo's father, knew him, and both do narration and interviews and are making this film public on Netflix. So, take a vanity project for what it is.

His temper tantrums at museums and galleries are part of why he is "lost", but his really noxious antisemitism and Polish nationalism are the "we don't want you here" part. Like many European and English writers and artists of the time, even those who were in different countries and didn't like Hitler, he still loved fascism and inciting murder of Jews. He wasn't just obscure because he lost his Polish studio, but because he made himself untouchable. The film keeps touching on that and then startling away, and making apologies for him.

His later derangement and conspiracy theories of a deluge and Yeti-people are… well, charming by comparison, but claiming that many people right among us are subhuman corrupters isn't any better, and leads to the same atrocities if you get enough crazy people, and we're full up on crazy people these days. While the film spends some time on it, reading about his views online shows they really soft-pedalled it in the film.

At first I felt this was a bit of an American Movie clone, Stas' focused but low-class craziness and the long downward slide. But no, it turns out he's a very different kind of monster turned failure.

★★★½☆

Programming in C

On tbasic, I've been doing all my C coding in BBEdit, not fucking Xcode, and it is fantastic. Doesn't crash. Syntax highlighting works, and by "works" I mean doesn't replace my text with Cyrillic as Xcode is wont to do (I do not like the new BBEdit color theme editor, but it's a far cry from stabbing me in the face like Xcode does). BBedit's window stays where I fucking put it, and sidebar shows clearly which files are open and modified. Running make from iTerm2 works fine, if you aren't an idiot and each compile produces less than a handful of errors. I can't really use BBEdit for JavaScript which needs more tool support, but for simpler languages, it's fine.

OS X Mojave no longer has C man pages visible anywhere I can find, so Dash is the only way to look anything up:

To use it from the shell, create dashman: (hashtag command-line integration, I couldn't find this in any search, and Dash has no AppleScript which is my usual solution to o'erweening GUIs)

#!/bin/zsh
open "dash://$*"

Hm. So, I've worked with people who don't learn their languages, they just rely on autocomplete in an IDE, snippets, and StackOverflow. If this is you, if you can't code without an Internet connection, you can't code. Please stop programming, go away, and read a book until you know the syntax and fundamental APIs, because right now you do more harm than good.

That said, while I studied K&R (and Stephen Kochan's Programming in C, my introduction back in the '80s) with the intensity of a snake-handler reading his Bible, I certainly can't remember every strcspn, strcoll, strstrn or whatever random series of 7-letter identifiers they had to use back in the '70s (even in the late '80s, I was still using C compilers which only distinguished 7-letter identifiers). C's libraries are often gibberish and searchable man pages are all we have.

Metal 2019 Tuesday Music

Gonna start this year off with some music discovery; all three of these get updated weekly, so bookmark this post and check back. In a long list of things Apple Music doesn't do well, there's no way to pin them to the For You page. And the best album of last year: