The difference between IR sensor and ultrasonic sensor:
IR sensor, Infra-Red sensor, whose circuit is simple; However, it is heavily influenced by light and ranging unavailable;
Ultrasonic sensor: Stable, ranging available and little influenced by light; However, it’s expensive and it’s impossible to use wildely due to its price;
BTW, generally, the ultrasonic module ranging is as far as 4-5 meters.