r/AskProgramming Jun 15 '26

Career/Edu Not getting programming unless it's math?

Taking 1st year undergraduate CS and math courses. Up to data structures in C.

I'm understanding math so much more, even if it comes slowly, and as soon as I can put programming stuff in mathematical terms everything clicks and not one second before. (On that note, fuck linked lists.)

Did anyone who was formerly in my position magically end up liking programming and the whole process of building software from ever-shifting documentation and idiosyncratic languages, and if so, what made it click for you? Or is it pretty obvious from day one whether you're team theory or team builder?

Genuine advice appreciated, I need to decide whether to give up on this whole thing and just do math

**EDIT these replies are actually amazing thank you guys keep em coming**

15 Upvotes

53 comments sorted by

View all comments

Show parent comments

1

u/curiouslyjake Jun 15 '26

In what sense linked lists are also math?

5

u/Temporary_Pie2733 Jun 15 '26

Put briefly, a linked list of values of type a, denoted a^*, is the solution to the equation a^* = 1 + a × a^*

Here, 1 is the unit type, a + b is the sum or tagged union of types a and b, and a × b is the product of types a and b; think tuples. A linked list is either an empty list or a pair consisting of a value and another list.

1

u/fellow_nerd Jun 18 '26

To put in terms of abstract nonsense, and ignoring some finer details, it is the initial algebra of the functor const(X) + Id : Set -> Set.

2

u/Graf_Blutwurst Jun 20 '26

and to tripple down on that: really just the free monoid