Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
How to become a programmer
23 points by lowfat on Dec 18, 2007 | hide | past | favorite | 36 comments
Hello, I have been doing some web programming during the last few months and I'd like to become much better at it. I am trying to learn by reading programming (php) books and doing the practice exercises. I have also tried to write my own code for fun. The problem is that the stuff I do from books are really, really boring! The stuff I do on my own is more fun, but I get stuck quite a bit. Last week I spent an entire day trying to debug why php was not connecting to the mysql db. Once I figured it out, it was great, but I was beat. Is there a better way to learn programming?


"Once I figured it out, it was great, but I was beat. Is there a better way to learn programming?"

No. You found it.


Think of it this way: learning a programming language is learning a completely arbitrary and made up language that is used to talk to a hunk of 80 million silicon switches and try to convince those switches to do something complicated. It's going to take a little while to learn that language.

When I first started studying CS at school, I thought that there was some secret knowledge that the true hackers had that allowed them to program without thinking about it. And alas, I must not have had the hacker gene because I worked at it and worked at it and worked at it until I solved a problem, only to move on to the next problem.

Then, it hit me: That's the secret knowledge. You just have to keep chipping away at it. Eventually you'll become good at it. There's no free ride; it's a lot of hard work.


Actually your analogy is very accurate and just as after you reach a certain level of fluency in a new language you stop thinking about what you are going to say and how to compose the sentence you want, and just say it.


Only thing I'd add is that a mentor can help a lot, though they can be hard to come by.


The way I learned PHP is by developing two apps that I really wanted to build. I set aside three weeks for each app and coded PHP day and night.

One thing I realized was the importance of rhythm. If I code for a day and then come back to it after a week, it was almost like I was starting from zero.

Coding for sometime continuously is a good way to pickup a new language.


This makes sense! Think I will take the 3 days off between the Christmas and NYE holidays and do this! Thanks.


Find someone around you who can program, and somehow get them to mentor you. It's less intimidating, but rather equivalent, if you ask them if they could be available for questions every now and then. I think many people who really like to program will be happy to help you out, as long as you do your homework and show respect for their time.

Ideally, you'd work in the same room as your mentor, but it should be enough if you can meet once a day or so. A longer feedback cycle, or mentoring remotely through the net, is less than ideal, but anything you can get is better than being on your own.

Ask them what language they'd be more comfortable helping you out with. Start playing with that language. For that, follow other advice in this thread. Don't expect to be spoonfed.

If you get stuck in something after giving it a honest try, ask. Every now and then, show them what you are doing, even if you have no immediate problems. Chances are that they can steer you into better ways to think about problems, simplify your code, etc. These are insights that only come through experience. They are often hard to explain out of the blue, and hard to internalize so that you can put them to use later, when explained in abstract terms. They are best communicated in little doses, while commenting on actual code that addresses actual problems. Ideally, your code and your problems.


I think the route to success with programming is much like maths, medicine or indeed any discipline, go for breadth first then depth. Don't spend all your time mastering one aspect, try to learn many different things at once even if you are actually only interested one specific thing. Once you have even just basic knowledge and familiarity with most facets of a field then you will be better equipped to approach any specialization.

So in your case its fine to learn PHP but I would encourage you to look at many different things that are unlike or even the antithesis of PHP. It will help you understand where general computing nomenclature comes from, what the limits of your chosen technology are, how best to implement it in a given environment and ultimately it will give you a much better understanding of the technology itself.


It's always exciting to hear someone eager starting out. The only secret is to keep being interested and not give up on yourself. If you're looking for a fun problem to solve, try writing a brute-force sudoku solver. That could be fun in the context of a webapp. I'd also recommend getting a solid grounding in SQL and designing schemas. You can do a lot of this by brainstorming applications and then working out how you'd design the schema. You don't actually have to write it, and the process can be a good way to get a feel for whether an application will be simple or hard.


There is only one way. You need to pick a problem and then try to solve it. The problem needs to have depth and should require some gumption on your part.

Unfortunately, days when you try and solve one problem for a long time can be common. When you think you are getting into something like that you need to take a 5 minute quite break. Something that gives your concious brain quite time, I find ideas and answers flood in then.


Don't be turned off by the fact that this is geared towards kids more than adults:

http://hacketyhack.net/

It's a pretty decent introduction to Ruby.


There is also "Learn to Program" by Chris Pine [http://pine.fm/LearnToProgram/]. The book is an easy read, moves along well, and best of all, the entire book in one huge Ruby script, so you can dig in there after you are done reading the book for some real work examples...:D


I'm not sure PHP is the best first language.


There is one thing that PHP has going for it as a first language: You can do "cool" things with it almost immediately. It is like making an animated drawing back in the day in [whatever version of] Basic.

Most into tutorials start "this is an int, this is a char, this is a variable, etc." Before you even get to anything interesting you are already dozing off.

With PHP, however, you can hack together your own blog/website show it to your friends and say "I made this." The ability to say "I made this" is the best feature of any language, but usually it is a pretty inaccessible feature for the beginner.


This is so true. The starting developer will feel an immediate response, without (typically) first having to install/configure the webserver, compile code, setup deployment scripts etc.

PHP is definitely not a good language to start programming at first (for that I'd recommend Scheme, ala SICP) but it's definitely a great one for a My First Website project.


I just bought "The Little Schemer." It is rocking my world.


First, ignore the language wars. They are all BS. You want to use PHP, use PHP. Just keep in mind that every language was written for a fairly specific task and it's very good at that task. Don't try to use C to write a server-side script. Likewise, it doesn't make sense to use PHP to write an OS. Try to understand what problem you want to solve and then pick the right tool for the job based on performance, libraries available, community support and past projects that are similar to yours.

Now on to becoming a better programmer:

Find a good project and read some theory books on debugging and how to write code in general (check amazon.com and read the reviews). Books like Code Complete 2nd edition and Beautiful Code. If you want to be more serious about it, the Computer Science series by Knuth will give you all you need to know to get a CS degree, but they are boring so you have to be willing to stick with them. Those books, 3 volumes, are the bibles of Computer Science ( yes, someone will disagree) and as such they are theory. However, you need to know a good deal of that theory to write good software. Specifically, you can concentrate on searching/sorting algorithms, algorithm analyses and machine architecture.

In general, you will find that there is a HUGE learning curve to understand what the computer is doing with your program and how to write code that makes sense, which makes you a good developer. However, the time you invest in learning what happens behind the scenes is worth it's weight in gold, independent of the language you use.

Always try to figure out what the tool/language you are using is trying to do and don't blindly trust it.

Never, ever skimp on comments. You don't have to write a novel and explain that you are adding 2 to variable i, but do explain what the function is doing or what a complex bit of code is doing, this will save you hours when trying to find that bug.

Use a version control tool. The simplest one to use would be Subversion and the book for it is free online. There are also free Subversion hosting services such as http://beanstalkapp.com/.

Depending on how serious you are, you might want to look at the coursework from colleges like Stanford. Many top schools post their coursework with lectures online.

Google is your best friend. Just paste the compiler error and remove any variable names and you will often find people who had the same exact problem with possible solutions. You might have to play with the search string, but you will often arrive at an answer quite fast in this manner.

Try to find mentors on forums and newsgroups. This will take time as you develop relationships with people, but it's the best way to learn as the software development industry is still, very much, based on the notion of apprenticeship.

Try to study some open source projects. Little ones are best, as they are least complicated usually. Trying to figure out what someone else wrote will make you a better programmer in a hurry, because you will notice mistakes people make and how you would like to do things differently.

Lastly, think about which tool/program/etc. that you would love to have or rewrite an existing project in your own style and do it. The first one will be horrible, full of bugs and many many problems, but it will teach you more than most classes you take in school.


"You don't have to write a novel and explain that you are adding 2 to variable i"

Better yet, don't name your variable "i". Name it something like "PartCounter" or "CustCtr". Then you won't have to write many comments. Your code can be largely self-commenting.

As a general rule of thumb (IMO), never name any variable with less than 3 characters and never allow one variable name to be completely contained within another (Ctr & CustCtr). Being able to find every instance of a variable (and nothing else) with a simple editor global search will save you much time and headaches over the next n years. (Oops, I just violated my own rule.)


and, as always, take other people's rules (of thumb) and guidelines with a grain of salt. there's almost always someone who will argue the opposite, all, or part of the time.

( i for one will continue to name my counters i :-) )


A long time ago I started naming mine 'ii' or some variant of 'index' for exactly the reason mentioned (wouldn't confuse search/replace).

Although I often try to avoid using counters at all via foreach or recursion.


1. Read SICP

2. Do the exercises

3. In parallel, choose an open source project and join on that

4. Share with us your experience


PHP is probably a pretty good place to start. I built myself a couple web apps with it years back, having never coded anything previously that wasn't on a TI-82. It's a good introductory language to web programming.

I'm now spending my time on RoR, and I don't think it's a very good language for starters. It's just too much to learn at once.


I guess I should mention that there may be something to the argument that you'll probably want to end up with RoR or Python/Django at some point, so maybe you should start there. But at the same time, if you're not familiar with OOP or MVC, or even basic DB programming, it might just be overload.


When I started coding I found a book that spoke to me -- This is very important because if you get a book you don't like or understand you will not want to learn from it.

And I tend to agree you should probably not start with PHP as your first language. I did, and now all I do is Python and Ruby which are significantly better, imho.


The reason I picked PHP, is that so many open source web stuff seems to be written in PHP and I want to be able to customize these apps (ex: joomla, wordpress, etc). But ultimately I just want to code without thinking and if python or ruby takes me there faster, so be it.


I've been a PHP developer for 6 years and I'm a ZCE. When possible I choose Python over PHP for web related things.

I think the main thing to accept is that if you're going to be coding then you're going to be thinking a lot. If you're not thinking and going on auto pilot then you don't know enough...



I'd also like to add that becoming an active member of a forum helps a little bit, as long as you only use it as a last resort.

For a first project, I'd say, just don't give up, think of something you want to make and dont stop until it's done.


Stand on the shoulders of giants, e.g. use and study good code.


Learn many languages as soon as you feel interested. See programing from as many points of view as possible.


An argument for learning Python:

http://xkcd.com/353/


Join some Opensource project at sourceforge.net


I think participating in a community like this also requires learning so that might be a bit too overwhelming to learn to program, learn to use sourceforge and learn how to participate effectively in an open-source project...

Also, I think it's important not to rely too much on others for acquiring knowledge.


I recommend throwing out the entire field of computers and starting from first principles. Let's put the Ermine back in determine and stop weaseling our way out of deterministic systems.


Where would you begin?


> Where would you begin?

Begin at the beginning and go on till you come to the end: then stop.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: