Live data from Hacker News

Want to learn to code? Don't copy and paste, type out other people's code

shockoe.com

91–100 of 184 posts

Re: Want to learn to code? Don't copy and paste, type out other people's code

#92
I learned to code essentially from books. I tried the type it out method. It was... um... a dismal failure. I would type it in, and I would have no idea what happened. It was all in code. There was magic in them thar characters, and the magic wasn't working.

So I regrouped and started writing my own code. Lots of code. Very bad C++ code. Excruciatingly bad code. Over and over again. I desperately wanted to understand, and I studied the books time and time and time again, taking those concepts into my very bad code, and after time, my code became less very bad and just... bad. After about two years of this, I was barely marginally competent, but I did pretty much understand how to write code. Then I went off to college and learned computer science.

Re: Want to learn to code? Don't copy and paste, type out other people's code

#93
post #67

When learning code out of a book for a new language, one trick I found that worked really well was to read the code, then close the book and try to type as much of it from memory as I could. I would futz with it for several minutes exploring various ways of making it break, seeing if I could 1) predict how I was breaking it, and 2) use the error messages to fix my mistakes. Then I would open up the book again and com…

This is how I learned/am learning Erlang.

Reimplementing standard library functions is great for Haskell too. The biggest of the "big breakthrough" experiences I had was from trying to reimplement the standard monadic State datatype.

Re: Want to learn to code? Don't copy and paste, type out other people's code

#94
It is essentially what Zed Shaw propose in his "Learn Code The Hard Way" books. It definitely helps to type in everything and can be applied in almost anything we need to learn.

It's this memorization trick teachers usually told us to do, basically rewrite the notes you've taken or things you need to remember. It's somehow boring to apply and while doing it you don't necessarily realize you are learning but it does work great.

Then it's extended with programming where what you typed is used interpreted by your computer and turns results from what was typed.

Re: Want to learn to code? Don't copy and paste, type out other people's code

#95
post #92

I learned to code essentially from books. I tried the type it out method. It was... um... a dismal failure. I would type it in, and I would have no idea what happened. It was all in code . There was magic in them thar characters, and the magic wasn't working. So I regrouped and started writing my own code. Lots of code. Very bad C++ code. Excruciatingly bad code. Over and over again. I desperately wanted to understan…

It isn't that typing it out is the best possible way to learn, it's that copy-pasting is a terrible way to learn - even worse than just typing it out.

Re: Want to learn to code? Don't copy and paste, type out other people's code

#96

In the old days of tape drives (at best) hooked up to our TRS80s, Commodores, and the like. The only way to run programs in popular magazines at the time was to type them in. If you didn't have storage and wanted to try the program again, you typed it in again. It was a pain, but certainly learned things (like how poor / slow a typist you might be). This slow process allowed you time to see and think about what was g…

My school library used to have books full of games, text art, and programs written in BASIC that I used to type in line by line to our C64. I wish I could say I learned a lot about computer programming (I didn't) but the biggest thing I do remember was being thrilled at being able to make typed instructions turn into things happening on the screen.

These programs would get run only a handful of times, since I had no way (or it never occured to me) to save them for later use.

Re: Want to learn to code? Don't copy and paste, type out other people's code

#97

When learning code out of a book for a new language, one trick I found that worked really well was to read the code, then close the book and try to type as much of it from memory as I could. I would futz with it for several minutes exploring various ways of making it break, seeing if I could 1) predict how I was breaking it, and 2) use the error messages to fix my mistakes. Then I would open up the book again and com…

Another +1. When I've used this method I've noticed that the tendency at first is to try to just remember the code and copy it out of your memory. There comes a point, though, when you don't remember it well enough to "copy from memory" and this naturally segues into a focus on the logic and syntax of the code so you end up reconstructing working code without fully remembering the original.

Re: Want to learn to code? Don't copy and paste, type out other people's code

#98
For roughly the first year when beginning to learn to code, I refused to use an IDE or any editor that had intellisense. The result was having to remember the syntax of different languages, method names, etc.

I was in college at this point, so it made spotting syntax errors easy for multiple choice questions or debugging on tests.

I also approached coding problems on paper before typing a line of code. This helped to grow how I approached problem solving, rather than whether the page would run properly or not.

If I were to start fresh I'd still take the same approach. I'm a huge believer in repetition for remembering, and writing out code rather than copy/pasting or have it be autocompleted, eventually pays off.

Post reply on HN