Live data from Hacker News

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

shockoe.com

141–150 of 184 posts

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

#141
I started using this method after reading one of Zed Shaws books, and it really works. I repeat an excercise 9-10 times, until its automatic. Its rote, but I'm actually starting to understand concepts. I'm also able to apply what I've learnt when I'm writing my own programs. Its not easy and maybe its not the best way but its working for me.

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

#142
post #139

In a different domain, the journalist Hunter J. Thomson was known to type entire novels to learn the style of master novelists ( http://en.wikipedia.org/wiki/Hunter_S._Thompson ): "During this time he worked briefly for Time , as a copy boy for $51 a week. While working, he used a typewriter to copy F. Scott Fitzgerald's The Great Gatsby and Ernest Hemingway's A Farewell to Arms in order to learn about the writing st…

This is explicitly mentioned in the article you just commented on.

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

#143
post #139

In a different domain, the journalist Hunter J. Thomson was known to type entire novels to learn the style of master novelists ( http://en.wikipedia.org/wiki/Hunter_S._Thompson ): "During this time he worked briefly for Time , as a copy boy for $51 a week. While working, he used a typewriter to copy F. Scott Fitzgerald's The Great Gatsby and Ernest Hemingway's A Farewell to Arms in order to learn about the writing st…

I believe you mean Hunter S. Thompson, which, ironically you linked to with the correct name.

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

#144
post #69

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…

I'm a high school computer science teacher, and this is a WONDERFUL idea. I'm totally going to steal it and create a few assignments based on the concept.

I teach Maths (in the UK), so pinch of salt needed with my suggestion below...

Suggestion: code fragment on your interactive whiteboard. Ask students what each line does, how the loop works &c.

Then blank the screen and get them to replicate....

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

#145
Not sure about just typing, but working thru things for yourself helps, even if it a repetition.

This is how I taught myself mathematical problem solving (and math as a side effect). I would read the problem statement, instead of looking at the solution, try to solve it for upto 15 minutes or sometimes even for several days depending on how much value I am planning to get from the solution.

The Brachistochrone problem(http://en.wikipedia.org/wiki/Brachistochrone_curve) is an example of a problem that I tried to solve for several days. Newton solved it in 3 hours, and when you learn math like that you don't take things for granted. You can admire the amount of insight that went into the steps. You can also internalize the knowledge obtained thus exponentially more effectively than you would by listening(and falling asleep).

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

#146
So one thing that I want to point out, many, many tutorials and books for coding teach bad design practices or provide code that is overly verbose, to make instruction in a particular element clearer. Java is particularly troubled by this imho. So if you are going to use code you find, you should look at good code. I recommend code from a mature open source product.

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

#147
Here's another trick that's helped me a lot over the years:

open up your favorite library on Github, go back to the very first commit and start reading, commit by commit. If you don't understand something, just copy the difficult section, line by line, on a repl, inspecting variables and/or function results.

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

#148

So one thing that I want to point out, many, many tutorials and books for coding teach bad design practices or provide code that is overly verbose, to make instruction in a particular element clearer. Java is particularly troubled by this imho. So if you are going to use code you find, you should look at good code. I recommend code from a mature open source product.

This is one reason why I skipped Java and went right to learning Python and Ruby (after background in C). As a beginner, there was no context, no way for my n00b self getting into OO programming to sort the good Java from the cruft.

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

#149
post #72

I agree with this especially when you are doing tutorials for this reason: when you type out code, you inevitably make typos that cause bugs. This forces you to learn what some of the common possible error conditions are and forces you to learn to find and resolve them. Learning these things when you have the safety net of a tutorial is ideal, because if you can't figure it out you can always compare with the tutoria…

Can anyone else relate to this? Back in the day (early 90s), I would go down to the public library, pick out a thick book full of computer games written qBASIC, and of course I had to type them in all by hand. We didn't have internet yet, the idea of copy-and-paste from somewhere did not even exist in my mind. So I would copy these 10,000-line BASIC programs in by hand into our 386 computer, one line at a time. For s…

This is pretty much how the book I'm using on Pygame is working. It's a load of games written in Pygame that the author encourages you to copy out and try to learn how it works yourself. Then afterwards he explains in detail how it all works. The writing it really helps with learning how you can use the simple stuff together to make more complex stuff.

Book: http://inventwithpython.com/pygame/index.html

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

#150

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…

One thing that has really sped up my my learning over the past few months on Code Academy -- complete a lesson, then in another tab open their scratch pad feature and try to retype the code not only from memory, but also while thinking through the logic. Has really been effective for me as I feel like I now have a pretty good (beginner) grasp on JS and Python

I have to try this. Could you code in other languages before doing this?
Post reply on HN