You don’t even need an Apple account to use one. Unlike Windows.
Yes, there's a fee to get access to the App Store, but almost nobody on the Mac uses the App Store... the fee is mainly for putting stuff on iOS (and likely watchOS, tvOS).
The fee also gets you the absolute latest Xcode, but go back one version, and it's entirely free.
On Mac, you can install brew, and use it to install gcc, clang, qemu, whatever utilities you want.
You used to need the developer fee to put stuff on your iOS device at all, but these days you can put stuff on your personal devices without a fee, but the binary expires in a week... enough to learn and debug, but not ideal for a personal tool. That's about the only annoyance where the fee comes up... long term deployment to iOS.
For distributing your program without the fee, you'll probably moan about the hoops that people have to jump through to run your stuff: https://support.apple.com/en-gb/guide/mac-help/mh40616/mac - and I can't say I love this myself, but people can run your stuff, and no fee necessary.
(I've got a couple of (somewhat niche) FOSS things for macOS, and I build the releases using GitHub Actions with whatever default stuff the thing uses, then make up DMGs that people can download from the GitHub releases page. I added a bit in the documentation about visiting the security dialog if you're blocked - and that seems to have been sufficient.)