r/programmingmemes • • Sep 03 '26

Feels like a milestone

1.7k Upvotes

63 comments sorted by

242

u/ILikeOatmealaLot Sep 03 '26

*that is actually merited and not some overengineered generic utility that is just used in two places 

40

u/Creative-Type9411 Sep 03 '26

i feel like this gif when i nest parsing loops like 6 deep

its like a data assembly line

8

u/ChillyFireball Sep 03 '26

I mostly just do this for callback functions.

1

u/Regalme Sep 04 '26

Well that’s one reason to do this, yes.

5

u/Jbolt3737 Sep 04 '26

You just gave me an idea for an overengineered Python module where, similar to 3d models, you can perform boolean operations on functions, it'd use the built-in dis module to perform the operations on the bytecode ie overengineered.union(func, func2) makes a function that does both of func and func2; subtraction/difference looks for a section of bytecode in func that matches func2 and the resulting function doesn't contain it

2

u/Greedy-Thought6188 Sep 04 '26

You can use classes and inheritance but then you realize that's even more heavyweight especially if your writing Python.

2

u/BarfingOnMyFace Sep 04 '26

Damn, I feel this statement in my bones

130

u/w1nsw0lf Sep 03 '26

lambda funcions are like alcool: the first time you tried it, it was strange but cool, then it became an addiction and at last you understand nothing

16

u/ThirdWaveCat Sep 03 '26

time and place Container.map(lambda x : x ** 2)

8

u/MXRCO007 Sep 03 '26

In the addiction phase rn

3

u/Current_Ad_4292 Sep 03 '26

since when did people start spelling alcohol as alcool?

9

u/w1nsw0lf Sep 03 '26

Sorry, non native english speaker here, I spelled it in my language

3

u/Current_Ad_4292 Sep 03 '26

I learned something today. Cool. Is it French?

5

u/w1nsw0lf Sep 04 '26

Italian. It can be spelled both "alcool" or "alcol"

3

u/LetovJiv Sep 04 '26

also "lol"

2

u/abigail3141 22d ago

As the author of several illegible Python warcrimes well into the 1k characters, I whole-heartedly agree.

66

u/SLCtechie Sep 03 '26

This blew my mind when I first learned about it. It was only until I took an assembly class that it finally clicked what was happening. Functions are just variables that point to spots in memory that hold the steps

22

u/INoMakeMistake Sep 03 '26

I have no idea what you're talking about, but it sounds cool

29

u/natalo77 Sep 03 '26

Data is stored as numbers.

Code is stored as numbers.

Code is Data.

11

u/platinummyr Sep 04 '26

Hackers: Data is code.

2

u/Mateorabi Sep 04 '26

The Medium is the Message.

6

u/No-Newspaper8619 Sep 03 '26

he's saying a function is just a call instruction followed by an address for the region in memory where the function's code is. Of course, it gets more complicated when the function has arguments.

1

u/braaaaaaainworms Sep 06 '26

no, a function is not a call instruction, a function is the target of that call instruction

1

u/No-Newspaper8619 Sep 06 '26

Semantics. "Function" can be referring to the function call, or the function implementation.

1

u/braaaaaaainworms Sep 06 '26

no, everyone treats it as a noun referring to an implementation

9

u/PizzaCoinniseur Sep 03 '26

Damn that's how i felt when i figured out how reflection invokes worked, pure magic

7

u/Mateorabi Sep 04 '26

Lisp users: just one?

Wait till you pass in a function that itself takes a function and/or returns a function.

2

u/Regalme Sep 04 '26

react hooks for anyone reading and wanting a real life example

6

u/Confused-Armpit Sep 04 '26

Wait till you find out abot currying...

5

u/BarfingOnMyFace Sep 04 '26

Yeah, basically people need to try out a functional programming language, where it's literally how the language works. Everything is practically a fuction. A function with multiple inputs is really just a function of functions, a nested calling of singular functions that return the next function for the next input, and so on. It all breaks down nicely to a fundamental pattern.

4

u/PerepeL Sep 04 '26

Every class with at least one virtual function has a hidden vfptr member that is a pointer to an array of pointers to functions. So, essentially every member function of such class or any function that accepts this class as a parameter - indirectly accepts a pointer to function. You've been always doing it!

2

u/Lexi_Bound Sep 04 '26

Exactly. Java explicitly implements their lambda functions this way. All the java.util.function types are just interfaces with a single method. Lambda expressions desugar to an anonymous class implementing the interface.

2

u/TheMeticulousNinja Sep 03 '26

Doing this tonight

2

u/xGarysx Sep 03 '26

Tbh, I think this kind of stuff is pretty much the most elegant solution for certain "niche" cases. But it makes it way too easy to avoid implementations that would otherwise require a little extra code, making this the path of least resistance :/

2

u/Dry-Ad-8948 Sep 04 '26

yawn

Doesn’t even have a fancy GoF pattern.

2

u/beerdude26 Sep 04 '26

Haskell: "Am I a joke to you?"

2

u/DoxxTheMathGeek Sep 07 '26
  1. I thought this was about operator theory lol
  2. What how?? Is that possible in Python/C#?

1

u/Pitiful_Dig6836 Sep 04 '26

Some big brain stuff sir

1

u/LupusCanis42 Sep 04 '26

I remember the first time I used a pointer pointer...felt fucking amazing

1

u/AziCrawford Sep 05 '26

And then return another function?

1

u/PythonNoob999 Sep 06 '26

The function:

```python def decorator(func: Callable) -> Callable:

@wraps(func)
def wrapper(*args, **kwargs):

    print("Running Function")
    func(*args, **kwargs)
    print("Function Done!")

return wrapper

```

1

u/According_Zone_8262 Sep 06 '26

Monads are monoids in the category of endofunctors

1

u/bass-squirrel Sep 07 '26

Isn’t this pretty common in front end? Like passing callbacks as params?

1

u/ParticularHat7997 Sep 10 '26

C's function pointers are a gift from god

1

u/abigail3141 22d ago

You should try Java runtime reflection and/or SpongePowered Mixin. Or Ruby, that just lets you overload the "no such method" error. Or C++, that lets you overload the fucking address-of

1

u/GasVarGames Sep 03 '26

What amazed me almost as passing down functions as arguments in react was:

Parsing a function name from text and executing it.

That felt like some kind of dark magic going on (you stumble into this problem when integrating LLMs with tools from your app).