When or why would someone use a programming language (Swift, Java, C++, Rust etc…) over an engine like Unity?

You need to write a game without an engine when you have a game with very unique technical challenges which are not sufficiently covered by general-purpose game engines.

General purpose game engines like Unreal, Unity or Godot are optimized for running any kind of game people can come up with. But a one-size-fits-all solution often has problems with handling unusual edge cases. When your game is such an unusual edge case, then you might have to create your own engine in order to perform the low-level optimizations you need in order to run your game with satisfying performance.

A couple games which would not have been possible (or at least very difficult) with a general purpose game engine are:

  • Minecraft, with its millions of blocks in a single scene. Which runs so well on low-budget hardware due to the simplistic graphics and well-chosen data-structures.
  • Factorio, which does a lot of micro- and macro-optimization to make sure it can process a huge amount of entities (their development block is a treasure trove of interesting programming tricks).
  • Flappy Bird. Yes, I am serious. What, you say you could do that in your favorite game engine in a couple hours? Sure, but could you squeeze it into an APK of under a MB? Game engines tend to add runtimes which are several MB in size to every game. Which hardly matters for a large project but seems pretty excessive for a tiny one. Filesize is also an important factor for web-based games, where every additional second of loading time will cause you to lose a couple players.

However, game engines do keep developing and become able to cover more specialized use-cases they couldn’t before. Like Unity’s DOTS initiative which allows to create games which require highly optimized game systems and its scriptable render pipelines which can be used to optimize for unusual render performance requirements.