Recent comments in /f/explainlikeimfive

John_Vattic t1_iyc8ya7 wrote

Nothing at all makes the French person wrong, if the math adds up. I'm not talking about culture at all, it's just an example, like launching a rocket mentioned earlier in the thread. You seem a little angry, you ok?

To put it another way, forget about the equation. The "required" answer to launch the rocket in the example at the start of this thread is 7, not 9. Could we conceivably write and read math in a different order? Yeah absolutely, but if we write math the same and two people read it differently, then there's too much rocket fuel and it explodes on launch. That's why we have a standard for reading back these equations so that we can all get to the same answer.

5

csandazoltan t1_iyc8rms wrote

It is about setting down some ground rules so everyone arrives to the same solution.

It would be chaos if rules were arbitrary. Just imagine if one computer arrives to different math solution and you suddenly have 20% less money in your account.

It is like this in every field of science, including math, that you need to define the basic rules and frame of reference.

---

There was a NASA debacle, that after 10 months the Mars Climate Orbiter got destroyed. The reason was, that one of the engineers used imperaial measures instead of metric.

---

Things that drive or contribute daily lives should have one possible right answer, ambiguity leads to issues and errors

1

Kalirren t1_iyc8k40 wrote

The real reason why we do this is so that we can write DISTRIBUTION neatly.

(4+5)*6 = 4*6 + 5*6

See how I didn't have to write the right side of that with any parentheses at all?

If we had pure left-to-right order of operations, I'd have had to write

(4+5)*6 = (4*6) + (5*6)

which is much uglier.

Note also that * distributes over +, but + doesn't distribute over *:

4+(5*6) != (4+5) * (4+6)

So there's no advantage of less parentheses in assuming that + should be the first operation you perform.

Similarly, exponentiation distributes over multiplication. That's why the usual order of operations is PEMA:

P (exceptions before general rules)

E (^ distributes over *)

M (* distributes over +)

A

1

Ravingrook t1_iyc8gwl wrote

Unless you're peeing on yourself after you've already washed, it's not. Your toilet and shower drains both go to the same place, and flushing the toilet wastes more water than just rinsing it down with water you've already used to wash with.

28

Whyistheplatypus t1_iyc854z wrote

The same reason we write sentences the way we do. Arbitrary tradition seeking to remove ambiguity while also conveying information with as little effort as possible.

"Put the cookies in the box on the counter" can mean, "put the cookies into the box which is currently on the counter", or it can mean, "put the cookies which are currently in the box on to the counter". So we rely on context clues to give us the correct interpretation. Because maths can exist in a bit of a context less void, the correct way to write an equation removes any ambiguity, but failing that, we rely on the most accepted context, which in this case is the order of operations.

1

dosadiexperiment t1_iyc7bxz wrote

It's what you tell beginners to keep them from making too much of an unmaintainable spaghetti mess, which is what people will generally end up with if they think of it as a general-use tool in their toolbox, instead of merely for a few specific narrow situations. But it's not quite as absolute as it's usually presented.

The Linux kernel uses gotos in a structured way that's helpful. (If you're using C++, you should probably instead use RAII to do what they're doing, but in C careful use of goto can be worthwhile to get a similar effect.)

Some would claim breaking out of multiple levels of nested loops also is a good use case, and produces code that's easier to read than trying to chain breaks through multiple loops. Common wisdom is you're better off putting your loops in a function and using 'return' when you need this, but it's a debatable point when goto is in the language.

5

DTux5249 t1_iyc6i19 wrote

The issue is that "goto" plops you somewhere in the program, but with little to no way back.

Programming practice likes consistency, and linear flow. Every line is an instruction, and should be followed in sequence.

Even if I have to say, call a method from somewhere else in the code, I'm still sitting in the same place. I can leave where I am, go do whatever, then come back and continue where I left off. Clean.

"Goto" though? I could've jumped 5 lines ahead, or 269, and I have no way back. It's obscenely reckless in large programs, making them an absolute pain to edit, and it's just lazy in smaller programs.

1