Which OS is faster for my iMac Early 2009? I just got a new iMac Early 2009. It's running Mac OS X 10.6.8. I was wondering which Mac OS X version it would be faster to run on since it cannot run the latest macOS. As a developer that is new to Mac, I want something that will be fast and compatible with my current hardware situation &amp; Development Tools. I was thinking Yosemite 10.10 or Mavericks 10.9. Any suggestions on what I should do?

Specs:

Intel Core 2 Duo running on 2.66 GHz.

2Gb of RAM

Model Identifier is "iMac9,1"

If you need anymore specs just let me know.
I'm was sorely rempted to -1 your question and then comment, but the comment grew long. You're just trying to make the most of what you have and asking for advice so that's a +1 now.

Unless you define what "fast" is - it's hard for this not to be entirely speculative. Worse, when you define fast - then you make it very narrow and less useful. 

The OS doesn't really change your CPU and your memory speeds. It doesn't change your filesystem and since you can't run High Sierra and APFS - you're stuck on HFS+ for that Mac.

About the best thing that can come of this "let's get an answer on which is faster - 10.11 or 10.12 or 10.10" is the suggestion to partition your drive and test each OS to your needs and then make your call. 

The downside is you'll likely lose so much more time doing the measuring than just installing the latest OS that runs and then look to optimize what your bottleneck is when you reach them. Another downside would be if someone saw "10.12 is slow" and it discourage them from upgrading when for them it would be faster and/or more secure and no more slow.

I'd say - make a good backup, and then upgrade to the latest OS you can. Old software and not keeping your drive clean from needless files is likely to be far slower than whatever marginal difference you could ever measure on OS versions.

The upside of this is you'll have learned some skills on measuring performance and thinking about the end goal "swift and Xcode" and then can make decisions like - should I spend $$ on RAM and SSD or find a used Mac with those that is more economical than upgrading a core2 duo machine.