Molecularly speaking, they are the same. The foods like carrots, beets, sweet potatoes, squash, peas contain “Natural” sucrose in them (fructose+glucose) are the health outcomes the same or the sugar in isolation is more harmful? And is sucrose in food harmful or beneficial in some way?
Sugar isn’t “bad” for a metabolically normal person (eg not diabetic) who is eating in energy balance and getting all their micronutrient needs met. The problem with sugar is that it is high calorie, low micronutrient, and often hard to eat in moderation. If you’re not terribly active and don’t have a whole lot of muscle tissue and therefore require less daily energy, it’s hard to stay within your energy budget, get all the required micronutrients and still have leftover calories for sugar. But if you’re very active and need energy quickly (say halftime of a game or while running a marathon) sugar can be a great fuel. Often athletes will choose gummy candies for this reason.
If you’re insulin resistant or diabetic then it’s a different story and you should try to only eat your sugars in the context of whole foods where the fibre, protein, and fats in the foods show down the absorption of glucose into the blood.
Too tired to post links but….
Sugars found in whole foods are generally good for you (carrots, beets, sweet potatoes, and peas are literally some of the best things you can eat) because they are paired with fiber and a host of other nutrients. In addition, the amount of sugar you get in any one food is usually quite small. That being said, some whole foods are very close to pure sugar (grapes) so they may cause issue if you have an underlying condition (diabetes, for example).
Sugars in isolation, from any sources, are less good for you because they cause a rapid physiological response and don’t have all the fiber and nutrients a whole food has. That being said, some percentage of the population can eat (quite a lot of) sugar and see no real negative impact.
TLDR….sugar is sugar, but it’s the whole food aspect that moderates and supports sugar being used effectively by the body.
I suggest you to look into brown sugar , because i think that’s the best available replacement of the sugar since it comes with additional benefits such as higer minerals. But if you are asking in terms of “calories “ , any type of sugar has approximately same 3-4cal per gm.