How can I learn to program?
I am in my early twenties and am seriously considering a career in entrepreneurship. I have a partner and we are in the midst of entering our business idea into numerous entrepreneurship contests. We have met with several business and tech professors and have been thoroughly encouraged to pursue this. The only problem? Neither of us know any code. One of our business coaches, a successful entrepreneur himself, suggested that the programming can be done with little problems -that there is still much utility in two idea boys. However, to be truly successful, it has occurred to me that we will need to know the ins and outs of programming. Perhaps we won't need to be experts, but a successful leader must be well versed in every aspect of his company. Does everyone agree? Can anyone make some recommendations about where I should get started learning code and the strategies to keep in mind while doing so? Help is much appreciated.
76 comments
[ 4.6 ms ] story [ 198 ms ] threadTry Mark Pilgrim's Dive Into Python. It's free online, and python is one of the better introductory languages: http://diveintopython.org/toc/index.html
Aside from that, search stackoverflow for variations of your question - it's been answered lots before!
I have to disagree with the book choice - for this case. The first sentence on the main site for the book[1]:
>> Dive Into Python is a Python book for experienced programmers.
It might be a great book, but not for someone who knows nothing about programming.
[1] http://diveintopython.org/
Use a forgiving and simple language like Python, and ideally an operating system where the tools you need are already installed.
Learn the documentation systems for your language of choice. For instance, in Python, you can go to http://www.python.org, run the command-line "pydoc" tool, and use the "help" function in an interactive session.
Use things like StackOverflow and Google (i.e. learn how to find answers and ask questions). These days, help isn't too far away.
Choose some programming goal, even that goal is something arbitrary like reading 20 lines of a text file and printing all the words that start with A. Make yourself write programs that achieve arbitrary goals so that you're satisfied with how well you're learning the language. Do this for a few weeks before you attempt anything remotely related to the "real" reason you learned programming.
And not only write code, but also read code.
And debugging is actually a more useful skill than writing new code, and comes in handy far more often. It also tends to be more painful. But where there's mud, there's brass.
If you happen to try it out, I can answer any programming questions you may have, give you tips, feedback, etc.
Check it out at:
http://blueberrytree.ws
https://www.cs50.net/
I'm in the same boat as the person that posted the original message but I'm currently doing Rails for Zombies (free in-browser interactive course) after first doing tryruby.org (free interactive introduction).
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:
$ sudo apt-get install postgresql
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/
Vim tutorial: http://blog.interlinked.org/tutorials/vim_tutorial.html
/me bias because I'm an Emacs user - but I don't think myself above VIM users...
The problem is, someone who is just starting doesn't even know what to look for. They don't know their mindset or needs, yet.
The OP advice should be taken as "these are good defaults, when you grow older you'll be able to tell what to change and, more importantly, why to change".
I started learning this stuff... my god... 10 years ago.
It took me over a year to figure out that line 1 was the best first step OS (a question I didn't even ask until 4 years in).
It took me four years after that to figure out that line 2 was the best second step (I am on chapter 18 of Mark Lutz's Learning Python, very easy read, the only problem is to not get impatient).
It took 3 years to figure out that line 7 (including line 8) was the best way to go for databases.
10 years ago was the first time I read Greenspun's stuff and decided to march down this path (lines 6 and 10). I still use vim as my primary editor, but I'm learning emacs. Most valuable starter tip on emacs I ever got: you should have hundreds of files open.
That is a great answer.
This is because the first and foremost important thing about learning to program is the desire to do so. The early hackers programmed by directly banging hexadecimal machine code into computers without screens. Were they not programmers? Sure they were. Don't put too much stress on the tools - just program.
Use gedit as your text editor. It's the default GUI text editor in the Ubuntu operating system, and works well enough for programming, and is significantly easier than Emacs for someone just starting out programming.
I'd also suggest MySQL instead of PostgreSQL, for the same reasons (works well enough, significantly easier for beginners).
On the other hand, MBA types will have heard of MySQL -- that might be an advantage, of a sort.
But may I recommend geany instead? Its a pretty good GUI text editor. Alternatively Kate...it is quite awesome too.
Setting up Linux teaches system administration skills. Useful, but nothing to do with programming. Learning Emacs is fantastic (I'm a huge fan), but again — nothing to do with programming. For that matter, writing a blog engine should not be someone's first exposure to programming. Frameworks and web development should be simply banned for people who haven't yet written a Fibonacci sequence generator. Please don't waste your time learning how to integrate other people's services and APIs. You aren't ready for this yet.
Don't think about tools, think about concepts. Learn about how programs flow. Learn about data structures, the basics of algorithms, and recursion. Understand how and why programs are structured the way they are. This stuff isn't hard, and won't take more than a few weeks to learn. Then you should look around at tools and at the kinds of problems you want to solve. In the meanwhile, you'll only slow yourself down if you try to run (e.g., figure out why web frameworks work the way they work) before you can walk (e.g., understand functions).
There are a ton of good resources online. Hacker News is awesome, Stack Overflow, etc. Python has a nice and free online book to get you started.
Best of luck!
Oh, I agree with the need for a good editor. Emacs is great (of course others will argue for VIM of course ;). Unless things have changed in the last release, you'll have to install it yourself which is one of the reasons people choose the lighter weight editor of VIM.
If you have a mac, I would suggest TextMate. I recently came across SublimeText 2 which is currently in alpha stages but is really cool too! It is cross platform so it will also work on Linux.
Painful? It's fun.
Sure, it's difficult, but if he doesn't find difficult things to be fun, he's neither going to be an entrepreneur nor a programmer.
Also there's HacketyHack, Rails for Zombies, CodeSchool.com.
Also there was an old HN thread that is very similar to your situation. http://news.ycombinator.com/item?id=2280070
So my vote goes to PHP + javascript (+node.js) + HTML + CSS
edit: i recommend Ubuntu for development, or if you own a Mac, just install xampp and enjoy.
If you'd like to learn best practices, check out Hunt & Thomas' 'The Pragmatic Programmer' (http://www.pragprog.com/the-pragmatic-programmer).
To get up to speed fairly quickly on what's going on under the hood, check out Petzold's 'Code' (http://www.charlespetzold.com/code/) and Nisan & Schocken's 'The Elements of Computing Systems' (http://www1.idc.ac.il/tecs/).
Remember though - entrepreneurship is not a career. You have to have a solid idea that you can develop into a product - developing and then taking that product mainstream and running that particular business (or working on selling it)is then your career.
Just like non-profit work is not a career - usually people who go into a non-profit work environment have a passion for something in particular, that then becomes their career, which so happens to be for a non-profit entity.
However, if you are either mathematically minded or somewhat into chain-and-bondage, then Haskell might also be worth looking into. I'd suggest reading Raymond Smullyan's "To Mock a Mockingbird" if you want to go down that road.
It's a popular book about combinatory logic. The kind of logic you need for functional programming.
Peter Norvig: http://norvig.com/21-days.html
Eric Raymond: http://www.catb.org/~esr/faqs/hacker-howto.html
Paul Graham: http://www.paulgraham.com/pfaq.html
http://see.stanford.edu/see/courses.aspx
In particular, check out CS 106A.
http://news.ycombinator.com/item?id=2069477
Next, you probably have an idea about where you want to be with your business. Is it mobile? Is it web? I'll assume the latter, because even if it's the former, you're going to need both eventually.
Even though it's not programming, you need to know HTML/CSS. Start there, even though it's not programming. You can get your feet wet editing and you can add programming shortly.
Start with a simple but capable editor. If you're on Windows, start with Komodo Edit or Notepad++. On Mac, something like TextMate. You can always 'upgrade' to Emacs/VIM later.
Once you're comfortable with basic HTML, you'll probably want to make it do things. You can start with JavaScript. This makes programming exercises simple and quick. Just refresh the page.
Once you decide you need a bigger challenge, then a larger world of choices becomes available: what server side language (Python and C# are two options), what server (Linux is pretty standard), what web server (Apache or Nginx are good), what database (Postgres, MySQL, MongoDB, etc...) are some of the many choices to be made.
I would first survey the above and decide what you think you might need, then pick the language based on that. Let's say you pick Python. Start playing with it from the command line or with your editor like you did with HTML. Once you understand the basics, then pick a web framework (like Django) and start making it produce the HTML that you now understand.
It's a stepwise process. The goal is to pick off small, achievable pieces, and then use them to build something more substantial. The core of it all, though, is programming. Programming is how you make the gears turn the way you want them to. Eventually, everything will start making sense and you'll just add to your repertoire as the needs arise.
http://www.youtube.com/watch?v=k6U-i4gXkLM&feature=relat...
Professor keeps everything simple and direct because this class is designed for beginners with no or little programming experience.
2. Search for: "start programming"|"learn to program" site:stackoverflow.com
3. Read:
- http://stackoverflow.com/questions/4769/what-is-the-easiest-...
- http://stackoverflow.com/questions/1858064/so-my-girlfriend-...
- http://stackoverflow.com/questions/335063/whats-the-easiest-...
Then, write a program that works on all major platforms with little or no modifications. Learn C++ or C. Learn how to use a debugger, how to distribute code to end-users, etc. While doing this, learn data structures, big O notation and why they are important when you need to scale. Learn how to handle threaded data safely and Unicode input too.
Just start coding ASAP to solve "real-world" problems (not book exercises), the rest will come as you progress.
Edit: Spelling
To your comment "Solve a specific real-world problem" I would say +1, but add that you should start by trying to solve the smallest possible specific real-world problem that will create some sort of value for your customers.
And before you start, describe that problem using a testing tool like Cucumber (cukes.info). This will ensure that all your early coding and learning is completely focused on solving that one small problem.
Keeping reading, Googling and experimenting until you find you can write enough code to solve that small customer problem. Then set your sights on a slightly larger customer problem.
As for tools, I like and recommend Ruby on the Mac but there are a number of options that seem to have lots of community support and free tutorials, including Python and Perl, whether on the Mac or Linux.
I am quite a lot older than you and I have a child, a company and a girlfriend to manage, so you can probably pick it up much faster than me. Basically I have been forced to take an hour here and an hour there, sometimes more.
I have worked on it a while now but http://www.blueskycouncil.com is my idea of a idea generation website. still lot's of little mistakes but again it was actually having a goal in mind that helped me know how far in the process I was.
So here is what I have done.
1. Sign up for Lynda.com
2. Watch php/mysql for beginners twice, just to get an understanding of the scope that I am about to venture into.
3. Start programming with an idea in mind.
4. Use IRC, StackOverflow and friends
That should take you plenty of the way.
I can also recommend reading books like Code Complete to get a sense of some of the programming issues and paradigms to think of.
- http://mitpress.mit.edu/sicp/ - http://groups.csail.mit.edu/mac/classes/6.001/abelson-sussma...
Once you have mastered this material, learning the specialization of web development shouldn't take more than a week or two of intense study.
Plus, as a bizdev person, you will earn incredible street cred with programmers. MBAs with backgrounds in Lisp hacking don't come along every day.
SICP is truly a masterpiece, but it might not be the best book for someone just starting out who wants to do productive stuff like prototype web apps. Peter Norvig wrote in his review, "I agree that the book's odds of success are better if you read it after having some experience" and I think I agree too, although I'm biased since I only read it after getting a degree in CS. I don't know how I would have felt if I'd read it as a freshman.
Felleisen et al argue that SICP isn't the best intro in their "The Structure and Interpretation of the Computer Science Curriculum" and although I haven't read the whole thing, I think I agree that How to Design Programs might be a better first book. It's certainly easier going, and you couldn't ask for a better environment than DrRacket to get started. And it's also freely available online.
1st ed: http://www.htdp.org/
draft of 2nd: http://www.ccs.neu.edu/home/matthias/HtDP2e/
No comment on HtDP, as I haven't read it. Heard good things about it, though.
You might have higher caliber students than I have had (or am), but I have a hard enough time explaining how to use a text editor in one window and run a script in another. To get to actually doing something useful enough to keep them interested via SICP is, well, beyond even imagining.
While it obviously sucks that your students can't figure out text editors and scripts, I hope to alleviate some of the pain by using Racket, its integrated editor, and the "Run" button on the toolbar.
(But then I am the type who very early learned to avoid what the best professors thought was a good intro text and only trust my fellow students. Because once you see the field as a whole, you have VERY different taste in introductory texts, and more seem to prefer terse and comprehensive overviews which start from first principles, which are also the VERY WORST sort of introductory text possible.)
Don't just learn to learn, because you will forget more than you remember.