I happily develop (Ruby on Rails mostly) on a 16 GB RAM machine with memory to spare, so unless you do some really heavy stuff (which I think you’d know) you’ll be fine with 24 GB. The M2 will be significantly faster than your Pro, like really noticeably faster. The screen is the one thing I’d be worried about, unless you have a good eyesight or have an external monitor, 13” can feel a bit cramped, especially for big IDEs.
I don’t mind working on my Air for a few days when visiting the family, but I do miss my 4K screen at home, and I usually limit my contributions to smaller stuff that doesn’t need that much awareness and many changes in many files at once.