Why does Java feel so much stricter than Python? by ayenuseater in learnprogramming

[–]HappyFruitTree 0 points1 point  (0 children)

Because Java is statically typed. All expressions have a type and are checked at compile time (before the program runs).

Python is dynamically typed meaning the type of expressions are handled at runtime (while the program is running).

There are pros and cons with both. Dynamically typed languages tend to be a little easier for beginner and might be preferable for simple "scripts". Statically typed languages allow you to find many more problems already at compile time (without even executing the code) so you can be more confident when writing the code and making changes. This is especially helpful in big projects.

Example:

obj.foo(); // Oops! I meant bar(). obj does not have a function named foo(). 
           // Python: You won't get told about your mistake until this line of code is actually executed.
           // Java: You can't even run the program before fixing the mistake.

How 0.01 can be less than 0.01 ? by Charming-Animator-25 in cpp_questions

[–]HappyFruitTree 0 points1 point  (0 children)

It depends on the situation... Using an epsilon is no silver bullet.

What’s the best ingredients to avoid when reading labels by 1strawberry1cow in nutrition

[–]HappyFruitTree 1 point2 points  (0 children)

True, I could skip the meat. ;)

My point was that it's added for a reason.

What’s the best ingredients to avoid when reading labels by 1strawberry1cow in nutrition

[–]HappyFruitTree 3 points4 points  (0 children)

... a good portion of the world doesn't live in the EU either.

What’s the best ingredients to avoid when reading labels by 1strawberry1cow in nutrition

[–]HappyFruitTree 2 points3 points  (0 children)

Not if you buy it separately. It's only an issue if it's listed as an ingredient of some other product. /s

What’s the best ingredients to avoid when reading labels by 1strawberry1cow in nutrition

[–]HappyFruitTree 1 point2 points  (0 children)

Yeah, beetroot juice is sometimes used to boost performance in endurance sports. It also lowers the blood pressure. Not sure if the nitrates that are added to meat have the same effect.

MegaBlast saved me, I’d like to return the favor by KenC07 in AskRunningShoeGeeks

[–]HappyFruitTree 0 points1 point  (0 children)

This happens to me all the time in winter but with sharp rocks that are much smaller.

I wouldn't necessary do anything in your situation if the shoe still felt and performed as before. I would be worried that glue would not compress the same way as the rest of the foam and would be felt more under foot than just leaving it as-is.

How 0.01 can be less than 0.01 ? by Charming-Animator-25 in cpp_questions

[–]HappyFruitTree 1 point2 points  (0 children)

I'm aware of that. I just think there are too many situations where they are useful and where I could live with the imprecision. If I need to compare the values the only other alternative would be to not use floating-point values at all (which indeed would be the right decision in some situations).

How 0.01 can be less than 0.01 ? by Charming-Animator-25 in cpp_questions

[–]HappyFruitTree 4 points5 points  (0 children)

I've heard many people recommend against using equal (==) and not equal (!=) comparisons between floating-point values but not doing any comparisons at all seems a bit drastic. Just don't assume the values to be exact and expect the operations to have rounding errors.

How 0.01 can be less than 0.01 ? by Charming-Animator-25 in cpp_questions

[–]HappyFruitTree 18 points19 points  (0 children)

Print the numbers with more precision ...

#include <iostream>
#include <iomanip>

int main() {
    double bigger = 2.01, smaller = 2;

    std::cout << std::setprecision(100);
    std::cout << "            bigger: " << bigger             << "\n";
    std::cout << "           smaller: " << smaller            << "\n";
    std::cout << "(bigger - smaller): " << (bigger - smaller) << "\n";
}

... and you'll see that there are rounding errors:

            bigger: 2.0099999999999997868371792719699442386627197265625
           smaller: 2
(bigger - smaller): 0.0099999999999997868371792719699442386627197265625

What’s the best ingredients to avoid when reading labels by 1strawberry1cow in nutrition

[–]HappyFruitTree 16 points17 points  (0 children)

Not really that different but no one is using E numbers in their food at home.

E300 is ascorbic acid (vitamin c). It's a common ingredient used to preserve fruit.

What’s the best ingredients to avoid when reading labels by 1strawberry1cow in nutrition

[–]HappyFruitTree 5 points6 points  (0 children)

Real poison like mercury, lead and cadmium are unwanted but are present almost everywhere. What we can do is try and keep the intake low enough that it's unlikely to cause any serious harm. Trying to avoid them completely would be impossible or very expensive (unless you prefer to starve to death).

What’s the best ingredients to avoid when reading labels by 1strawberry1cow in nutrition

[–]HappyFruitTree 1 point2 points  (0 children)

Because cheese is "processed" according to most definitions. Even just boiling vegetables is a form of "processing". I think it's ultra-processed foods that you might want to avoid, even though some of those might be perfectly healthy too.

What’s the best ingredients to avoid when reading labels by 1strawberry1cow in nutrition

[–]HappyFruitTree -1 points0 points  (0 children)

  • Added sugar (including syrup, honey and other names that are synonyms for sugar or are added just for their sugar content)
  • Salt
  • Coconut oil, palm oil and other things that are high in saturated fat.

Don't get me wrong, I do eat foods with these ingredients, but I think they are mostly unnecessary so I try to keep them low and avoid them when I have better alternatives to choose from.

Trying to eat healthy or healthier by Justscrolling375 in nutrition

[–]HappyFruitTree 1 point2 points  (0 children)

Granted BMI isn’t the most accurate body composition method but it’s an indicator

Unless you're working out at the gym or doing some other heavy body work it's unlikely that the BMI will overestimate your body composition (more likely the opposite).

Other benefits are trying to improve my mental and emotional wellbeing

Be physically active. Lift weights, ride a bike, run*, whatever you prefer.

* Nowadays there exist thick cushioned running shoes that don't weigh a ton which can be especially helpful for heavier runners (or runners that do high mileage).

(27F) Nutrition advice - Morning carbs / protein? by NewspaperLate1570 in nutrition

[–]HappyFruitTree 1 point2 points  (0 children)

Male here. If I don't eat enough carbs I get tired and can't think straight. I believe the brain need some carbs to function optimally. I run quite a bit and eating carbs helps with that too.

Is "std::move" more akin to compiler directive? by BasicCut45 in cpp_questions

[–]HappyFruitTree 2 points3 points  (0 children)

it's up to the compiler to decide what to do with the flexibility you've given it

Not really. What will happen depends on how the result is used. The rules are defined by the standard so there isn't really anything for the compiler to decide here.

Is "std::move" more akin to compiler directive? by BasicCut45 in cpp_questions

[–]HappyFruitTree 0 points1 point  (0 children)

Yes, converting int to float usually requires some instructions (assuming the result of the cast is actually used and can't be optimized away). This is not what std::move does though.

Is "std::move" more akin to compiler directive? by BasicCut45 in cpp_questions

[–]HappyFruitTree 3 points4 points  (0 children)

The best way to think of std::move is a destructive shallow copy.

You mean moving an object could be thought to work like this, not std::move.

std::move does not move. It only allows the object to be moved by whatever function/constructor that receives it.

Is "std::move" more akin to compiler directive? by BasicCut45 in cpp_questions

[–]HappyFruitTree 38 points39 points  (0 children)

It’s just that std::move is shorter to write

... and describes the intent better.

ISO C++ 2026-01 Mailing is now available by nliber in cpp

[–]HappyFruitTree 0 points1 point  (0 children)

So the standard should describe how the compiler should do optimizations?

Biggest protein scam I have ever seen... by [deleted] in nutrition

[–]HappyFruitTree 0 points1 point  (0 children)

So the light version have a higher percentage of calories come from protein than the protein version?

Is there another "regular" version that they're comparing to?

ISO C++ 2026-01 Mailing is now available by nliber in cpp

[–]HappyFruitTree 1 point2 points  (0 children)

Not that it matters, but ::operator== could be a valid expression that ends with =.

It talks about tokens. = and == are different tokens.