Live data from Hacker News

Ask HN: Why do I find it so difficult to learn to code?

news.ycombinator.com

1–10 of 29 posts

Ask HN: Why do I find it so difficult to learn to code?

#1
I have been trying to learn how to code using numerous languages for the past 10 years. I go over the same stuff, strings, variables, arrays etc and I possibly get about 100 pages through a book, everything feels great, I'm understanding what I read and I do the examples. For some reason, out of the blue I hit a brick wall and suddenly I feel overwhelmed and stressed, I look at other people's code and it's as if I'm reading Chinese. I get dishearted and eventually stop. After a few weeks/months I repeat the entire process. I've used several languages over the years so I know it's not the language. Is it something I'm destined not to do or could I be doing something wrong?

Can somebody PLEASE help me overcome this problem as I want to code more than anything.

Thanks

Re: Ask HN: Why do I find it so difficult to learn to code?

#3
Start without looking at other people's code. Think of simple projects you could do, and do them from scratch. Even highly experienced contractors have a difficult time going over other large projects if they are not familiar with the code.

Don't try to make everything perfect from the first time. Make it work, then you can improve it.

Build a simple tool first, such as a video converter or a timesheet management tool or even the classic blog, calculator, image gallery etc.

You will hit not one, but many brick walls, you just need to know how to find a way to go over them. If the problems you are trying to solve when you hit the brick wall are too complex, divide them into smaller things you can tackle independently.

While you are doing this, keep on reading about programming as well as secondary processes that can make your life easier.

And finally, use an IDE, not notepad, learn to do TDD and how to use a profiler. You'll save yourself a lot of time.

I hope this helps you.

Re: Ask HN: Why do I find it so difficult to learn to code?

#4
I look at other people's code and it's as if I'm reading Chinese.

How large a program have you written on your own? Where are you finding code to read?

I wouldn't start reading code until you are fairly comfortable writing and debugging code. Reading code is harder than writing code. Start by trying to read code you wrote but haven't looked at in a month. That way you are familiar with what it is supposed to be doing and the style it is written in.

Re: Ask HN: Why do I find it so difficult to learn to code?

#5
I don't know, I can only tell you what worked for me. It was "just doing it", without worying about style, guidelines, whether this will scale, is this the best practice, I just wanted to do something, I wrote the code that was the least resistance path to achieve it (I wrote 5x5 word guessing game in TurboBasic - I didn't knew how procedures worked, I did not knew that there was while loop, so i wrote one for nested into other for with the bigges numbers I could put there and worked, it was basically one big loop with if for each case, and a few variables. I should be ashamed of this code, but I was proud, because it worked. It was magic. I've shown it to my friends and parents, and everybody, and I felt so great.

I've tried something harder next time. And I've found about arrays - so I don't have to name my variables X1, x2, x3, x4 and check them with ifs, so I used arrays, then I found out about procedures, etc, etc. Then I used that to write next simple logic game, and so it went.

Whe you have something that works, it's easier to see why you need arrays, or functions, or loop without counter :) And it gives you motivation.

Anyway - good luck.

Re: Ask HN: Why do I find it so difficult to learn to code?

#6
Don't look so critically at others code - everyone has their own style to programming, you can do much the same stuff with complex code as with simple, functional or object oriented. Glean what you can/want from it now and don't fret over the rest, come back to it later as you improve.

If you have issues with your own code, work them out. One thing that helped me deal at my code was to work on my formatting and readability. Breaking up long lines consistent indenting, better variable, field and and function naming etc.

Third, use some concept you 'own' to work on. As in a project of some sort, a concept you understand forwards and backwards... maybe a baseball card database, or an event calendar - maybe you nailed it years ago in language X, do the same now in language Y. This is so you aren't fighting with deciding on what you want, you just need to discover in the language how to get there or how to improve upon what you know, also it will give you a quicker success in the new language which is good for the ego too.

I think also the more experienced (older) we get the more frustrated we get when things just don't just work the first time, so we need to fight that frustration a bit more.

Re: Ask HN: Why do I find it so difficult to learn to code?

#7
Let's talk about Chinese.

Can you "learn" Mandarin by reading a few books on Mandarin, taking a few courses, attempting to read some books in Mandarin, and occasionally speaking a few words to that cute Chinese girl at work?

Yes, you can "learn" Mandarin that way, but you can't Learn it.

If you were REALLY passionate about learning Mandarin, you would have to go to China (or at least Chinatown) and stay a while. Then you would be driven to learn Mandarin because you would need huge chunks of it for very real things. NOT learning Mandarin would be more painful than learning it.

You need a project. You need a project complex enough that you need huge chunks of programming knowledge to implement functionality. You need a project so interesting to you that it's more painful NOT to learn how to program than it would be to learn.

UPDATE: One other thing. It's ALWAYS difficult to read other people's code. Always. This gets easier, but complex codebases always look like gobbledygook the first time you look at it. I've been programming for 20 years and this still happens to me. You get used to it. What's the strategy? How do you eat an elephant?

Re: Ask HN: Why do I find it so difficult to learn to code?

#8
Don't rule out ADD or Dyslexia (even at a low level) as limiting factors when you're trying to learn something from a book or read other people's code. In the last couple of years I've learned a lot about programming by just making up some ridiculously large project, and _just doing it_.

Re: Ask HN: Why do I find it so difficult to learn to code?

#10
Maybe you're just not in the right mind-set. Programming, being highly analytical, requires a certain outlook to properly understand and if you're not in that state of mind you might have little luck getting anywhere.

I'd argue a good portion of learning how to program is simply in learning how to hold yourself in that state for longer periods of time.

The best way to introduce yourself to programming is to start small, build something, but always build it to completion. You learn very little from efforts that don't produce results. Even a "Hello World!" success propels you forward a tiny bit. Build on it. Make something incrementally more complicated from there.

The best motivator is to have an idea that's compelling. Always start with something far simpler than your original idea, strip it down to the absolute essentials, practice by building parts of it in isolation and later try for a more integrated approach.

The other thing that's important is persistence. You need to put in a bit of time each day, every day, in order to move ahead. Taking a few days off is damaging to your momentum and in that time you're already losing track of things. Training requires continuous exposure.

Post reply on HN