New app! A compass that points to the centre of the galaxy

18.34, Thursday 15 Feb 2024

Hey I made an app! It’s a green floating arrow that always points to the middle of the Milky Way.

i.e. 26,000 light years towards the supermassive central black hole, Sagittarius A*.

You can have it too!

Download Galactic Compass from the App Store.

BUT: I don’t know how to write apps.

And yet here we are!

Let me explain.

Cultivating a sense of the galactic centre

It’s remarkably grounding?

Once upon a time I trained myself to always know where to look, and the centre of the galaxy moves of course over the day and the year: So I would end up pointing through the pavement, or down a street, and thinking, huh, that’s where it is.

It is a worthwhile super-sense:

Eventually then I had this picture of myself, and the Earth, and the solar system, and the centre of the galaxy which had initially been whirling round me, and now it had flipped, I was turning around it.

It was wildly situating.

I’ve lost the intuition now, sadly.

The above description is from my 2021 writeup which I conclude by saying:

In my imagination I see an iPhone app which displays a 3D model, connected to the gyroscope and the compass and the GPS. …

But there are slightly too many things I would need to learn

So I couldn’t build it.

EXCEPT.

Now there is ChatGPT.


Developing an app with ChatGPT

I can’t write Swift (the language used to code iOS apps).

But what I am able to do is break up large problems into smaller, expressible problems, and then sequence them.

I’ll be detailed about this. When I’ve walking folks through this, they’re often interested so it is (perhaps) non-obvious?

If you’re not interested in the detail, skip to the next section.

I started by installing Xcode and setting up a git repo. I know how to do that. (GitHub Copilot doesn’t work in Xcode by the way.)

To get going, I said to ChatGPT 4 something like:

  • I’m building an iPhone app using SwiftUI. I have installed Xcode version X. Please walk me through creating a new iOS app with a single screen. The screen should be blank except for a line of text in the middle that says “Hello, World!”

Then I followed the instructions.

There was lots of interaction like: okay I’ve done step 1. I’m on step 2 but I can’t see the X, or I have the error Y, what should I do?

I know, from other coding, that I want to have my build working as early as possible.

My next question to ChatGPT was something like:

  • Now I want to see my development app running on my phone as I work. Please walk me through that.

Ok, now I’ve got a setup which means I can develop and I can test.

Now putting together the app itself is not about describing the overall app. I don’t want ChatGPT to be overfaced.

I worked in steps at this kind of resolution, making sure each step was complete before moving to the next:

  • Okay now add two tabs at the bottom. The tabs are called Compass and Debug. Each has an icon. The first tab show should the Hello World screen, and the second tab should have the word “Debug” in the middle
  • We’ll work on the Debug screen. Add a section of text rows that simply say A, B, and C. Use standard iOS components. Ok, now add a label at the top. Make the text smaller. Make it capitalised.
  • Add two rows, latitude and longitude, based on the device location. Add the device heading.
  • Track the device motion and add rows for pitch, roll, and yaw.

The workflow consisted of me copy and pasting code from ChatGPT into Xcode. When there were errors, I would paste the error text into chat and say “this error appears on the line about such-and-such,” and work with it on corrections.

Often I would start each stage by saying to ChatGPT: ok here’s the current code, and then paste in the entire ContentView file.

The generated code is not obscure to me. I’m not asking ChatGPT for huge goals with multiple steps and pasting in code unseen – that wouldn’t work. The experience is more like very, very good autocomplete, or very, very good spellcheck: I can understand the output even if I couldn’t get there on my own.

Next I found a Swift-compatible library to translate between galactic coordinates and relative coordinates. (Ultimately I need altitude and azimuth, a way of pointing at a position in the sky, based on the current time and location.) I’m using SwiftAA.

  • I’m using SwiftAA. Please make a new Swift object that takes the current date and device location, and provides the azimuth and altitude of the galactic centre (I looked up the coordinates of the central black hole as a proxy)
  • Using the new GalacticCenter object, display azimuth and altitude in a new section on the debug screen.

I retained the Debug tab in the shipped app so you can see.

So that’s all the astronomical stuff done.

You never want to give ChatGPT big goals where it has to figure out the way on its own. Then both of you will be confused. Intermediate stepping stones and being sure of your boots with each stride, that’s the way.

Now we build the rotating arrow:

  • Ok now we’re on the Compass screen. Make a SceneKit view with a cube in the middle over the whole screen
  • (There was a whole lot of back and forth here to fix scrolling issues, ensuring the tabs were tappable, positioning some text over the bottom, and so on.)
  • Now let’s make a green arrow from an extruded rectangle and squashed pyramid. The arrow should point to the top of the screen
  • Break out the data from the Debug screen into a separate object so both tabs can use it
  • Assuming the phone is lying flat. Make the arrow point north
  • Rotate the arrow in 3D in real-time in response to the device orientation so that it always points north
  • Instead of pointing north, point the arrow at the altitude and azimuth of the galactic centre

This now became pretty tricky because I had to learn about how to combine rotations. I barely know anything about quaternions, so there was a bunch to learn here.

ChatGPT, being a large language model but lacking embodiment, is awful at 3D maths and reference frames.

Finally I…

  • Asked ChatGPT to walk me through the process of building the app using Xcode Cloud and distributing it on TestFlight
  • Shared the test app with friends to ask for their help with rotations.

Galactic Compass is still pretty janky, to be sure.

But it ain’t bad for a collaboration between someone who can’t build apps and an AI that is barely a year old.


“An app can be a home-cooked meal”

Ethan Mollick and a team of social scientists studied a group of management consultants using AI.

The headline is that, yes, AI results in better work.

The fascinating buried result is that the biggest effect is felt by the bottom-half skilled participants.

i.e. if you’re sub-skilled then you can use AI to drag you up to median.

Now, none of us have just one skill. Like most people, I have a mix.

But now I’m a reasonable engineer, an amateur designer, an ok systems thinker, ok at having ideas, and now a midwit everything when it comes to all the actual skilled tasks.

And the combination means I can bring ideas to life that simply wouldn’t be possible if I had to persuade a designer or engineer buddy to help me out. Being able to bring ideas to life means I can scaffold up to other ideas… and others…

Like this galactic compass.

Back in 2020, Robin Sloan said that an app can be a home-cooked meal. It’s such a memorable perspective, and what we should aspire to from our software.

Now I’ve cooked a meal that anyone with an iPhone can download. Probably only a couple dozen people will want it, but I want it in my pocket, and I want to share it with my friends, and here we are.

And I can’t even cook!

But I know where the centre of the galaxy is, even so.


Galactic Compass links

Download from the App Store.

Project page on Acts Not Facts.


Update 16 Feb. Huh this did numbers! My post on X/Twitter currently has 7.2K likes and 1.3M views 12K likes and 6.1M views. A post that quotes mine has 35K likes 161K likes! Whoa.

Here’s a lovely post on BoingBoing in which Mark Frauenfelder includes a photo of Galactic Compass with his cat.

My post on Hacker News kicked off a brilliant, friendly conversation (150 points, 57 comments): Show HN: Galactic Compass.

I’m glad y’all like it. Thank you.

Two additional asks while you’re here:

  • Do you work in a museum? I’d love to make an installation of Galactic Compass. Get in touch.
  • Another of my projects is Poem/1, a clock that tells the time with a unique ChatGPT-composed poem every minute, every day. It’s live on Kickstarter, you could get involved? There are just a few days remaining.

Ad astra!

If you enjoyed this post, please consider sharing it by email or on social media. Here’s the link. Thanks, —Matt.