This question has a simple answer:
You can develop apps for web or Android on Mac, but you cannot develop apps for iOS on Windows.
Yes; there are some emulators that allow you to use MacOS on Windows, but it is almost impossible to install and run Xcode (the software for creating iOS apps) on those, as they are slow and primitive.
Yes; using Flutter on Windows, you can develop apps for iOS, Android, and web at the same time – as we mentioned earlier. But if your goal is to write a native application, i.e. specific to the operating system, you have to choose Mac.
So, if you're one of 1.6 billion Windows users around the world, whether your enthusiasm for learning programming will cost you a MacBook will be determined by whether you want to develop an iOS app.
I started using computer at the age of 13, and throughout the next 20 years, I didn't touch any operating system other than Windows. During the period of Apple's increasing popularity, I have always been prejudiced and antagonistic towards the brand – known issues: Imposing their own accessories and connection types, relentless monopoly efforts, excessively high pricing, snobbish attitudes...
As I started learning to code in 2017, I bought my first Mac (a used 2012 MacBook Pro 15") and iPhone (first generation SE) for the reasons mentioned above. I always kept and continued to use my old computer (2015 HP Spectre x360) for almost all my needs except for coding.
Then, at the end of 2019, I upgraded to a brand new MacBook Pro. Today, I only open the lid of my laptop when I need the HDMI output, and I only use Android to test my apps.
Great Macs think alike
As you have noticed, I already put on my jersey and started cheering.
The only product that I know of other than Windows, which is so widely used and so much worse than its rivals, is Seat Leon mk3.
When it comes to hardware, there are PCs that come very close to the workmanship and material quality of Macs. But when it comes to software, the advantages of MacOS over Windows are endless – subject of another article. As a software engineer, whenever I have to turn on my notebook now, I'm tearing my hair out about everything except the boot time, and I'm surprised that such a mediocre operating system has spread so much.
When it comes to games, Windows has an undeniable optimization and performance advantage. The only way to get around this on a Mac is to get at least a 2019 MacBook Pro with Radeon Pro Vega and install Windows on it. But even then, you will struggle to hit 60+ FPS in latest games and you will have to pay a very steep price for that.
Android vs. iOS
We've gotten off topic, but for those wondering about my opinion: I don't think there is a similar advantage between these two. Even though I personally prefer iOS, there are Android phones in the market that I would gladly use if I hadn't become so dependent on the Apple ecosystem.
So, which one?
If you've finally decided to buy a Mac to code, the most important question is what year, model, and hardware you need.
Let's start by stating that, in general, Apple products are much longer lasting and backward compatible than their counterparts, in terms of both hardware and software. That's good news, because you won't necessarily have to buy a brand new Mac (and sell your kidney).
Roughly, a 5-year-old MacBook Pro or 2-3-year-old Air will do. You don't need to ponder on each component; just don't go for less than 8GB of RAM. Based on age and, of course, price, you'll notice two main differences between the devices you might buy: Compile time (the time it takes until the simulator starts up so you can experience how the changes you've made to your code actually look and work) and battery life.
You don't have to worry about the first one, especially when you've just begun learning to program (we are not talking about hours anyway, you will wait 1-2 minutes at most). But the second issue is a bit tricky.
Achilles' heel of Macs
The battery of every electronic device degrades over time. But the trouble with Macs is a little different.
The energy required to compile a complex code is much higher than standard media consumption. The same is true for video rendering: These types of operations drain your computer's battery super fast.
A 5-year-old MacBook Pro will last around 1-1.5 hours in regular use, depending on its battery cycle count. When it comes to programming, forget about these numbers. Or rather, forget about hitting the compile button without plugging that Mac in.
But the real problem is that your Mac, which still shows close to 50 percent battery left, might suddenly shut down when you click 'compile'.
Even if it doesn't, it shouldn't surprise you if that '50%' icon turns into '5%' all of a sudden. That's why you have to keep your device pugged in to power while compiling with almost all Macs except the latest ones.
Fortunately, MacOS has a highly successful automatic data-saving system that cures 'saving anxiety'. In other words, in a scenario like the one above, your efforts won't get wasted; once you plug in your Mac, you can continue writing your code exactly where you left off.
Do I need an iPhone?
As exciting as it is to really see how your app works on a phone, Xcode can simulate almost any iPhone model and lets you test your app on different screen sizes. So if your budget is limited, no, you can write and publish an iOS app without buying an iPhone.
Likewise, if you are an Apple user and want to develop apps for Android, you can preview your app without a physical device thanks to simulators. However, it is worth noting that Android Studio's simulators can occasionally give slightly different and inconsistent results. In any case, it's a good practice to connect your computer to an Android phone before going live.