Ask HN: I want to learn how to code. Can anyone tell me how to start learning?
I am a recent college graduate (as of this past May) and I studied chemistry and physics. I have plans to go to graduate school within a year for theoretical and computational chemical physics - that's basically fancy talk for predicting physical interactions between molecules using high performance computing. I have some experience in the field from working as a research assistant as an undergrad and while I never had any problems with the physics, I struggled a little bit with the coding aspect because of lack of previous exposure.
I also read this post "To founders who can't code"
http://news.ycombinator.com/item?id=1761530
It really hit home. I have had two failed ventures thus far which likely would have taken off better if I had the coding abilities to make my own demo. Instead I took the seed funding I received and hired people to do it for me - long story short things didn't work out; I lost money and disappointed people.
The author of the aforementioned post recommends that noncoder founders should: "Take 6 months off and go learn how to code (day and night, weekends including)." This is what I would like to do but I am unsure as to how to begin. Sure, there is a wealth of sources but I am unsure of which ones are quality sources and also what languages to learn first. I am not trying to be a coder or hacker overnight and my approach is methodical: I will devote 8-10 hours per week to learning. I generally pick up things fast; the key though, is having interesting problems to solve which increase in order of difficulty.
If anyone can give me a few pointers on how I can start learning (what resources are good, what language to begin with, a good program of studies) that would be much appreciated as it would help me develop my future ideas on my own and would probably also help with my research. I thought a cool initial project would be an applet which queries each line of a word document with book titles (I keep a running list of all the books I’ve read, one per line in a doc) and searches the net for a picture of a book cover and imports it into the app. Apologies for my ignorance but would this be a realistic project within 6 months?
Lastly, I did run a search on this but didn’t find any related threads; I apologize if this Q has come up before.
Thanks for your advice, AKD
58 comments
[ 2.9 ms ] story [ 136 ms ] threadBreak it up into steps. First write a program that opens a file, reads the book titles and displays them on the terminal. Then write a program that makes some sort of network connection; maybe download the HTML contents of a website. Etc., etc., until you've learned how to do the various subtasks involved with your project, and then assemble it all together.
I'd suggest that Python would be a good language to start with. I personally like the O'Reilly book Learning Python, though there are many options.
plug: It's the tack that I took when writing Quick and Easy Python (http://manning.com/briggs/) - small bits, building on each other.
When I was trying to decide what to learn I narrowed the search down by just heading to the book store and flipping through some books on various languages. Ultimately, I ended up with a choice between Ruby and Python. I couldn't tell what the major differences were, so I just decided to pick Ruby. I figured that there was no real way of recognizing the nuances of ANY language until I actually had one under my belt and could better understand what makes each one tick.
I'm fully aware that this was a somewhat cavalier method of choosing the pal I'd be spending the majority of my waking hours with, but I think that starting anywhere is better than stalling because you can't decide.
So far I'm satisfied with my choice. I think I would have been satisfied with Python too.
So I guess from my experience: - Find a single good source or book for tutorials and learning. Its best for the coding style and teaching style to be consistent. I used a fantastic series of free video tutorials produced by the Walker Brothers, which included 3 entry exams, and a series of lab assignments after each tutorial set. I had to submit the work in order to get access to the next set.
- Find a good Q&A source like Stackoverflow, forums, or a site more specific to what you're coding in. When you get stuck or don't understand something, go and ask (search first). +1 if you have programming friends to ask too.
- Keep a journal (really!) on Google docs. At the end of the night, you can quickly re-hash what you learned (cs concepts, or cool functions you learned), or often write out the things you don't understand. That way, when you start up again, you can do a quick review on where you left off and get back to figuring out things you previously were stuck on.
- Try not to skip past things you don't understand. If you don't understand them, take the time to practice out the code, or look up documentation. A big key point: its always worth it to invest the time to figure little problems out. I once spent 3 hours trying to get some timer controllers working just perfectly the way I wanted. They were actually OKAY to begin with and I was considering skipping past it for the sake of productivity, but in hammering out the problem, I gained confidence and had the satisfaction of solving a problem.
- Get your things WORKING! As beginner programmers, our first concern is making what we want happen. Not pretty code, not computer science theory. Just results. Getting results fast gives you the confidence to try harder things, which will naturally take you into the world of organized code and computer science.
Good luck!
http://www.codeschool.com/courses/rails-for-zombies
Nom nom nom...
Python is easy to learn (not much syntax), easy to read (explicit vs implicit), has a big ecosystem (more packages/libraries), is taught at universities so it's easy to find good programmers to help, and is used by many large websites/companies so it's a good language to know.
Here are some of the best online Python tutorials, including a link to videos and course material for MIT's introductory computer science course, which uses Python: http://www.quora.com/How-can-I-learn-to-program-in-Python/an...
Build something that you want to use so it will be meaningful to you. Do you have a blog? That's usually a good first exercise. It's easy to do using Flask -- follow the tutorial (http://flask.pocoo.org/docs/).
Here are some tips to get you started:
Use Emacs as the text editor to write your code -- it usually comes pre-installed on Ubuntu, and it has a Python mode. Here are some Emacs tutorials (there are some good videos on YouTube too):
http://philip.greenspun.com/teaching/manuals/usermanual/emac... http://www2.lib.uchicago.edu/keith/tcl-course/emacs-tutorial... http://www.gnu.org/software/emacs/tour/ http://cmgm.stanford.edu/classes/unix/emacs.html
Use PostgreSQL as your database. To install it on Ubuntu, use this command:
Use SQLAlchemy (http://www.sqlalchemy.org/) to connect your Python website to PostgreSQL.Here's a good SQL tutorial: http://philip.greenspun.com/sql/
When you build a blog, you don't have to worry about building a public authentication and comment system if you use something like Disqus (http://disqus.com/) -- you just include the Disqus JavaScript tag at the bottom of the blog's entry page.
Here are some good JavaScript tutorials: http://www.quora.com/What-are-good-books-preferably-found-on...
Use StackOverflow to ask programming questions: http://stackoverflow.com/
UPDATE: Here are links to some commonly-used scientific Python packages (http://www.drewconway.com/zia/?p=204).
1) Free software/languages 2) Cut corners (disqus) 3) StackOverflow. This was a super life saver as I never had someone next to me while learning to just ask a quick question. The response time on it is often incredible.
Focus less on your 'platform choice' or whatever, as that can actually be quite fluid. Programming is programming, so spend more time writing code in the beginning I'd say.
Yeah, but programming on Windows is a PITA so I found its simpler to just eliminate that from the equation :)
Windows programming is not a PITA, that's a flat out lie from you. It's total and utter nonsense, especially as Windows has arguably the best IDE of all the platforms.
In the end it's exactly the same as linux programming. And iPhone programming. And BBC Micro Programming. And Spectrum programming. It's just that you have some personal preferences.
Programming is just programming and that's what he wants to learn, not your dogmatic preferences.
The OP says he wants to do a startup and plans to go to grad school for physics, but in terms of programming, he doesn't really know what he wants.
That's why he is asking for advice on what path to take -- he is asking for "preferences," recommendations, and guidance. How many startups do you know that run Windows? How many high-performance physics labs?
When people were asking for faster horses, they didn't know to ask for automobiles because they didn't know that was something to consider. The had no perspective. Helping someone onto a more productive path from the start can help them get to where they want to go faster in the long run.
How long does it take to run a marathon? The OP has a timeline of 6 months.
Everyone should learn sysadmin basics. It's not hard, and in the long run it can be handy, especially in startups with small teams.
Now, if you are doing more researchy work, then a lot of the web stuff is peripheral.
My advice would be to use scipy (the swiss army knife of scientific programming with python), matplotlib (for 2D plots), something for 3D (maybe Mayavi2?), NetworkX for networks, PyTables for storing read-only data, the inbuilt csv library, ctypes or weave for performance ... and domain specific libraries here: http://www.scipy.org/Topical_Software
But don't worry about all that yet. You can hack together a good demo with nothing but scipy and matplotlib.
As for specific languages to learn: startups in particular seem to love Ruby, but honestly, they all work the same way, fundamentally. I crashed through the basics of Ruby in a week, started learning JavaScript, and stopped shortly after realizing that the majority of it was the same code just written differently.
++ to keeping a journal. It keeps you in check, because even though you say will will devote so much time a week to it, you won't. I had to start setting personal goals on a daily basis. That drive alone is helping. Keeping a blog is great for peer support too. I don't get many comments on mine, but it definitely feels good when someone stops by to say, "Hey, this is cool stuff."
Hope that helps, and good luck!
As an experienced programmer with math background using a language I knew, a problem took me 15-60 minutes. Not knowing a language or how to program, it might take several hours, but not weeks.
Now for a language recommendation. I am a Ruby programmer, so I've got a pretty heavy lean towards that.
Ruby is an exceptionally easy language to learn. There's a book called Learn to Program written by Chris Pine (http://pine.fm/LearnToProgram/) which is an amazing beginning to getting into Ruby.
Past that, there's the Well-Grounded Rubyist by David A. Black (http://manning.com/black2) which covers all the things from basic Ruby up to medium-advanced levels of Ruby). There's also Programming Ruby 1.9 by the Pragmatic Programmers (http://pragprog.com/titles/ruby3/programming-ruby-1-9)
If you want to brush up your Ruby skills, the Ruby Koans (http://rubykoans.com/) are also pretty good.
If you're looking to get into web development (well, you ARE on the internet!) then I would recommend learning HTML and CSS with a book such as HTML 5 and CSS 3 by Brian Hogan (http://pragprog.com/titles/bhh5/html5-and-css3). Then a good JavaScript book, perhaps something like JavaScript: The good parts (http://oreilly.com/catalog/9780596517748).
After learning as much of those as you can, familarize yourself with Git by reading the Pro Git book by Scott Chacon (http://progit.org/), or if you choose another version control piece of software (Mercurial, Bazaar are good, SVN isn't and CVS is (I'm pretty sure) the work of demons).
Ah and before I forget, I've got The Developers Code (http://www.thedeveloperscode.com/) bookmarked for late-night reading and I'm quite enjoying it so far. Quite a lot of lessons in there that I have learned over my brief career, but ones I knew from the beginning.
One more final thing: you are new here and people will treat you like that. Be nice to them and they will be plenty nice back. Respect the fact that they have limited patience and may not wish to answer your questions eternally. They may also have other people asking them questions at the same time you are, or have other things they would like to be doing.
You will get better with practice. You show a keen want to learn, which is a great start. Never give it up. Nothing is "too hard" forever. Persist, and for the love of god, practice.
I've been opening Miami Ruby Brigade meetings with these, recommending them to non-pro-Rubyist friends, and did them myself last week. They're a really great exercise.
I spent a year working in high performance computing at a university and so much ugly and inefficient code was written in matlab. Had they written it in python, it would have been much easier to optimize and their research would have been much more productive.
However, I would suggest that Python is probably a better beginner/learning language than Ruby. There are many odd ends in the Ruby language that might easily trip an inexperienced coder up.
So: code as much as possible. As soon as you can possibly stand it, look into MPI4py and start parallelizing your code. Chances are you won't be working with python in HPC contexts, but learning parallel programming at the same time as C or fortran would be needlessly difficult. I would also try to get time on a cluster as soon as you're in a position to use it respectably. Most universities with HPC facilities have an online application for an account, and some sysadmin might take pity on you :) Otherwise, maybe Amazon has some kind of deal?
In the interim, become _very_ comfortable with bash and general command line fu, and a serious text editor. Good luck!
* assignment/sequence
* recursion
* concurrency.
Most students never master the first, and most of those never master the second, and so on. In that spirit, I would recommend that the OP firmly grasp the first two with both hands before reaching for the third. Of the languages the OP could study that treat concurrency or parallelism as a kind of conceptual primitive (e.g. Scala or Erlang), none are likely to appear as working languages in an HPC milieu. Almost always, the libraries are bolted on as an afterthought to traditionally popular languages for scientific computing.
I think this is a regrettable pattern, but a pattern which will shape the OP's daily work if they wish to begin (and remain in) a program in computational chemistry.
All I meant to suggest is that when the OP begins to learn parallel computing, they want to be thinking about parallel algorithms, not segfaults or pointer purgatory or the finer points of scp or vi. The sooner the former can be mentally sublimed, the better the OP will feel about HPC.
A fairly good resource is Google Code University; http://code.google.com/edu/
In particular you may want to start with Python basics; http://code.google.com/edu/languages/google-python-class/ind...
A lot depends on which language is going to be helpful in your computational physics class: you should find out which language they'll expect you to work in.
I don't think I have any further questions - I got loads more helpful advice than I thought I would ever get and again, I'm very grateful. The only couple things I feel are worth mentioning is that I am using a Mac and I have actually written a couple subroutine packages for HPC in FORTRAN but they are nothing too special as FORTRAN syntax is very simplistic.
Since you say you have dabbled with physics, you may find this sort of method useful.
- Eeks, that looks eerily like common sense :-)
That may come across like a smart-ass answer, but it's not. I'm in the same boat, and I'm learning the same way. I've got a Mac dev environment, and Linux dev environment. I'm using a book by Stephen Kochan, and another by Dave Mark.
We're surrounded by a plethora of materials to help us learn.
Just do it! Pick one up and read, and write some code. Stumble through. You will make mistakes.
See emilepetrone and @housefed for a good example of this. He posts on here all the time. He's only been coding for a year, and has a functional website.
If your ventures are web apps, my recommendation would be to learn Ruby on Rails. You will be able to build demo apps within a few months of 8-10 hours per week.
I started with RailsTutorial.org, which is a free book that will take you from installing Ruby to building a twitter clone. From there, get a few books, I recommend Agile development with rails and The Rails 3 Way, and continue to work on some smaller apps. There are also great screencasts you can find by searching for "railscasts."
If you are using windows computers, install Ubuntu Linux which is really easy with Wubi. I have found it makes things easier. If you have a mac, stick with it.
For text editor, I use Sublime Text 2, and if you're on mac, just go with Textmate.
Sign up for Github and learn about version control. Also, go through projects on Github and learn by reading other people's code.
After you have a semi-grasp of the basics, start building something substantial.
Search Stack Overflow when you have questions, and if you've been trying to figure something out for over six hours, ask a question on Stack Overflow.
For html and css questions, I generally just google any issues I have and fool around in firebug, which is a firefox extension that lets you edit html or css and see the changes on your screen.
Best of luck!
Try Google App Engine to get started so you don't have to worry about dealing with a server. Start here http://learnpythonthehardway.org/
Find a copy of http://oreilly.com/catalog/9780596801601#toc for understanding basic ideas with HTML, CSS, JS and Python/GAE.
In the meantime, start a blog and write about your stuggles and the things you learn. Initially it won't really be about coding - but the main thing is showing momentum to the outside world. (Trolls will hate just ignore). By getting your name out there, people will be more interested in helping you.
Start there. If you have questions, my email is emile (at)
Did you hire people with the intent of having them build a demo for you?
And for other readers... Do either of these things happen much? Does it work?
That's not to say the tutorial/source would be completely unrelated, but it sounds like from your post, that coding isn't something that comes easily which means that in order to make the leap to something that you actually want to do, you'll need more than a book to guide your way.
The great thing about a mentor is that they (should) will have a real life problem for you to solve and they can help you work through some of the subtleties of the problem.
I used to think that anyone can learn to code (this was when I was 18). I find, now, that there are people that are more naturally inclined to it and some people that will never be able to, because their brains don't work that way. I would gently encourage you to be open to discovering where you lie on that spectrum and not to be too disappointed if you've tried but still find yourself swimming in molasses.
If you're used to and good at learning in a school format, MIT OpenCourseWare is excellent. My friends also liked the videos better than learning by book.
http://ocw.mit.edu/courses/electrical-engineering-and-comput...
I would go in this general order for beginners. Do all the assignments, and don't cheat. Ask for help on explaining the solution. These courses help in building good fundamentals, then apply what you learn to a personal project.
From there, 6.001, and perhaps the database course (I think experiencing databases is much easier that a taught course)Doing #1 already goes a long way to your proposed project.
I started with MIT OpenCourseWare. I was very fortunate to find this lecture series: http://www.youtube.com/edu?edu_search_query=intro+computer+p... because it is class taught at MIT for students entering the CS or engineering programs that have little or no background in Programming Languages.
Hint: Pay attention in the first and second videos close enough and you'll learn how to locate online resources that are provided to the enrolled students.
so before starting with a small project, try to implement a one person tron / snake game in processing - it helps you to start "codethink".
after that i would recommend reading a shitload of books. if you are into mobile apps, try http://ofps.oreilly.com/titles/9780596805784/ it's basically a tutorial for making a simple web app in HTML, css, js with no prior knowledge required.