How to begin to teach yourself how to code, starting from scratch
jrheard.tumblr.com
jrheard.tumblr.com
I'd find it more frustrating than anything to be confronted with a significant problem right out of the gate.
Learning programming “for learning’s sake” sounds great, but it also sounds damn hard without goals.
I've given a variation of this "how to start programming" email to someone else before, and with that person I made the mistake of not pointing out how programming could be relevant to their daily life; I think that email was significantly less useful as a result, so I'm trying to iterate a little bit.
I can’t say for sure how much fun this’ll be for you: The next time you think to yourself, “I wish this thing worked like this” or “I wish this thing had this feature”, if it’s open source, just load up the code and start playing with it. Your problem might be easier to solve than you’d think.
Something like SICP has problems that are fairly interesting from a mathematical perspective as well as a coding one. I don't know if there's the equivalent for Python, but it might be worth checking.
I have taught two people to program from scratch and I did so with both by finding a project that they wanted to do. One was a character creator for the pen and paper Deadlands and the other was an accounts receivable batch crediting application. Both individuals where self-sufficient in less than a month and where able to search and answer all of their own questions within three.
With my experience, the way I first got into programming was when a friend shows me visual basic many years ago when i was 12. The idea that I could actually "paint" my own application by dragging and dropping buttons, text-fields/etc fascinated me to no end.
It was this fascination of being able to create my own applications that got me stuck into it all. It was never a problem that needed solving.
I saw that you were having a little trouble dealing with some of the proper-noun Concepts thrown at you in Beginning Ruby, and that you weren't entirely sure where to go next in terms of finding exercises not already in the book.
As far as the Concepts go, it's probably best to approach them all as a bunch of different ways of solving the one main problem in programming: complexity[1]. When you're coding anything longer than ten lines, you're usually tackling a problem that's too big to fit into your head all at once. So, you need to break the problem into a bunch of little chunks. Coders do this by building abstractions.
All an abstraction is is the act of deciding you've got a problem ("I need a way to print the contents of the screen!"), solving that problem (by writing code that grabs whatever's being output to the screen, translates it into something the printer can deal with, and prints it), and then hiding that solution from anyone who has that problem. The key here is that you're hiding the solution, but you do expose an interface - a "print_document" function, say - that allows them to benefit from your hard work without having to think about it[2].
That's really what nearly every programming technique is all about: minimizing complexity. So when you see big scary words like Encapsulation and Polymorphism and Mix-Ins, just remember: they're almost certainly just different ways of minimizing the amount of stuff you have to think about at any point in time, and if they're any good at letting you do that, they're probably worth learning about.
Oh! And as far as finding fun exercises to work on goes: Try writing something that'll automate a chore in your daily life. Say, an automated grocery list, or a "books to read" list, or an apocalypse-detector that checks every five minutes to see if Google's down. You know what they say about the sky and the limit and all that :)
-
[1] “Managing complexity is the most important technical topic in software development. In my view, it’s so important that Software’s Primary Technical Imperative has to be managing complexity" - Steve McConnell, Code Complete
[2] "Civilization advances by extending the number of important operations which we can perform without thinking about them" - Alfred North Whitehead
One advice (from beginner to beginner) is to find yourself a good mentor. I've got to know a Rails programmer and he is helping me to get into Rails and giving me advice on good ways to work (using the command line etc) and how to solve problems in Rails.
I need to wrap up this OSX and Windows stuff so that I can actually promote it.
It's looking like a Shoooes 3 release may happen soon, though, and that should help. I'll certainly let you know when it's usable.
i haven't used it, but i think it's aimed at this kind of problem (where to apply them and how to architect your program).
It's the right approach, they teach you the concepts so that you can pick up any language and run with it. It uses Python but it's not about Python, which is a clean language that has a great support system (perhaps the most essential part in learning how to code).
In this case though, I really did stop reading after "as a matter of fact, any self-respecting programmer you’ve ever met is mostly self-taught."
And why did Reba want to learn programming in the first place?
I think she was probably interested for a couple of reasons.
* First, the house we live in has a strangely high proportion of coders, and so she hears us get really excited in our discussions about programming on a pretty regular basis. I think this is probably one of the main reasons that other people who live in the same house have, in the past, asked me the same question she did.
* Second, she thinks coding seems pretty practical; it comes up in a bunch of fields, so it's probably a pretty useful skill to have.
I think that most of the people I know either have no idea what coding is and see it as a foreign and scary thing, or, like her, they think that it must be pretty useful, and are curious about it. It'd be pretty nice if we were able to convert those in the former camp to be in the latter, but I think that what's even more important than that is that people who are already curious about programming should immediately be made aware of the fact that programming is fun as hell.
If you learn PHP:
* You'll be able to see results running in your Web browser a lot quicker
* Your knowledge will be really relevant if you're looking to work on slightly older, more established Web sites like Facebook or Yahoo!, but
* You probably won't learn very good programming practices on your own - PHP has been pretty notorious for this, but maybe this has changed with PHP5, I haven't been keeping up.
If you learn Ruby:
* First you'll have to learn the language, and then you'll basically have to learn a framework like Sinatra or Rails before you'll be able to do awesome Web things
* Your knowledge will be really relevant to most startup-style Web sites begun since 2005 or so (e.g. Yelp, which is written in Python, which is basically sort of like a sister language to Ruby, give or take)
* You'll be much more likely to learn a lot of really good programming practices as you go that will serve you throughout your career.
Having worked with both PHP and Ruby, I'd recommend Ruby, because I think it's easier to learn, it's more fun, and it's a better investment; I'm pretty sure most HNers would agree if given the choice between those two languages, but your sample of respondents is probably pretty biased :)
Googling for help with errors in PHP would be easier I imagine, seeing as more people know PHP. Also, there are a lot of existing PHP scripts that I could build off of.
Those are my concerns.
PHP has been more dominant in the Web world for a longer period of time, that much is definitely certain, and there's a lot of resources out there already. I think this Google Trends chart captures my impression of the relationship between the two languages, though: http://www.google.com/trends?q=php%2C+ruby&ctab=0&ge...
In addition, although you're definitely right in that there must be much more PHP documentation out there, you're not going to have much difficulty Googling for Ruby errors either - just because there will be fewer results doesn't at all mean that there won't be any. Just like in any other programming language mainstream enough to be considered a good language to learn on, any problem you have in that language will have already been experienced by someone else, and there'll almost definitely be an easily found Google result that'll solve that problem.
If you're really on a quest to create web apps and you'd like to invest in knowledge that'll help you and your webapps grow, I'd really strongly recommend learning Ruby (or Python) over PHP.
edit: on closer examination of that Google Trends chart, it looks like a good chunk of the Ruby results are from non-programming-related hits, but I'd still be willing to bet that the overall trend is the same.
I'm a lowly web designer with many ideas for web apps that I'd love to implement/see implemented. Thanks again!
Also, for a well-worded counter-argument to one of my comments, see rick888's post above ( http://news.ycombinator.com/item?id=1163355 ).
Many newer sites are using PHP as well. PHP is used on established sites, but that just means that it's a proven concept. I also see many more jobs for php developers than Ruby (I have seen a few startups using ruby).
"You probably won't learn very good programming practices on your own - PHP has been pretty notorious for this, but maybe this has changed with PHP5, I haven't been keeping up."
I suppose this is true. But I think you can pickup good programming practices in any language.
Another reason to learn php is because it uses a C-style syntax, which will make it much easier to transition to other languages like c/c++/javascript/c#/Java.
Ruby uses a syntax all its own that you can pretty much only use in Ruby.
I also don't feel people should be learning a programming language through frameworks. It's like learning how to add and subtract using a calculator.
What beginners need to learn is programming concepts that they can use in any language.
My enjoyment of programming in Ruby and Python may have something to do with them both being scripting languages, and having easily-accessible REPLs (for the uninitiated: Read-Eval-Print-Loops, like irb, a program I mention and show example output from in my post). In addition, scripting languages just... feel easier. If you've got Python installed on your computer, go ahead and pop up a terminal if you'd like to follow along:
[jrheard@jrheard:~]$ python
>>> import webbrowser
>>> webbrowser.open_new('http://google.com')
True
If you weren't following along: Firefox just opened a new tab with Google in it! Isn't that awesome? How many lines would that be in C? >>> import urllib
>>> goog = urllib.urlopen('http://google.com')
>>> page_source = goog.read()
>>> len(page_source)
6917
>>> page_source[:27]
'<!doctype html><html><head>'
The real power of Python and Ruby is that I can do awesome stuff without even thinking about it. At all. At least half the time I have a problem, the most I have to do is one Google search to find the built-in library I need.The point I'm trying to make is that, syntax aside, I feel like Python and Ruby just get out of my way most of the time, so I can focus on solving problems and learning programming concepts I can learn in any language.
Jeff Atwood sums up a lot of my sentiments in his post "A Scripter At Heart", which you can read at http://www.codinghorror.com/blog/2009/01/a-scripter-at-heart... .
You may have other options, and hopefully someone can correct my misconceptions and fill in the gaps where I didn't mention a good option.
In any case: Ruby (and Python too, as it turns out: http://www.python.org/download/windows/ ) offer installers for Windows and can get repetitive shit done, and are pretty fun to write, so I'd recommend you take a look at either language. I use Python myself.