5

Extremely, extremely subjective question here, but its something I've been struggling with for quite a while. I've seriously tried to become a reasonable PHP coder for the past several years. But I've really failed every time. I hate to describe myself as a beginner, b/c I've been designing websites (using WordPress, Drupal, etc) for years, but still I just can't seem get better at programming.

Could it be that I have some kind of allergy to PHP? I went through Chris Pine's awesome into to Ruby about a week ago (for about the fifth time), and though it did all all seem much clearer to me than PHP, I wondered if I was just switching languages to find an easy way out?

The things I struggle with in PHP all seem elementary—when to use a function, how to return database queries in foreach/while statements, when to turn those queries into reusable functions, adding arguments to functions, etc, etc. And all the OOP stuff that I keep seeing these days just files over my head.

I guess my question(s) are: Am I going about learning how to program in the wrong way? Do I have some aversion to PHP that's preventing me from catch on? If I keep pushing at Ruby/Rails, will it just eventually 'click'. Or, the one I fear, am I just unlikely to ever be a programmer?

7
  • 2
    if you are asking "Am I going about learning how to program in the wrong way?" it would be helpful if youtell us how you ACTUALLY ARE "going about learning"? I highly doubt PHP is the issue.
    – Morons
    Jul 28, 2011 at 16:29
  • 4
    For some insight into why you find PHP so difficult, have a look at this: codinghorror.com/blog/2008/05/… Jul 28, 2011 at 16:35
  • 2
    Then, take a look at this whimsical counterpart for Ruby: slideshare.net/vishnu/… Jul 28, 2011 at 16:40
  • Don't loose heart. Programming is hard, that's why it pays as well as it does. Switching languages would only help you if you were getting AWAY from OOP, which isn't the case when going from PHP to Ruby. I suggest trying some JavaScript. Maybe it's direct connection to the HTML page will help you get over the learning curve of clean coding.
    – GHP
    Jul 28, 2011 at 17:32
  • @Robert Harvey - whereas that list would be much easier to learn if you also needed to learn which module to import for each function, eh! I'm no fan of PHP, but the trick with large lists of functions is to only learn the ones you need to use all the time, and to look up the others as and when you need them. It really doesn't matter much whether they're built into the language or provided as libraries. In language terms, personally, I briefly tried Ruby but stuck with Python. And BTW, I've learned dozens of languages, Haskell included - I'm not really prone to giving up on languages.
    – user8709
    Jun 17, 2012 at 21:36

7 Answers 7

8

I recall feeling the same once. You can only go so far without being mentored. You can learn about OOP, and that would be a good start. What worked for me was to go work with some Sr Devs for a while as a Jr Dev. That is how real learning is done. Once you work with a good team and have guidance form an architect you wont have these questions. Books and websites are cool, but when you see something that you dont understand no one will be there to tell you why it is the way it is.

16

Programming isn't about what language you use. Some programming languages to a better/worse job of reinforcing specific concepts (OOP, for example, is available in almost every currently popular language, but only enforced in some), but the concepts themselves are usually a lot more language-agnostic than it seems at first.

"Teach Yourself Language X" books/tutorials are useful, but it sounds like you could use a primer on the aspects of programming that are more universal. If you can, I recommend taking a class. Even a simple 'introduction to programming' course at a local community college is likely to give you a decent primer on how to think like a programmer. Don't worry about the language(s) the courses cover - you can take a course that does everything in Java and still learn valuable lessons even if you never program in Java again.

For the record, I really enjoy programming in Ruby (and I believe that enjoying oneself is a huge factor in the quality and pace of learning), so I'm certainly not telling you to steer away from Rails as an alternative to PHP, if you think it will be valuable. But don't look at the specific technologies too closely when you're asking broad questions about how to learn. Learn, and then look at the technologies you can use to apply your knowledge.

0
8

And all the OOP stuff that I keep seeing these days just files over my head.

I think your problems are more fundamental than just the choice of language. Almost every popular language nowadays has some OOP in it, and usually doing any serious work in it involves the OO part. You really should learn OOP first, and worry about choosing the best language later. Now you're like a ballerina-wannabe who doesn't know the steps, but worries about the choice of shoes.

3
  • 1
    Ballerina-Wannabe? That's just uncalled for.
    – Morons
    Jul 28, 2011 at 16:32
  • @Moron Tellin' the truth, no matter how bad it hurts.
    – quant_dev
    Jul 28, 2011 at 16:35
  • Thanks. This truth certainly doesn't hurt—you're exactly right. I just find that I'm always wondering, "Where does this SQL query go? Into a function? Is this thing an object? How can I rewrite that part to make it generic and use it with arguments instead of rewriting it everytime", etc, etc. I find that I'm never able to see how this tiny piece fits into the bigger picture. I've tried making a To-Do app for example - I just couldn't figure out what my functions should be, or how things should be structured. Maybe some mentorship would do me best.
    – saltcod
    Jul 28, 2011 at 16:56
5

Simply: No.

I know both languages well enough. Ruby is more complex, even if it's 'syntactic sugar' may make it look nicer. And the problems you mention are exactly the same with Ruby anyway. These are structural questions and you have to handle them in every other language.

4

I think a key aspect you have to understand is learning by doing.

Does it really matter, whether you put a query into a function or not? Why does it matter? Answers to such questions will become obvious to you once you write code and try to modify it afterwards.

As an example: In my first year of programming I had written about 50000 lines of code. By now, I may have written half a million or more, of which a quite significant portion had to be reiterated at some moment.

Even though getting help from others is of much value, going through this is the only actual way to find answers to such questions. At first, you will find code you wrote a month ago horrible. Then slowly you will get to a point where you will find code you wrote a year ago horrible. And so on ...

Instead of trying to do it all by the book the first time, just do. And ask here, when you have a more concrete question. We'll be happy to help.

Apparently, there was an interesting study:

  • two groups of people were asked to produce pottery within a given time frame
  • one group was tasked to create an item of the best possible quality
  • a second group was tasked to create as many items as possible of sufficient quality
  • in the end the second group produced the item of the best quality

Repetition (and learning from failure and success) is inevitable on the road to masteryy.

1
  • I agree with the points on repetition. And there's no point trying to learn Ruby this early. Its too OOP specific for you, imho.
    – GHP
    Jul 28, 2011 at 17:30
3

Some languages are designed better than others, but to program well, you need to be able to manage complexity. All languages (well, most) look simple and friendly when you consider tutorial examples, but in the real world, there will be hard problems to solve, regardless of language.

My suggestion is that you try to get better at what you do well. If you are struggling with when to use functions, after several years of hard work, then I suspect that you will never be a good programmer. And the world already has plenty of mediocre programmers, why not choose a vocation in which you can excel?

2
  • Thanks. It's actually less a vocation than a hobby. I enjoy designing stuff for the web and can see hwo knowing how to program would be infinitely helpful—I just can't seem to get better at it. The other big part of the puzzle is that I don't live in a big place, so it's hard to find people to learn from. I think having a programming mentor/someone who actually knew how to program would give me just what I need. So I guess I'm wondering: Can I actually learn this stuff on my own?
    – saltcod
    Jul 28, 2011 at 16:49
  • If you are motivated, I believe you can learn it on your own. The challenge is finding real world situations where you need to accomplish something. THEN you're motivated to keep poking at a process to get to an end result. Just like Math in school... teachers that explain why I can learn from. Ones that don't? No better than just reading the book, which I'm horrible at.
    – Krista K
    Jun 18, 2012 at 20:17
1

I like the answer you accepted and also @back2dos's answer.

IMHO, I believe you would do quite well to take a community college or University class on Intro to C/C++ Programming. I was a lab assistant for that course a few years ago and I feel C translates well to php. The structure is about the same and I actually like php's flexibility and syntax more.

To go on a little about my recommendation, try to avoid classes that go on too much about theory or computer science. You need a nuts and bolts "get stuff done" class like that one.

Not the answer you're looking for? Browse other questions tagged or ask your own question.