tl;dr Assembly early on, C later on, C++ recently
Since the 2020 Nintendo leaks (most of which I've seen personally), a good amount of this information has been known for certain. I will summarise it here alongside some technical/historical info (which goes 90% of the way to answering this question on its own, short of the absolute certainty that source code offers).
RBY and GSC are written in assembly language. This comes more or less as a necessity -- the Game Boy has very basic hardware where low-level access to memory (in particular, CPU registers) is required to program the console effectively. There would've been C compilers out there writing instructions for the Game Boy CPU, but those would've been worse in the '90s and come with drawbacks, as described by the Game Boy development community:
[C compilers] won't always generate code that runs as fast as skilled, hand-optimized assembly. ... There is overhead due to C being a stack-oriented language, whereas the Game Boy's CPU is rather built for a register-oriented strategy.
If the above is interesting to you, check out the GBDev community's Pan Docs. Here is a guide to Game Boy opcodes (instructions that its CPU understands). There are also disassembly projects for Pokemon Red and Pokemon Crystal, which are generally reflective of the source code and assemble back into working ROMs that you can play on an emulator (for example).
RSE, FRLG, DPPt, and HGSS are written in C (and BW/BW2 likely were as well). This is a higher-level language that compiles down to assembly language, hiding from programmers the ugly aspects of assembly language. The GBA and DS feature less constrained hardware that doesn't care as much about the mild inefficiencies of compiled languages. According to this guide, Nintendo released development kits with libraries and compilers aimed toward C (which, along with C++, dominated game development on handhelds).
Source code for all of the above games except HGSS has leaked, which confirms what we would suspect based on the information above. We also know from the leaks that Game Freak used Ruby and Perl for tools/scripting during development of these games, and that assembly was still used for some purposes (move animations and logic, which surprised me). BW and BW2 have not leaked, but it's basically certain they were written using C or C++ or both.
Decompilation projects exist for Pokemon Emerald and Pokemon FireRed (as well as other games, including Gen 4, though considerably less progress has been made for those). Decompilation is less scientific than the disassemblies of Gen 1/2 games above, as C is yet another layer of abstraction above the binary ROM (but as usual, you can build the code in these repositories back into the real game).
SM and USUM are written in C++ (and XY/ORAS almost certainly were as well). C++ interfaces with hardware similarly to C (which is good, as the 3DS is not a resource-abundant system) but it belongs to the object-oriented programming paradigm, which has become popular in proprietary software development in recent decades.
From the leaks, we know that SM and USUM are built with an in-house game engine called gflib
("Game Freak library"), which is written in C++. Source code for XY and ORAS hasn't leaked (and I haven't seen the SM leak), but nevertheless, I can confidently speculate that those games were built with C++ and gflib
as well. People who know more than I do actually say gflib
is still being used as recently as Gen 8, so loop Sw/Sh in with C++ as well.
The only exception to the above is BD/SP, which was famously outsourced to a different developer and made in Unity, which is a game engine anybody can use. Unity's runtime is C++, but its API (which is what developers actually use) is made available through C#. Unity games are really easy to reverse engineer; here's a fun video about that if you're interested.