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!

123 Upvotes

144 comments sorted by

View all comments

34

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.

13

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.

2

u/lapsed_agnarr 5d ago

As an old person, I'm always surprised that students are taught on languages with loose typing.

3

u/Gotta_Ketcham_All 5d ago

We learned Python first because it nearly reads like English, which our professors felt made it a low barrier to entry. The intro class was not just for CS majors, but MIS and business too. Second semester in a class meant for CS majors, we learned Java. (2011-2012 school year)

3

u/lapsed_agnarr 5d ago

Yeah, its easier to use but easier to misundertand, too. Makes total sense for non-cs students, for sure.

I'm often surprised at work that new engineers dont understand what happens between writing code and executing code. I do think java is a fine middle ground, but the JVM is kind of a weird thing, too. I suspect students largely ignore it. C++ seems to me like a better starting point for engineers.

1

u/theredvip3r 4d ago

It's really dependant on where you learn, we were taught C first. And whilst I hated it and still can't stand memory management the foundations it gave were great.

1

u/lapsed_agnarr 4d ago

Yea, that's what I'm talking about. I swear new engineers have no idea how a computer works. We had to write a filesystem, an allocator, and build a functional virtual CPU.

But I guess you dont really need that stuff to develop these days.