Both are equally good if you know how and when to use them. Experienced and beginner lifters can both get great benefits out of it.
In fact, machines might be the best choice for starters since coordination is often the first issue with beginners so machines, follow a strict range of motion without the risk of possible injuries due to faulty techniques.
This same range of motion can also be a problem. No one is the same. Limbs length can often be a problem when going on specific machines, which could be a problem for shorter or taller individuals.
Once a good strength base is established, moving on to free weights and barbells is the next step for the beginner.
As you gain experience, machines could be great tools for supplemental work. After a great workout, when the nervous system is under fatigue, there is always a greater chance of getting injured. This is when the use of machines can be included in the program at the end, as a finisher for a given body part or when you want to work a specific range of the strength curve.