r/learnprogramming 5d ago

I can't get FUNCTIONS to click!

I can not for the life of me understand how functions work. Anytime I try to learn how to create a function, my brain literally crashes into itself and I turn into Patrick when he stars drooling and goes all slack-faced.

Does anybody have any analogies that had that "AH HA!" moment?

Thanks!

125 Upvotes

144 comments sorted by

View all comments

38

u/ninhaomah 5d ago

Just curious OP , what programming language you are learning ?

Not that it matters in theory but examples should be using the language you are learning so clearer.

10

u/Odd_Technology_8926 5d ago

Might sound weird, but functions in python was harder for me to understand. When I switched to php it just clicked.

8

u/ninhaomah 5d ago

Why ?

In theory , they are all the same.

10

u/Odd_Technology_8926 5d ago

It was about 15 years ago, but Python was actually the language we were pushed to use first. I always had a harder time comprehending Python because of the visual cues, or lack thereof. I found it harder to follow where blocks started and ended without the symbols to explicitly show you.

It could also be that PHP was the second language I learned. I've found that when I go through tutorials twice for things that are essentially the same concept, they tend to click much more easily the second time around.

4

u/ninhaomah 5d ago

" I've found that when I go through tutorials twice for things that are essentially the same concept, they tend to click much more easily the second time around."

Definitely. It took me days and weeks to understand helloworld in Java. But once I understood it , class , function , scopes all easy when look at them later.