The M4 can be a great gun if you use it properly. Many people think of it as a bad starter weapon. If you add the right attachments, it completely eliminates recoil. It can be used for long, medium, and close ranges, and is just a great overall gun.
My recommended attachments are green laser, angled grip, and muzzle brake. I recommend using a medium magnification scope, like the C79. All of the above attachments make recoil non-existent for the M4, and allow you to use it at longer ranges. In close range you will want to hipfire, but in medium and long ranges, scope in.
Because it is burst fire, people tend to spam-click. If you properly burst fire, you can make the M4 fire like an automatic. When you get burst firing down, the M4 has an extremely fast fire rate of 950 RPM (Rounds Per Minute). Unlike with the AS VAL, it is fast and extremely easy to control. The iron sights can be hard to use, but are still good.
A way to use the burst fire at any range is to spam-click, and it acts in a similar way to automatic. Combine this with its great time to kill, you have a killing machine at any range.
Another way to use the burst fire at close range is to click & hold your mouse button, it might be slightly harder than spam-click but its more effective to save some ammo, thanks to its damage that can 3 hit kill at close range, you can click & hold your mouse 1 time and make sure all your shots hit the enemy.