Thursday, May 10, 2012

How I learn a programming language

Today I'm going to talk about how I learn a new programming language.  Let me start by saying that I've never fully mastered a programming language, or even come close.  My roles are that of sysadmin and not of an actual programmer.  What generally happens is I'm given some task to accomplish, such as modify an already written report in our home brewed application.  I will dive into the report and figure out where I need to start modifying things. Or I need to come up with a new process, but since the rest of the home brewed application is written in PHP, I'll write the new process in PHP as well, just to keep everything consistent.

I learn programming  by looking at running code and modifying it to do something else or do the same thing but better or more accurately.  I have trouble reading through a book and doing the simple examples and building upon that knowledge.  It comes from already knowing a bit about programming and feeling dumb for re-reading what a variable is and how to assign it (pretty much the same in all programming languages).

At my last position I was able to learn a lot of PHP and I became very comfortable with it. I had worked with PHP a bit prior to this, but honestly, I had forgotten most of what I had learned.  In this case, that is probably for the best, it was all spaghetti code and crap for the most part.  The one thing that helped me the most was a good editor (Netbeans for PHP) and of course documentation.

My new position is with a firm that runs perl for nearly 100% of their code base.  I've always had a hard time reading perl code in the past (Mostly nagios plugins). Perl uses a lot of syntax that doesn't explain what its doing just by reading it in english.  So my typical take something that works and modify it has been a slower process.  I'm able to get the end result that I'm looking for, but I wouldn't say "I UNDERSTAND HOW" this code works or what it honestly does.

This had led me to reading the first few chapters of a book ( so that I may understand the HOW something works and WHY it works, not just that it does. This might be the first programming book I actually read all the way through! So far some of the wizardry of perl is going away because I know or at least know where to look up what "=~" does and not have to guess.  Some other resources I've used is of course  Some of the users there leave answers that don't just give an answer, but explain how and why it works and examples of other ways to do the same thing.

How do you guys learn a programming language?  What tools do you find are the best for learning a new programming language?

No comments: