A Scheme of Gerbils Runnin' in a Wheel

Chicken's mediocre performance is causing me problems, so I'm taking yet another language tour/spike.

Looking at Gerbil Scheme, as a faster Scheme and as a bonus it's closer to R7RS. It has far less library support than Chicken, but does have a FFI, and compiles to a native binary through C, so I really don't need too many libraries.

Instead of the #!key #!optional #!rest keywords used in Chicken and some others, Gerbil uses a literal template style for functions:

;; Chicken: (define (foo a #!key (b 'bar) #!optional (c "see?") #!rest rest)
;; Gerbil:
(def (foo a b: (b 'bar) (c "see?") . rest)
    (print "a=" a " b=" b " c=" c " rest=" rest "\n")
)
(foo "Mark" 1 b: "bees!" 'what) ;; note out-of-order optional & keyword
;; a=Mark b=bees! c=1 rest=what

I like this style better, but I dislike the "def" keyword (which uses the enhanced lambda that does this) instead of "define" which uses "lambda%" (traditional lambda).

Gerbil uses [] for list construction, and {} for method dispatch, so goodbye to the nicely distinguishable braces I was using in Chicken. The spec says implementations can do what they want with those symbols, but I wish they wouldn't. Ah, well. I'll add a shitload more whitespace and some comments and it'll be fine.

The struct/object system in Gerbil is pretty nice, they're slightly upgraded records, but there's an (@ obj field) syntax instead of (MyClass-field obj), and (defmethod {mymethod MyClass} ...) creates a polymorphic {mymethod obj args} which finds the right method for any object, which is especially useful for inheritance.

I tried doing some VT100 graphics just to proof-of-concept, but it's doing something to the terminal, such that the same escape codes which work in Python don't clear the screen fully in Gerbil. After a short losing battle with stty and termcap, I give up on that and I'll jump right to writing a C FFI to SDL, because in 2019 that's easier than writing to a console.

Daily reminder that everything we have made since 1984 is overcomplicated junk. On an Atari 800, this took a few seconds to type, and you could start coding a nice UI instantly:

atari-is-awesome-graphics1

Alas, we live in a fallen world, so this is going to be trouble. Here's my Gerbil FFI template so far:

package: myffi

(import
    :std/foreign
)

(export )

(begin-ffi
    ;; names of all Scheme wrappers to expose
    (chello)

(c-declare #<<CDECLEND

 <stdio.h>

int chello(void) {
    printf("Hello this is C!\n");
    return 1;
}

CDECLEND
)

    (define-c-lambda chello () int "chello")

) ;; begin-ffi


; TODO for constants: (define FOO ((c-lambda () int "___result = FOO;")))

(define (main . args)
    (chello)
)

Gerbil has a Scheme-based build system, but I'm a caveman so I make another build.zsh:

#!/bin/zsh

function usage {
    echo "Usage: build.zsh MAIN.scm [LIBS] || -?"
    exit 1
}

if [[ $# -eq 0 || "$1" == "-?" || "$1" == "--help" ]]; then
    usage
fi

mkdir -p bin

main=`basename $1 .scm`

gxc -exe -static -O -o bin/$main "$@" || exit 1
echo "Built bin/$main"

Now:

% ./build.zsh myffi.scm
Built bin/myffi
% bin/myffi
Hello this is C!

Hooray! Unconditional success! Only took all afternoon and a half-pot of coffee!

Now I "merely" have to wrap all of SDL (well, just the parts I need) and get linking working and oh sweet merciless Cthulhu. And I still won't know how much this'll help my performance until I'm days into it. But, the first step is the hardest.

Project UFO

Which one is correct? Let's think about this from the other direction. Could we buzz another planet, today, in a way that makes "UFO sightings are ALIENS!" make any kind of sense?

Premise 1: It is incredibly unlikely that any "intelligent" species, having recently developed from hunter-gatherers to agriculture to technology in the span of a few thousand years, is smart enough to reach that technological stage without making their planet uninhabitable as we have, or discovering nuclear weapons and waging primitive tribal warfare with them. Even if anyone survives this century, or we colonize Mars, it may be centuries before we have this amount of available energy and economy again.

Therefore 1: Any "UFO" is probably from someone like us, just barely capable of doing it before going extinct. A last fireworks show before the Long Night.

This is going to take a while to work out. Get a coffee.

The nearest star is Proxima Centauri, 4.3 Light Years (272K AU, or 40.7 trillion km) away, and there is a potentially habitable planet.

If we stopped having wars (as if!), we'd have a few trillion dollar surplus; but I'll just suppose we redirect no more than half our military budget. You could easily recruit volunteers for a life-long mission.

A spaceship capable of keeping people alive to get there would be, as a minimum, the size and complexity of a nuclear submarine, 6800 tons displacement, 128 crew, and maybe 100x the cost: $150 billion. Let's handwave away with hydroponics and recycling that a real sub has to surface for supplies every 3 months, and the reactor lasts 30 years before it needs a refuel from recently-processed uranium. Neither are insurmountable engineering, the ship's going to be unpleasant to live in but it's about the best we can do.

SpaceX Falcon Heavy can lift 22.2 tons to orbit, displacement isn't exactly dry weight but close enough for an estimate so that's 300 launches at $100M+ each ($30 billion!) and then somehow assemble it in orbit.

Assembly would be easier if we had a space colony, with a giant machine shop, or even could still run the Space Shuttle (the space truck finally useful for something!), but that'll cost even more money and time to set up. At least another $1 billion on moving enough workers through ISS to finish the thing.

Now we need a space drive. Here we're kinda screwed.

As reference, see Atomic Rockets, menu at the bottom of the front page is where all the interesting stuff is, and in particular Slower Than Light. And a lot of the systems given there don't work in reality, or we don't have yet.

The "ALIENS!" enthusiasts are gonna say magic spacedrive, or fusion torch, or whatever, but we can't make any of those, and fuel's still not adequate for constant burn. You can't magic up extra fuel. There is no such thing as faster than light travel. And see premise 2 later.

Bussard Ramjets would be perfect, even with the 0.12 C speed limit they would actually have… but we aren't within decades of making one.

The nuclear reactor could power an ion drive, which we know how to make and fuel, very very low thrust but constant acceleration, scratch pad shows decades to reach halfway and start decelerating, except we can't carry enough reaction mass and there's none in deep space. Great for in-system maneuvering if you're patient, useless for interstellar travel.

Orion drive, firing nuclear bombs at a heavy plate under your ass, is an act of war in our own Solar System, and a giant whiplash and cancer machine for the crew. 100% buildable, but nobody's that stupid.

Charles Pellegrino's Flying to Valhalla has a reasonable proposal for a sorta clean antimatter drive that'd get there in about 5 years, we just need to plate Mercury in solar cells to power particle colliders to make the shit. Avatar is a stupid, terrible, stupid movie, but Pellegrino designed the starship in it, which is perfectly reasonable. So, that's a century or two off. No good.

Solar sails and laser launchers should work, and we can make these. We'll know for sure in a couple weeks. Making them big enough for a huge ship (1000 km across!) is a challenge, but this is a matter of engineering, not fundamental science. This would take 20 years to reach halfway and 20 years to slow down, but some original crew and their kids could get there.

The lasers are the infinitely expensive part, where you can just sink all money forever into and not be done, but good news is A) they stay put in the Solar System, B) you can build and launch them one at a time over years as a satellite array zapping a lens which projects onto the sail, and C) they're useful anti-asteroid tools (not by burning, but put another sail on an asteroid, and you can push it out of harmful orbits). The bad news is D) the people back home may be dead/forget about you/not be able/be unwilling to continue running them in 20+ years, and E) lasers in orbit can be turned against ground targets, almost literally a lightning bolt from "god" striking down your enemies. Quis custodiet…

Worst case is the lasers go quiet, and the laser sail ship becomes a much slower solar sail ship, which has to make a couple of slowdown passes at AC. If our recycling is good enough, maybe that works, maybe we die alone in the cold of space.

Now we're cruising slowly thru the system, find a habitable planet. We can't land the ship, but have a complement of drones that can fly into atmosphere. An unmanned drone could maneuver faster than any aircraft, and would even be hard for primitive radar to spot, just like our UFO stories.

But is there anyone there? Humans have existed for ~1 million years, about 5,000 of that civilized enough to be worth talking to, 100 years capable of radio, before probable nuclear or environmental extinction. Out of 3.5 billion years of Earth being a life-bearing planet so far, and maybe 6.6 billion years ahead where life can exist, that's a 1 in 2 million chance of there being anyone to talk to.

The ship would be very visible, with sails out decelerating in, it'd be the brightest object in the sky. If the autochthons have radio, they can be called; but we'd have already heard their broadcasts here on Earth. Maybe blinking lights to talk to a more primitive culture? Land a drone and talk over a radio speaker?

There's no easy way to land, abduct redneck autochthons, probe their cloaca-like entries, and return. Even if there was space for a couple Falcons as landers (strapped to the sides as maneuvering thrusters?), they'd need fuel to get back up. It may be possible to do a one-time water landing of the spaceship without killing everyone.

The only reason we would ever have gone there is to meet them and share information, tell them about our home and what we're like. Show them Pulp Fiction and The Ramones and Heinlein's The Green Hills of Earth. We wouldn't be trying to keep it a secret, even aside from the physical impossibility of hiding the spaceship. Nor would the aliens cover it up; no matter what they are, we'd be the most important new source of science, technology, and entertainment.

But landing presents political problems even with public disclosure, they might go to war over who "gets the Earthers", and possession is 9/10ths of interstellar law. Hopefully there's some competent diplomats. There's a lot more ways first contact can go wrong than anything in the flight. Really think very carefully before landing.

Colonization is difficult anyway, the atmosphere's not likely to be the mix we need, the native life may be digestible into basic materials (most life is probably CHON ) but will lack any vitamins; we'll need to keep eating hydroponics. We'd be immune to local viruses but might have no immune reaction to local bacteria & fungi equivalents, nor would any native life to ours. Staying in orbit or colonizing a barren rock is safer.

There will be no alien hybrids, no half-Vulcan Mr Spocks, and the aliens won't look anything like a Human with a latex mask. First, do you consider mating with chimps, crocodiles, squids, tulips, or…? No, stop, I don't wanna know! Baka! Ecchi!! But those are genetically related to us and yet no offspring is possible because we don't have enough compatible genes. If panspermia is real, actual aliens would be more distantly related than fungi, and if not then it would be like screwing a rubber toy.

Conclusion 1: Any plausible alien spaceship scenario is going to look almost nothing like the UFO contact stories. We'd see them coming. They'd have to talk to us on the radio. No secret bases. No abductions. They'd be weird alien pop stars with agoraphobia and unused to gravity, constantly on PR tours and eating alien food because ours is useless.

Premise 2: So Pellegrino's matter-antimatter drive? The point of Flying to Valhalla was that a near-C space drive is a one-shot planet-killing weapon. You'd briefly see an X-ray burst, then the ship's front shield would shatter like a shotgun shell so you can't just redirect it, then the planet would explode, in the space of hours or minutes as the ship chases up behind its light. And you could set one up with a deadman switch to kill whoever killed your planet.

Therefore 2: We're not dead yet, and nobody's contacted us to say "listen up, these are the rules!" Mutual assured destruction means they have to assume we'll do it to them. They don't have to fire first, just make sure we know the threat exists.

Conclusion 2: Nobody within 50 light years of us has advanced technology and has heard our radio signals (50 years there, 50 years for the weapon to come kill us).

Any other scenario isn't science, isn't even science fiction, it's just fantasy. I like fantasy as much as the next guy who isn't wearing a My Little Pony shirt, but it's not real.

The Machine Stops

The problem with the Internet… and here I'm referring to (sweeps hand across everything in view) all of this, but to take just current events Google blocking ad-blockers in Chrome, Google downtime locking people out of their Nest thermostats and "Home"-controlled security systems, horrible prisons of the mind like Twitter and Facebook, and the cacophony of Fediverse drama over Eugen adding features (better features are already in Pleroma and glitch-soc Fediverse servers), Gab forking Mastodon, client devs making unilateral decisions to block domains despite helpless users complaining, or anyone having "free speech" (which Eugen in particular is opposed to; I strongly advise against using mastodon.social, find another instance). These are just a point-in-time examples, it's been going on for decades (oh, USENET, how we don't miss your flamewars) and will only end with us.

… is people using software they didn't write themselves. No understanding, education, or discipline required. Just install something and it works! It's a product, not a skill! But they don't know how, or why, or why they should not.

"It didn't take any discipline to acquire", in the words of Ian Malcolm/Michael Crichton.

Until the software they rely on shuts down, literally like E.M. Forster's "The Machine Stops", and then weak unskilled mole-people crawl out of the wreckage of machines they never learned to understand, make, or repair, and then die.

My solution is drastic but logically unavoidable: No more software installs. As a child, you get a bare machine with nothing but a machine-language monitor. You learn ML first. You type in a language compiler or interpreter. You build up your own tools. We return to type-in program listings like Compute!, but no binary blobs, it must all be readable, comprehensible source, with design and implementation documentation.

If you want to share software, you need to build up your toolchain to that point yourself. Hopefully by then you've learned to read all patches you install.

Should this be extended to all technology? Information technology has the unique ability to coerce how and what you think; an automobile or an antibiotic does not. There's an argument (in "The Notebooks of Lazarus Long", for instance) that a citizen should be able to make all their own things, "specialization is for insects". But insects are the most successful clade on Earth, and will long outlive us; some specialization is probably acceptable, as long as it's not in the part that controls how you think.

I don't think this civilization can ever do that, it will not make hard changes that inconvenience anyone. I think this horrible Machine will lumber on a few more decades and then we'll all die from it. But maybe isolated tribes will survive, or intelligence will arise in the Machines, or in a few million years another intelligence will evolve, and build new things the right, responsible way. Their history books will describe us as being as foolish and self-destructive as the Easter Islanders.

Support Me on Patreon!

With the BBS going public, and soon a real release of Perilar Fallen Kingdom, it's time for you to help me keep doing this!

Become a Patron!

I'd at least like to get my hosting costs under control, and anything over that goes to me making cool games and apps for art, instead of boring things to survive.

The Best SF Author of All Time

So, I can't actually pick one, or even rank ten, but by decade (when they made the works most important to me) it's down to a short list:

  • 1830s: Edgar Allen Poe
  • … long empty stretch …
  • 1890s: H.G. Wells
  • … shorter empty stretch …
  • 1930s: H.P. Lovecraft
  • 1940s: A.E. Van Vogt
  • 1950s: H. Beam Piper, Clifford Simak
  • 1960s: Brian Aldiss, Robert A. Heinlein, Zenna Henderson, Frank Herbert, Andre Norton
  • 1970s: Marion Zimmer Bradley, Katherine Kurtz, Fritz Leiber, Anne McCaffrey, Michael Moorcock, "James Tiptree, Jr", Roger Zelazny
  • 1980s: Mary Gentle, William Gibson, Elizabeth Moon, Rudy Rucker, John Shirley, Bruce Sterling, Walter Jon Williams
  • 1990s: Pat Cadigan, Greg Egan, Neal Stephenson
  • 2000s: Neal Asher, Peter F. Hamilton, Alastair Reynolds
  • 2010s: Mira Grant (aka Seanan McGuire), Martha Wells

I can make an argument for almost any of them to be "my favorite" depending on mood, but Piper might be the winner in a bracket contest. I suspect I'd get down to something like Piper vs. Egan and my head would explode trying to compare Space Viking with Diaspora.

My first pass at this, there were only 3 female authors (Pat Cadigan, Mira Grant, and Martha Wells). Several were only fantasy: Which I think less of, but I do read—and Leiber and Moorcock's science fiction are not their best works.

Many only had a few great books or short stories surrounded by a giant midlist of dullness, but that's also why Niven, Pournelle, Steven Barnes, Iain M. Banks, Dan Simmons, and Poul Anderson never made it. Several I do list produced dullness after their peak, like Gibson objectively only wrote one short story collection & 2 thin novels worth reading, one should not read McCaffrey's post-trilogy extended sequels, and anything Stephenson wrote after The Diamond Age needed an aggressive editor to cut out about 2/3 of his text. And yet many continue to write exactly what I like, decades later.

The '60s-'80s really produced a LOT of SF I liked. Was it objectively better? Or was it just "the golden age of SF is 12" which was 1982, so I read what was still in print?

Terminal Condition

I spend half my time, easily, in a command-line terminal running zsh. So a new one, even one on an OS I don't run, is interesting:

There are some modern, nice conveniences in this. It's a little ways behind Mac Terminal.app (based on the NeXTstep Terminal from 1990), and vastly far behind iTerm2, but it's more advanced than the usual Linux terminals like rxvt, urxvt, or cross-platform Alacritty or Hyper.

Between this and WSL2 being a full Linux, it's plausible that the best Linux dev environment now (well, this summer when it's released) is Windows. The Year of the Linux Desktop is 2019, and it is owned by Microsoft®. Can you hear the tiny, distant screams of the FSF cultists?

Comparison based on code, reviews, and reddit thread with MS devs involved:

  • Scrollback: The single most important thing a terminal can do. MS does this, but doesn't have logging.

    Surprisingly, a lot of them only support a few pages. I keep mine at 10,000 lines or so, which is probably wasteful but so handy; I don't bother logging since my .zhistory keeps everything I typed, and I have Terminal.app and iTerm2 set to not close tabs automatically.

    Alacritty only just added scrollback last year.

  • Prompt Marking: Nope.

    This is a feature it's hard to live without once you've had it, no more paging up trying to see prompt lines (I have a red ANSI-colored prompt and it's still hard to see). In Terminal.app, Edit, Marks, Automatically Mark Prompt Lines, and then ⌘↑ and ⌘↓ move between them. iTerm2 has it enabled by default, and ⇑⌘↑ ⇑⌘↓ are the keys, which took me some re-learning.

    Nothing else has this, as far as I've seen.

  • Fonts: MS has programming ligatures and displays emoji, finally. Does not support RTL languages.

    I use Fira Code in all my editors and shells, and it's enormously helpful, more readable, and catches bugs: I look for === as a fat-equals symbol in JS, etc.

    Hyper, urxvt, Alacritty support Unicode fonts. rxvt stopped development almost 20 years ago so it barely shows 8-bit fonts correctly.

  • Tabs: MS has tabs! They're currently invisible until you add a second tab, same shit Terminal.app does, which annoys the hell out of me; I don't like UI that reshapes itself, reminds me of T-1000 Terminators (also makes it hard to tile my windows up correctly when they get resized).

    It's not clear if you can drag Windows Terminal tabs around to different windows.

    In iTerm2, I normally keep: First window with tabs for home shell, ssh into my server (running screen, so that has many open shells). Second window with 2 tabs for REPL, editor/running/compiling tasks, and sometimes a third tab for reading local docs. If I need more shells, I usually open them on the first window. I rarely open a third window for monitoring some long-running task; I just drag a tab out to its own window. All terminal windows are stacked on the left side of my screen, because there's no icons under that side of the Desktop.

    urxvt has tabs, but they're kind of a hack, not fully usable.

    Hyper has tabs, but they replace the title bar. Which is cool but also awful like a lot of things it does.

    rxvt and Alacritty don't do tabs, because they insist you use screen or tmux. Which sucks if you want to move a process from one window to another.

  • Profiles: MS supports multiple profiles, so you can use different ones for each task.

    So does Terminal.app, iTerm2, urxvt (but it's buried in a text file config).

    Alacritty, rxvt, and Hyper have a single profile and no UI for changing anything, hope you like editing text files and reloading.

    As far as I can tell, nothing else does automatic profile switching like iTerm2; when I cd to my ~/Code/CodeScheme folder, iTerm2 switches to my dark red transparent profile, including Scheme-specific triggers and copy/paste filtering.

    You can probably do that in urxvt's Perl(!) scripting, but it's not normal or easy.

  • Copy/Paste Filtering: Nope.

    iTerm2 and urxvt both let you set a bunch of regexp to run over lines to get selections correctly matching boundaries, not just space-delimited.

  • URL Highlighting: Nope.

    iTerm2, Hyper, and urxvt notice URLs and filenames, and let you click on them. In iTerm2, hold down ⌘ and click on any URL or path (like in an ls or find result!) and it does some useful action: Opens the URL in your browser or file path in your editor, by default, but you can configure that in the profile.

  • Custom Keybindings: Sorta? Doesn't seem complete, no idea if there's UI for it, but it does exist in their config.

    Most terminals can do this, but most can only remap a few actions. I like iTerm2's, as usual, which lets you bind any action, menu, or run a program on any keybinding. I mostly just use it to launch different profiles with starting paths & scripts.

    Terminal.app only lets you send specific text for a key.

  • Images: Sorta? Only if they're embedded in fonts.

    This is a neat trick in iTerm2: images. I use imgls all the time to see a thumbnail of every file with details (protip: I changed ls -ld in the script to ls -1Fskd for a more concise listing), and then ⌘-click to open what I want in Acorn; it's better than opening Finder and trying to read a long filename under a thumbnail.

    I'm unaware of anyone else being able to do this.

Tower of Babble

Programmers almost compulsively make new languages; within just a few years of there being computers, multiple competing languages appeared:

It proliferated from there into millions; probably half of all programmers with 10+ years of experience have written one or more.

I've written several, as scripting systems or toys. I really liked my Minimal script in Hephaestus 1.0, which was like BASIC+LISP, but implemented as it was in Java the performance was shitty and I had better options to replace it. My XML game schemas in GameScroll and Aiee! were half programmer humor, but very usable if you had a good XML editor. Multiple apps have shipped with my tiny lisp interpreter Aspic, despite the fruit company's ban on such things at the time. A Brainfuck/FORTH-like Stream, working-but-incomplete tbasic, and a couple PILOT variants (I think PILOT is hilariously on the border of "almost useful").

Almost every new language is invented as marketing bullshit based on a few Ur-languages:

  • C++: Swift
  • Java: Javascript (sorta), C#, Go
  • Awk: Perl, Python, PHP, Julia
  • C: Rust
  • Smalltalk: Objective-C
  • Prolog: Erlang, Elixir
  • ALGOL: C, Pascal, PL/1, Simula, Smalltalk, Java
  • LISP: Scheme, ML, Haskell, Clojure, Racket
  • BASIC: None, other than more dialects of BASIC.
  • FORTRAN: None in decades, but is the direct ancestor of ALGOL & BASIC.
  • COBOL: None in decades.

A few of these improve on their ancestors in some useful way, often performance is better, but most do nothing new; it's plausible that ALGOL 68 is a better language than any of its descendants, it just has mediocre compiler support these days.

Certainly I've made it clear I think Swift is a major regression, less capable, stable, fast, or even readable than C++, a feat I would've called impossible except as a practical joke a decade ago. When Marzipan comes out, I'll be able to rebuild all my 15 years of Objective-C code and it'll work on 2 platforms. The Swift 1.0 app I wrote and painfully ported to 2.0 is dead as a doornail, and current Swift apps will be uncompilable in 1-2 years; and be lost when Apple abandons Swift.

When I want to move my Scheme code to a new version or any other Scheme, it's pretty simple, I made only a handful of changes other than library importing from MIT Scheme to Chez to Chicken 4 to Chicken 5. When I tested it in Racket (which I won't be using) I had to make a handful of aliases. Probably even CLISP (which is the Swift of LISPs, except it fossilized in 1994) would be 20 or 30 aliases; their broken do iterator would be hard but the rest is just naming.

Javascript is a pernicious Herpes-virus-like infection of browsers and desktops, and nothing can ever kill it, so where it fits the problem, there's no reason not to use it. But there's a lot it doesn't do well.

I was leery of using FreePascal because it has a single implementation (technically Delphi still exists, but it's $X,000 per seat on Windows) and minimal libraries, and in fact when it broke on OS X Mojave, I was disappointed but I-told-you-so.

I'm not saying we should quit making new Brainfuck and LOLCODE things, I don't think it's possible for programmers to stop without radical brain surgery. But when you're evaluating a language for a real-world problem, try moving backwards until you find the oldest and most stable thing that works and will continue to work, not piling more crap into a rickety new framework.

The Biblical reference in the title amuses me, because we know now that it requires no malevolent genocidal war deity scared of us invading Heaven to magically confuse our languages and make us work at cross purposes; anyone who can write and think splinters their thought into a unique language and then argues about it.

Lost Treasure

In 1979, I learned to program in BASIC on a TRS-80 Model I. Sometime in the next year, I read one of my first programming books:

I played Monster Chase and Lost Treasure, modified them extensively, and combined them, so the cave on the island had a monster chase to reach the exit. I recall having problems getting Starship Alpha and Devil's Dungeon to work, but they joined my software library eventually.

One of my earliest and happiest programming memories was sitting at the dining room table, reading Monster Chase, and writing out a smarter movement system and obstacles in a notebook; at the time the only computers were at school, so I wrote code on paper and typed them in later.

So when I found the book again on archive.org last night, I was very excited, and had to reimplement it. I actually typed this into Pythonista on my phone with the PDF open on an iPad, only moved it to the computer to do some final cleanup and upload it.

The book suggests some modifications, and I did some minor ones: Lowered the movement error to 10%, and risk of shark attack to 10%, rising by 1.5x rather than a flat +50% each time; being anywhere near the island edge killed you too often in the original. I also don't move you out of the water automatically, that should cost a turn.

I realized in converting it that I hate, hate, hate Row,Column coordinates instead of Cartesian X,Y; tons of mainframe-era computing resources used Row,Column, and you can still see it in some APIs like Curses. Note that the original program is 74 lines, mine's 214; BASIC is a terrible language, but it's terse.

I could adapt this into another doorgame for my Mystic Dungeon BBS, but I'm not sure what the multiplayer aspect would be, and it has limited replayability without doing some randomization.

Twitterversary

A day that will live in infamy: Twitter emailed me to make sure I knew I joined Twitter 11 years ago today (really?). And then put a banner in front of my notifications (which I still see even if I don't read my timeline), so I said fuck it and hit post, made the swamp a little shittier.

But. 11 years ago, Twitter was really fun. WWDC lunch & event planning, and other nerds finding our weird Objective-C hobby useful and profitable, and all the weird social events which even antisocial nerds would enjoy because it was software-mediated. The normals hadn't really found their way there yet.

At first there was just a little post form on a page, and you had to reload to get updates. Then nice clients came out, like Twitterrific (great for just reading the stream, invented "tweet" and the bird icon, his name is Ollie), Twittelator (great for lists and filtering), and Tweetie (neat UI design, invented pull-to-refresh). And favrd, which was like a leaderboard for funny Twitter.

Then everything started to go wrong. Normals and their predators got on, and humor took a nosedive as thieves stole jokes and reposted memes. Twitter started making their web app usable, and limiting their API, and telling the client devs to go away. Eventually they bought Tweetie and mangled it and then killed it, because everyone at Twitter is too stupid and tasteless to maintain good software.

I've told of the time around App.net and on in Mastodon. I'm still there, generally quite happy with it; there's a bunch of App.net refugees around. I'm kinda sad a bunch of people I like are still on Twitter, there's a hell of a good world out here away from all of that.

Return of the Objective-C Jedi

[[[ These ]]] are your father's square brackets, the weapons of a Jedi Knight.
Not as clumsy or random as C++.
Elegant weapons for a more civilized age.

What's Different in Mulle-ObjC

This is like Objective-C circa 2010(?), good but not fully baked. Far better than circa 1986-2009, when it was a very thin translation layer over C.

  • No ARC (Automatic Reference Counting). This is just invisible sugar to hide retain/release/autorelease, and while ARC's convenient, it's trivial if you actually know how reference counting works. Don't really miss it.
  • No dot property syntax. [[myObj name] length] instead of myObj.name.length, and [myObj setName:newName] instead of myObj.name = newName. I can live with it, but I really did like dot syntax, even if it does "overload" the . operator and hide the distinction between methods and variables.
    • When dot syntax came out, Objective-C nerds came close to fistfights over this. You would not believe the venom some people had for it. Most of those nerds died or quit or got old & tired before fucking Swift came around, I guess.
  • No array syntax. [myList objectAtIndex:i] instead of myList[i]. This is a pain in the ass, I'll have to write some shorthand macros (or rather, go dig them out of my very oldest code).
  • No blocks. This one hurts, but it's a reasonable pick-your-battles decision. Classic: Write a method, dispatch to it, and call back success somehow. Blocks: create a weakSelf reference, enclose it, search-replace self in your block, pick one of a half-dozen complex GCD methods, get a memory leak because you retained something across the block boundary. This is annoying but logically simpler:
    [self performSelectorInBackground:@selector(computeData) withObject:inputData];
    
    - (void)computeData:(id)inputData {
        // create outputData
        [self setOutputData:outputData];
        [[NSNotificationCenter defaultCenter] postNotification:NOTI_DataComputed];
    }
    
  • Has object literals: @42 and @(var) create an NSNumber, @[] creates an NSArray, @{} creates an NSDictionary; dicts use key:value order, not the reverse order used in -[NSDictionary dictionaryWithObjectsAndKeys:], and array and dicts don't need a trailing nil, which was a constant source of mystifying bugs back in the day. Big win!
    • Hmn, crashes if you do something janky like [@[] mutableCopy]: mulle_objc_universe 0x1006adef0 fatal: unknown method 5e1b0403 "-getObjects:range:" in class 7aa0d636 "_MulleObjCEmptyArray"
  • Has for (id x in container) loops, using NSFastEnumeration. The 1.0 process of looping enumerations was awful, so this is very nice.
  • Huh, does have @autoreleasepool, so maybe I should use that instead of NSAutoreleasePool like a caveman? It compiles and seems to work.
  • Properties have properties assign/retain nonatomic/atomic nonnullable readonly, default is assign nonatomic, no "nullable" or "readwrite" flags needed. As it should be.
  • Weird isa define instead of pointer: blog post

TODO

  • I haven't set up an NSRunLoop or the equivalent of NSApplication (which is in AppKit, not Foundation), need to do that and then I'll have a working app template.