Jump to content

Two-week PHP newbie wants to know the next step on improving


avillanu

Recommended Posts

Last week I finally sat down and did an indepth look at the PHP/MySQL book I had bought years ago. This week I have gone through the basics and finally started coding the simple stuff - basic CMS, user/password system, etc.

 

Right now I feel that given enough time I could program Facebook. But obviously it would be cumbersome procedural code that would be a nightmare to maintain.

 

I don't know what the next step is. All the tutorial sites seem to just cover the basics. I want to learn how to write better code. What should I do?

Link to comment
Share on other sites

Honestly, if you want to become a better programmer I would recommend ditching PHP for a short period of time.

 

I recommend picking up a book on C.  Spend some time learning the syntax and write a few simple CLI programs; the syntax is very similar to PHP so it shouldn't be terribly difficult.  You want to really understand pointers and what's happening there though.  Once you've written a few simple things, pick up a book on data structures and learn how to create simple things like linked lists, queues, hash tables, binary search trees, priority queues, etc.

 

I would then recommend picking up either C++ or Java.  I'd pick C++ over Java since you have to manage your own memory allocations, like you do in C.

 

If you're motivated and spend a bit of time each day on this, you should be back to PHP within a couple of months.  Other than buying a couple of books, you can get all the software you need for compiling your programs for free.  You can become a decent PHP programmer without doing any of this of course, but using a couple of older languages will give you a new perspective on PHP when you return.

 

1)  You will understand on a lower level how a computer works and certain concepts in PHP will just fall into place.

 

2)  You will be able to appreciate everything PHP does for you!

Link to comment
Share on other sites

Honestly, if you want to become a better programmer I would recommend ditching PHP for a short period of time.

 

I recommend picking up a book on C.  Spend some time learning the syntax and write a few simple CLI programs; the syntax is very similar to PHP so it shouldn't be terribly difficult.  You want to really understand pointers and what's happening there though.  Once you've written a few simple things, pick up a book on data structures and learn how to create simple things like linked lists, queues, hash tables, binary search trees, priority queues, etc.

 

I would then recommend picking up either C++ or Java.  I'd pick C++ over Java since you have to manage your own memory allocations, like you do in C.

 

If you're motivated and spend a bit of time each day on this, you should be back to PHP within a couple of months.  Other than buying a couple of books, you can get all the software you need for compiling your programs for free.  You can become a decent PHP programmer without doing any of this of course, but using a couple of older languages will give you a new perspective on PHP when you return.

 

1)  You will understand on a lower level how a computer works and certain concepts in PHP will just fall into place.

 

2)  You will be able to appreciate everything PHP does for you!

For someone who started PHP two weeks ago, I'd have to say that's a pretty bad path to go down. First off, you have no idea what this person is interested in learning or what they want to do with that knowledge. If all (s)he wants to do is learn web development, then getting into those other languages is not necessary at all.

 

When most people ask what languages to learn, people generally tell them to go with what they like. This person has already found a language to learn, and here you are throwing other languages in their face saying "Learn these first." Perhaps learning those worked for you, but not everyone is the same.

 

 

 

For learning about objects and things like that I really wouldn't recommend anything other than the PHP documentation, which can be found on php.net. They have incredibly good details on how to use objects and the like. Getting into placing those objects into organized code is another matter, but it generally takes each person a reasonable amount of time to work that out in their own head. Looking at the source of object oriented open source things is generally a good way to go here, but you don't want to get into anything too complex. A lot can be learned by simply reading code.

Link to comment
Share on other sites

My web host has PHP4. I'd like to develop for PHP4, as it seems many web hosts are still using it... those books were written for PHP5, would I still be able to apply most of the concepts from the books to my PHP4 environment?

 

The PHP/MySQL book I used was PHP5 but I could use 99% of it, just need to change the MySQL connection code and such.

Link to comment
Share on other sites

First off, you have no idea what this person is interested in learning or what they want to do with that knowledge. If all (s)he wants to do is learn web development, then getting into those other languages is not necessary at all.

That's right, the probability of using those other languages for web development is less than 1%.  But I didn't say they should learn them to become a better PHP programmer, but instead to become a better programmer in general.

 

C is a fairly low level language and C++ can be if you choose.  A language like PHP hides a lot of the nitty gritty details; understanding some of those details will make you a better PHP programmer.

 

For example, a PHP programmer can't figure out why their script is performing poorly.  They've narrowed it down to a portion of the script that is doing repeated string concatenation.  Someone who has used a more low level language will tell you the reason is probably because of repeated memory allocation / deallocation on a large chunk of memory.

 

Perhaps learning those worked for you, but not everyone is the same.

To be a better programmer, you really have to understand some concepts at the hardware level.  You will not learn those concepts dealing with a "high-level" language like PHP.

 

Anyways, what I made was a recommendation to become a better programmer overall.  If this person wants to work with PHP only, I'd second your recommendation on reading the manual in terms of objects.

 

Of course, you can't really appreciate the concept of objects until you create them in a language that doesn't support them, such as C.  :D

Link to comment
Share on other sites

i'm 199% with roopurt18 on this one. having a grasp on the general concepts of programming languages is a fine way to teach people how to think for themselves and truly understand what they're doing in a particular language. my own background includes BASIC, Cobol, Pascal, C and C++ LONG before PHP - all of which are similar in many ways but the principles of which are almost identical.

 

Whilst PHP has still been a learning curve for me, it's been relatively easy - "Knowing" PHP is just a memory game to remember all the functions, etc you need. "Understanding" PHP is something that doesnt necessarily require PHP to pick up.

 

And as PHP is written in C and includes many of the same/similar functions, C is a great one to try and understand to get a true understanding of how things REALLY work.

 

Distancing yourself from one particular language but otherwise fully grasping the concepts is a good thing.

Link to comment
Share on other sites

That's right, the probability of using those other languages for web development is less than 1%.  But I didn't say they should learn them to become a better PHP programmer, but instead to become a better programmer in general.

 

C is a fairly low level language and C++ can be if you choose.  A language like PHP hides a lot of the nitty gritty details; understanding some of those details will make you a better PHP programmer.

 

For example, a PHP programmer can't figure out why their script is performing poorly.  They've narrowed it down to a portion of the script that is doing repeated string concatenation.  Someone who has used a more low level language will tell you the reason is probably because of repeated memory allocation / deallocation on a large chunk of memory.

 

To be a better programmer, you really have to understand some concepts at the hardware level.  You will not learn those concepts dealing with a "high-level" language like PHP.

 

Anyways, what I made was a recommendation to become a better programmer overall.  If this person wants to work with PHP only, I'd second your recommendation on reading the manual in terms of objects.

 

Of course, you can't really appreciate the concept of objects until you create them in a language that doesn't support them, such as C.  :D

Right, but most people can still program just fine without understanding those details. Personally, I got "good" in PHP before moving on to learn other languages. With the knowledge from C++ and Java, I learned some, but overall not too much. Albeit, I still haven't even gotten close to what I would consider "good" in either of those languages, but I still understand the concepts involved in the memory usage, and as you mentioned, the data structures.

 

If you haven't had a before and after to compare, can you really see the difference? I did, but I didn't see too much of a difference.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.