r/self • • 2d ago

Learning to code feels counterintuitive as someone who was brought up with the conventional way of learning mathematics

I'm self learning C# for Unity and there are many times where I think, why write code like this when all my life I have been learning something different. And it's frustrating. For example even something simple as x = 5. In albegra we learn this means that "x" is exactly 5. But in C# it does not mean x is exactly 5, it means we assign 5 to x. And that x = x + 5 is an impossible statement in mathematics but in C# it is completely logical. I feel stupid sometimes trying to wrap my head around this. Does anyone have a similar reaction when learning to code?

Not to mention the fact that ultimately self-learning coding feels pointless because coding is now replaced by AI.

1 Upvotes

11 comments sorted by

6

u/tardmrr 2d ago

You could try learning Haskell where every definition is immutable and side effects are only the result of the value you return from your main function.

10

u/Sock_Selection_2910 2d ago

this is a very beginner problem, you will get over it after a month. Regarding AI, my advice is to get solid at a language first, once you get good fundamentals; you can just get AI do the work as long as you understand it

3

u/CartoonistGlobal3610 2d ago

I completely agree

5

u/NotACockroach 1d ago

Just imagine putting the word "let" in front. That's how assignment is written in maths. As in "let x =5". If you're actually doing equality programming languages usually use ==.

1

u/Great-Use-3149 1d ago

Rust entered the chat

2

u/lillobby6 1d ago

This is why some languages use the Walrus operator (:=) instead in order to reduce confusion.

1

u/AntiqueFigure6 1d ago

“  And that x = x + 5 is an impossible statement in mathematics but in C# it is completely logical.”

There is a family of languages (functional languages) that work differently for people who are annoyed by x=x+1 being a thing. 

1

u/naomimyselfandi 1d ago

I've taught basic programming before. What you're describing is a very common sticking point, and most people get through it in time. It may help to consider a situation like this, where you're manipulating meaningful data and there's a clearer reason for it to change over time:

let the best student be the first student in the roster
consider each student in the roster:
    if that student has a higher score than the best student:
        update the best student to that student

1

u/Michthan 1d ago

I try to think of = as |-> more of a pointing operation. Now x points to x + 5. This made it easier to understand for me

1

u/No-Representative621 1d ago

variables are just containers. places in memory that are currently storing a value. x is just a bag holding something.

1

u/Frobizzle 1d ago

A variable is simply a container for data and sometimes it needs to change. Don't think of it like a math equation that needs to resolve to anything.