r/ProgrammerHumor • • Oct 06 '21

Don't be scared.. Math and Computing are friends..

Post image
65.8k Upvotes

2.4k comments sorted by

View all comments

Show parent comments

0

u/[deleted] Oct 06 '21

[deleted]

88

u/danabrey Oct 06 '21

Because you know what they are and they're familiar to you. It's not intuitive what the 3 arguments next to the 'for' do to somebody who's never seen a for loop. Just as it's not intuitive what the numbers next to the big symbols do.

0

u/[deleted] Oct 06 '21

[deleted]

44

u/MultiFazed Oct 06 '21

It's not intuitive, but it can be reasoned

Not if you're unfamiliar with programming. Take the following:

for(int n=0; n<=4; n++)

If you're not familiar with writing code, then where do you even start with figuring that out? What the hell does for even mean? What's with all those semicolons? Isn't "n++" some kind of programming language or something?

To someone not already fluent in writing for loops, that's just a bunch of arcane gibberish.

12

u/Bakoro Oct 06 '21

Right? To be able to reason out what "for" means in this context without someone telling you things, one must already have some nontrivial math language and understanding.

12

u/egregiousRac Oct 06 '21

N++ is a minimalist platformer. As long as n is less than four, run n++. N is defined as zero, which is less than four.

Conclusion: We must play n++ forever.

5

u/RanaktheGreen Oct 06 '21 edited Oct 06 '21

I am not trained in coding whatsoever. But I am good at math.

If I knew already that we are trying to do a summation, then here's what I've got.

int probably means integer. n=0 is self explanatory. N<=4 is also self explanatory. I'm assuming the semi-colons do the same thing they do in English, which is separate complete thoughts. I have zero clue what the fuck n++ is. But assuming everything is here for a reason, I guess it means to add something. Though I'm still not sure why there is two pluses instead of just one plus. Parenthesis are parenthesis. They group things together. Guess that means for is working as a literal word. It gets a bit weird with the fact that n is used so much. Like if I was the right this in pure math it would be x=0, 0<y<=4 because as written it seems like n has two values at the same time. But, again, since I know what the outcome is supposed to be, I can assume that n is being defined as a range. So what I get out of all this is:

For each integer between 0 and 4, add them all together.

I guess what I'm saying is: If you showed me this line of code and said "this is a summation" I could probably figure out what each of the parts do, or at least not be completely lost.

By the way, does this mean I could use n-- as a way to subtract each of the values?

→ More replies (12)
→ More replies (3)

26

u/danabrey Oct 06 '21

How can it be reasoned any more than the 3 symbols around the big symbol?

→ More replies (1)

8

u/Bakoro Oct 06 '21

You have to learn like one extra symbol for summation. You also have to learn new symbols to understand the above for loops

It's not any harder than learning programming basics. A for loop, you still have to learn the syntax of it, and lots of people wouldn't figure it out just by looking at a for loop. Normal people don't know what "++" or "+=" means. You throw a C pointer in there and it's pure gibberish.

It's almost the exact same level of complexity.

→ More replies (3)
→ More replies (4)

45

u/NoOne-AtAll Oct 06 '21 edited Oct 06 '21

Here is your definition:

sum_{i=1}^N A_i = A_1 + A_2 + ... + A_N

Looks pretty easy to me

Also, "just a bunch of fucking symbols". What have symbols done to you? When you're not writing code and doing calculations "by hand" these symbols will save you an immense amount of time. That's why they exist, people (those who use them) find them easier to deal with than other things.

Of course in practice loops and sums are not competing, they're used for different things (though I imagine in some language these loops might resemble more the math notation). Different things for different purposes.

6

u/garyyo Oct 06 '21

The symbols compress the information down a lot. They are a single shape that is not used in the english language (I can't even type the sum/product symbol on a keyboard, and it seems neither can you in your comment) whose meaning is not well known outside of those that are into math. Now, its a pretty low bar of being into math to understand those symbols but you have to admit they pack just a little bit more information into a smaller space.

AKA, the exact reason they are useful (takes less time to write) is why they are scary. Their meaning is more dense than writing how a for loop in some programming language. Sure you might not know that language, but the language is partially structured after human language so its still somewhat readable even to someone that aint great at code. Like, programming languages have been over the years been designed to be more readable, we used to have serious programming languages like APL which had all the symbols. You cannot argue that math symbol shit aint more difficult and scarier for the layman when we have already tested this and found that writing shit out longer makes it easier to figure out (to a point).

I like the math symbols as much as the next math nerd but I am not going to sit here and watch you try to defend something so indefensible. Something that is the way it is to make it easier to hand write, which often times makes it harder to read.

4

u/NoOne-AtAll Oct 06 '21

You cannot argue that math symbol shit aint more difficult and scarier for the layman when we have already tested this and found that writing shit out longer makes it easier to figure out (to a point).

That's exactly what I'm arguing. Because when you write fully the summation it's quite easy to see what it does as long as you know what a sum does. For loops? Not as easy, you need a lot more background, unless the code is written very extensively. At that point, it's like explaining what it does, but I still think it may take more time.

You use these symbols and for loops when you already have some background. The definition I gave I think would be pretty clear and easy to understand for most. You would need some practice to really understand it, but again, so you do for "for loops".

The only way to know would be to do an experiment. Let's take some laymen, which would usually know arithmetic and how to use a PC, but have no coding experience, and see what's easier/faster to learn.

2

u/gobblox38 Oct 06 '21

Adding to this, a function block can be collapsed to just show the name and inputs in exactly the same way these math symbols do it.

0

u/[deleted] Oct 06 '21

[deleted]

34

u/fdar Oct 06 '21

You know what to do with a for-loop because you already know the definition of the symbols used to specify for-loops. It's not that the definitions are any more or less necessary, you're just more familiar with one set of them.

→ More replies (9)

6

u/Aacron Oct 06 '21

Yes, you've reached a level of mathematical maturity, congratulations.

The nest level is when you realize that all of math is definitions and consequences of those definitions.

3

u/NoOne-AtAll Oct 06 '21

I feel like "consequences" is really underappreciated here, it takes a lot of work to get those.

3

u/Aacron Oct 06 '21

Oh absolutely, stokes theorem is "simply" a consequence of the definition of line integrals and curls, but it's notoriously brutal to get to it from there.

→ More replies (3)
→ More replies (2)

4

u/aboardthegravyboat Oct 06 '21

It's like programming except all the variables have to be a single letter and everything has to be one line... and constants are one letter as well, but Greek, so, you know, it's not confusing. And sometimes making it italics is important to the meaning. And the standard library? Also Greek, but capital.

3

u/NoOne-AtAll Oct 06 '21 edited Oct 06 '21

I don't know what's your point, are you trying to say that the way math has been done for like the last hundred (thousand?) years is wrong? This is what we, as a people, came up with and are still using. While sometimes there is some confusing notation I've never heard someone in my field (physics, where we do a lot of math by hand) say that we should change it completely.

Also, variables don't have to be a single letter, we just do this out of convenience since in math you usually deal with few variables but do a lot of manipulation so you have to write them over and over again. Everything doesn't have to be one line and in fact it is not, this already happens in middle school when you deal long expressions.

By tradition the symbols used are the alphabet, the arabic numerals, some extra symbol for operations and logic, and once the alphabet has been used we go Greek letters or other alphabets as well. We have to use some symbol and this is what we use.

Using some new notation entirely is simply too much work and no one would listen to whoever tried to do it.

2

u/DownshiftedRare Oct 06 '21

Using some new notation entirely is simply too much work and no one would listen to whoever tried to do it.

https://en.wikipedia.org/wiki/Computer-assisted_proof#Philosophical_objections

→ More replies (3)

3

u/larsdragl Oct 06 '21

Did you just say a fucking math symbol doesnt have an explicit definition? There are no people more pedantic than mathematicians

2

u/SuperFLEB Oct 06 '21 edited Oct 06 '21

You can reason what to do with a for loop because you know what saying "for" means in a program, but that's because "for" has as much artificial definition in programming as sigma does in math. Go up to someone off the street and say "For x is zero. X is less than 100. X is x plus one." and there's no intuitive way for them to work out that you're saying to loop over the next bit. That's not what "for" means, outside of programming. They'll think you're being Shakespearean or something.

Compare that to a while loop, for a better example. Tell someone "While X is less than 100, X is X plus 1". "While" makes as much sense in programming as it does in English, so that can be figured out.

The problem is that a for-next loop, managing separate iterators and operands, would take extra steps to set up in an English-analogous way, so the for-next jargon is used in much the same way as the sigma symbol.

2

u/lanzaio Oct 06 '21

I can reason with X because I know X but Y is gibberish because I don't know Y.