想學編程?這樣開始 Want to learn to code? Start here.

《轉》

去年九月我寫了一篇挺受歡迎的博文,叫 《想學Rails? 這樣開始》。 許多讀者看完文章後,當面或用Email向我提了大量問題;也有很多人真正投入到了Rails學習中。我也很自豪地向很多人推薦了這篇文章,因爲其中的內 容真的具有可操作性,並且對讀者真的有幫助。從那之後到現在,我的編程功力又長進了幾個甲子,於是又有了下面這篇文章,記錄我對“如何學編程”的再次思 考。

這篇文章是寫給那些真心要編程的人看的——那些憋着一股狠勁兒,一定要做出個什麼真東西的人;而不是那些“聽說編程好玩”的人。在我看來,這些人都不太可能真的整出個像樣的東西來。

1. “只用晚上、週末的業餘時間學習”很不靠譜

無論從我個人經驗,還是衆多訪談的結論來看,只用晚上和週末等業餘時間來學習編程是十分糟糕的辦法。斷斷續續的學習方式,你的腦子根本沒機會養成編程式的思維方式,你很難把之前學習的內容撿起來。一定要把你的時間儘量多的利用起來。

一種改善的方法是參加“編程訓練營”之類的項目;你不但要花整整九周時間,還要花費一筆不小的學費。這些付出可以對你有所約束,督促你學到東西。你必須全情投入,否則錢和時間就打水漂了。

2. 忘掉 Codecademy.com

“我用 Codecademy 學會編程了!”

不知道有多少人這麼說過了。但是如果持續的觀察六到八個星期之後,這些人就都歇菜了。

我告訴你們爲什麼用Codecademy學習不長久:

  • 你永遠只是在瀏覽器裏、在Codecademy網站裏編程;學到JavaScript、Python、Ruby的語法是挺好,但是從課程裏你也只能學到這些;其實這些你從別處也都能學到。
  • 你不會學到如何搭建開發環境。就憑你在Codecademy學到的那點兒東西,哪怕你只想做一丁點兒的小項目,你都不知道該從哪兒開始。
  • 對於只有一點點編程經驗的人來說,搭建自己的開發環境是很有挑戰性的一件事兒。你需要自己把這件事兒搞定

3. 做一個真正的、你想做的項目

在你想做的項目裏,先找一個小的來做。我做的第一個項目叫做“今日所學”。軟件裏只有一個文字輸入框,你每次輸入一些文字,軟件按照時間降序來顯示輸入內容的列表。僅此而已。

你的第一個項目一定就是一坨屎。但是它是完整的項目,而且是你完成的。這纔是最牛逼的地方。

4. 你的代碼要建立在你之前做過的項目之上

我每天寫代碼,我都會把當天所學的一兩個知識點放進去,這樣我下一次編程時就會寫的更好。你會不斷的從你的代碼庫裏引用老代碼,或從網上扒來的代碼。一旦你真的懂了這些代碼,你就能把它們用起來。

5. 別拷貝粘貼別人的代碼!

Tommy Nicholas去年12月寫的博客裏也提到了這個觀點。只有你把代碼敲出來,你才能真的學到東西,你才能發現你對某些代碼還沒弄透,也希望你去google一下你的疑問,這樣才能學到越來越多的東西。

6. 別在別人面前得瑟“我在學編程呢!”,除非面對一個高手,你要求教。

開始學編程之後,你要爲自己找到一兩個編程老師帶着你學,但別學了一點就在那些不會編程的朋友面前窮顯擺。

我一直相信,如果你把想做的事兒說了出去,那事兒就永遠只能停留在你嘴上了。所以除非對方是你可以請教的老師,不然就閉上嘴,低下頭,老老實實編你的程。

空談誤國啊!

7. 編程就是失敗無數次後弄清爲什麼。很痛?很挫敗?很正常。

編程就是要重複的犯錯誤,犯重複的錯誤,弄清楚錯在哪兒,再改正錯誤。下次再碰到相似問題(你一定會碰到的),你就會想起之前蹂躪你的那些代碼和你的對策,吃N塹,長一智。

當然,搞定編程的成就感也會讓你爽到內傷。“那東西是我想出來滴!”的快感是我活着的動力!我爲之着迷!但獲得快感的路也灰常艱辛。不斷尋找你的動力,不斷前進!

8. 別再糾結應該學什麼,開幹!

我一朋友的朋友總是沒完沒了的問我各種磨唧問題。他試圖在正式開始前看清所有可能會搞不定的地方。

這是一種最操蛋的學習方式。正確的方法是:選門語言(Ruby 或 Python)、買本剛出版的書、把自己當個白癡、立馬開始學!立馬開始第一章!有必要就把第一章再看一遍!你根本沒法想象有多少知識是你不知道的!不過沒關係,你會慢慢都搞明白的。大家都是這麼過來的。

祝你好運。

英文原文:Zack Shapiro,編譯:@張飛alex

譯文鏈接:http://blog.jobbole.com/37540/

Want to learn to code? Start here.

Last September, I wrote a post called Want to learn Rails? Start here. which has been pretty successful. I've met and emailed a good amount of people who have follow up questions or are in the middle of learning how to build things with software. I've referred a bunch of people to the post as well. I'm proud that the post is actionable and helpful. Since I wrote that post a while ago and developed my engineering skills much, much further. I wanted to write a follow-up post, some revised thoughts on learning how to code.

This post is intended for working professionals who feels a strong desire to code to build things that they want to see exist in the world. This post is not intended for the person who thinks they should code because they hear so much about it. I mean no offense but I've found those people to be lacking in the short and medium-term fire it takes to learn to actually build software.


1) Nights, weekends are bad

Given my personal experiences and a slew of conversations, I've found that learning how to code only on nights and weekends is a terrible way to go about it. When your brain is not trained to think the way coding forces you to think, it's very easy to lose where you were or not remember a key concept you just picked up. Putting in as much time as possible is your friend.

This point of view is reinforced by programs like Dev Bootcamp which not only require a full nine weeks of your life but also make you pay tuition to attend (which is not a small sum). They make you buy in temporally and financially to ensure your success. You have to throw yourself in or you will fail.

2) Forget Codecademy

“I'm learning how to code! I'm doing Codecademy!”

I don't know how many people tell me this. If I follow up with any of those people six-to-eight weeks later, they've fallen off the boat completely.

Here's why Codecademy doesn't work in the long term:

  • You're coding in a browser which you literally never do outside of Codecademy. Learning the syntax of JavaScript, Python, or Ruby is good but that's about all you get out of the program, in my opinion. You'll learn these skills elsewhere.

  • You don't know how to set up a development environment. Any time you have the slightest inkling to build something for yourself leveraging what you've learned in Codecademy, you can't and probably don't know where to start.

  • You'll need to go through the process of setting up your dev environment which can be incredibly challenging for someone with very little coding experience.

3) Have a real project you want to build

Have something tiny you want to build. One of my first projects was called Today I Learned. It's a text box that you enter stuff into and it shows the date you entered it in descending order. That's all it does.

Your first project is going to be crappy. But it will be done. And it will be done by you. And that's fucking awesome.

4) Everything you build, builds on top of the stuff you've built before

I built Today I Learned and whatever I built next, was better because of one or two concepts I learned while building TIL. You'll constantly be referencing your old code, code other places in the codebase or code from the Internet, once you understand what the pieces mean.

5) Don't copy and paste others' code

Tommy Nicholas wrote a post in December which echoes the same point. You learn things when you write code out. You question what certain pieces mean. Hopefully you Google those questions to learn more and understand more.

6) Stop telling people you're learning to code unless they're technical and you want them to help you

When you're starting out, your goal should be to find a technical mentor or two, not impress your other non-coding friends with the fact that you've taken the first step.

I'm a firm believer that if you talk about what you want to do, you never actually do it. So unless you're talking to someone you hope will be a mentor, close your mouth, put your head down, and keep building.

Loose lips sink ships

7) Coding is failing a ton and understanding why. It's painful and frustrating

The way you learn how to build software is by making the same mistake a few times, learning why that doesn't work, and doing it correctly. The next time you come across a similar problem (and trust me, you will), you'll either remember the way you did it last time or at least the part of the codebase that you struggled in, which you will then reference and remember what you learned from all of that failing.

The rewards for building software are incredible. The feeling of “that came out of my brain” is what I live for. I love it. But the road to get to that point can be tough. Build momentum. Keep going.

8) Stop trying to figure out what you should do and just start.

A friend of a friend kept emailing me with a bunch of questions. He was trying to figure out all of the places he could fail before he even started.

That's the absolute wrong way to go about this. Pick a language, (Ruby or Python) buy a really recent book that assumes you know nothing and just start. Do chapter one. Do it again maybe. The amount that you don't know that you don't know is bigger than you can imagine. Don't worry about that. You'll understand more pieces in time. We all will.

Good luck.

If you have tips for beginners learning how to code, please share them on Hacker News. Your time and effort may really help someone out.

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章