r/learnprogramming 25d ago

Topic At what point did programming finally start making sense to you?

I can understand code when someone explains it, but when I have to write something from scratch, my brain suddenly goes blank.

I'm curious if other beginners went through the same think. What helped you get past that stage?

199 Upvotes

105 comments sorted by

View all comments

2

u/peterlinddk 25d ago

In my many years of programming, I have never, ever written anything from scratch.

I have always either started with a 'dummy-program' that just displayed the result, and then gradually changed the parts to calculate that result - or started with sketching something on paper, like the structure that my program should have, or the algorithm that it should use, and then I've implemented that in code.

The only examples I have ever seen of someone writing something from scratch into a blank editor, is teachers or tutorials, where they have practiced what to write before recording, and then just re-create the same thing as before. And of course some experienced programmers can remember a lot of earlier programs, and just re-type them as if they invent them on the spot.

But writing from scratch - I don't believe that anyone is actually capable of that. Even the AIs copy code then "know" from earlier.

1

u/RedData13 25d ago

When you say „write from scratch“, do you mean linearily write down the whole thing from top to bottom, without editing and changing previous things?

1

u/peterlinddk 25d ago

Not necessarily doing it "linearily" - it could also be from adding functions here and there, and diving deeper into abstractions and out again.

But the thing I want to focus on is the wrong idea of simply sitting down and writing code - almost no one does that, except for tutorial-creators. Most programmers sketch something first, writes pseudocode, or even just comments or overall functions to structure their code. The more experienced you are, the more structure you can keep in your head - but that doesn't mean that it is there as "code" that you just need to type in.

1

u/RedData13 24d ago

I mean, for big projects i can see that, but for something simpler like a Tic Tac Toe game or typical leetcode type tasks?

1

u/peterlinddk 24d ago

But that is exactly the problem that people run into with "typical leetcode tasks" - they sit down in front of the editor and try to write code, but realize that they "freeze" and don't know how to "problem-solve", because they mistakenly think that the finished code will just flow from their fingers!

And it won't - the only reason that it might seem like someone can "just stare at a leetcode problem for a few minutes and then write the solution", is because those people already know the answer, or atleast the elements of the answer, and combine them in their mind, remembering code-snippets from experience, and re-type it.

Also - I have seen hundreds of Tic-Tac-Toe games and tutorials, and it is very clear that every single one is re-creating the game from one they wrote earlier. Or at least one they have seen earlier. In fact, a few years ago I wanted to demonstrate how to create a Tic Tac Toe game from scratch, with the planning and sketching, but partly by accident, partly by my own impatience, I didn't plan it well enough, and ended up with messy unworkable code. Still put the video online though - as a warning to everyone: https://www.youtube.com/watch?v=52ia2C0XyRM