Macbook M2 Pro vs Macbook Pro M4

I'm thinking about getting my first macbook. I don't need it for video editing or related stuff, just for programming (DevOps, Data Science, a bit of ML).

The thing is, at least in my country, both the M2 Pro and Pro M4 cost the same, and I don't know which one to choose.

I was also thinking about buying a used M2 Pro for $1,000 less and maybe with the extra buy a Mac Mini M4.

What would you recommend me? Go for the base M4 or buy a used M2 Pro for $1,000 less (in the case of a used one)? I don't know if the M4 is worth the extra $1000