[Discussion] PHP Dinosaurs?

  • (2 Pages)
  • +
  • 1
  • 2

29 Replies - 3376 Views - Last Post: 31 January 2011 - 08:29 AM

#1 Dormilich  Icon User is offline

  • 痛覚残留
  • member icon

Reputation: 3550
  • View blog
  • Posts: 10,329
  • Joined: 08-June 10

[Discussion] PHP Dinosaurs?

Post icon  Posted 28 January 2011 - 02:40 AM

*
POPULAR

Hi Folks,

PHP as Programming Language has quite a bad reputation (just ask a C or Java coder). I donít want to discuss that as thatís already been done somewhere. As a PHP programmer who likes his language (otherwise Iíd be coding something else) I want to get PHP the reputation it deserves. IMHO this only works, if people that code in PHP are writing better code and (as it is difficult to change the coding habits you have, esp. if youíre not a Pro) the only way I see is making new coders (of which are plenty enough) code the proper way when they learn.

So, what do you think is necessary to get newbies learning to write good code?



Spoiler


Is This A Good Question/Topic? 6
  • +

Replies To: [Discussion] PHP Dinosaurs?

#2 Dogstopper  Icon User is offline

  • The Ninjaducky
  • member icon



Reputation: 2874
  • View blog
  • Posts: 11,047
  • Joined: 15-July 08

Re: [Discussion] PHP Dinosaurs?

Posted 28 January 2011 - 02:52 AM

I would call myself a PHP programmer. I just don't particularly like debugging it very much (hence why I don't help in PHP as much as I could). Actually, I do more PHP work than any other language I've used up to this point. I think the difference between good PHP code and bad is the way that you handle the HTML. Personally, I use a function templating system, which keeps all the bad code in a single spot, making the rest of my application clean. I'm sure there could be other ways of doing it, but managing the HTML is key to good PHP.
Was This Post Helpful? 0
  • +
  • -

#3 moopet  Icon User is offline

  • binary decision maker
  • member icon

Reputation: 339
  • View blog
  • Posts: 1,185
  • Joined: 02-April 09

Re: [Discussion] PHP Dinosaurs?

Posted 28 January 2011 - 03:15 AM

Oh for the love of god, SERIOUSLY? I wrote a bloody page on this and DIC just send me back to the main page after I posted it.
AGAIN.
Was This Post Helpful? 0
  • +
  • -

#4 Dormilich  Icon User is offline

  • 痛覚残留
  • member icon

Reputation: 3550
  • View blog
  • Posts: 10,329
  • Joined: 08-June 10

Re: [Discussion] PHP Dinosaurs?

Posted 28 January 2011 - 03:17 AM

Iíd like to know how to get rid of mysql_query(), that is the one spot that stings me most.
Was This Post Helpful? 0
  • +
  • -

#5 cfoley  Icon User is online

  • Cabbage
  • member icon

Reputation: 2044
  • View blog
  • Posts: 4,226
  • Joined: 11-December 07

Re: [Discussion] PHP Dinosaurs?

Posted 28 January 2011 - 03:35 AM

View Postmoopet, on 28 January 2011 - 10:15 AM, said:

Oh for the love of god, SERIOUSLY? I wrote a bloody page on this and DIC just send me back to the main page after I posted it.
AGAIN.


Stupid PHP script must have screwed your post up. :P
Was This Post Helpful? 0
  • +
  • -

#6 baavgai  Icon User is offline

  • Dreaming Coder
  • member icon

Reputation: 5881
  • View blog
  • Posts: 12,758
  • Joined: 16-October 07

Re: [Discussion] PHP Dinosaurs?

Posted 28 January 2011 - 06:05 AM

Use functions. And minimal globals. Constants are fine. In fact, use constants too.

Well, that's pretty much what I'd tell a new programmer in any language, I guess. PHP suffers from a huge volume users that are learning it as a first language. Tons of pages in the wild look like a beginner's C or Java program, where everything is stuck in main and there is a lot of cut and paste going on.

I don't know a solution other than learning and experience. PHP is my first choice for web dev. It's advantages are also it's disadvantages. It allows sloppy coding with the extra bonus of all that messy markup getting in the way. Sometimes you don't need a function, or a class, and just want what's essentially SSI. When you take that mentality to larger problems, it gets ugly.
Was This Post Helpful? 2
  • +
  • -

#7 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 6076
  • View blog
  • Posts: 23,543
  • Joined: 23-August 08

Re: [Discussion] PHP Dinosaurs?

Posted 28 January 2011 - 06:07 AM

Quote

PHP suffers from a huge volume users that are learning it as a first language.


And...they're learning from crap code on the Internet!
Was This Post Helpful? 0
  • +
  • -

#8 Dormilich  Icon User is offline

  • 痛覚残留
  • member icon

Reputation: 3550
  • View blog
  • Posts: 10,329
  • Joined: 08-June 10

Re: [Discussion] PHP Dinosaurs?

Posted 28 January 2011 - 06:09 AM

too bad the internet doesnít forget.
Was This Post Helpful? 0
  • +
  • -

#9 atik97  Icon User is offline

  • ???
  • member icon

Reputation: 144
  • View blog
  • Posts: 715
  • Joined: 16-September 08

Re: [Discussion] PHP Dinosaurs?

Posted 28 January 2011 - 06:28 AM

Most beginners don't realize necessity of good practices, they believe good practices are for experts and novices don't need to worry about it. Thus they develop a habit of using not so good or worse practices. Once they adopt a practice which is working, they usually like to move ahead with it, even after pointing out towards better practices. So, i think they should be familiarized with good practice right from the beginning.
Was This Post Helpful? 1
  • +
  • -

#10 Shane Hudson  Icon User is offline

  • D.I.C Technophile
  • member icon

Reputation: 343
  • View blog
  • Posts: 1,286
  • Joined: 06-December 09

Re: [Discussion] PHP Dinosaurs?

Posted 28 January 2011 - 06:39 AM

Well, as I and many other PHP Programmers learned PHP from working with some form of CMS (whether it is a full CMS, a blog or even forum software, I personally learned from Wordpress) I would recommend getting those communities involved with best practises.

For instance, I always thought Wordpress was great (and I still do), it is often perfect for my clients and I enjoy using it. But it was not until I spoke to some python programmers over at the Forrst.com IRC that I realised that many people believe the backend of Wordpress is very poorly written.

If the backend of a very large piece of software like that is not written well, then how can we expect new programmers to write well?

My code is not terrible, but I am sure it is not great either.
Was This Post Helpful? 1
  • +
  • -

#11 moopet  Icon User is offline

  • binary decision maker
  • member icon

Reputation: 339
  • View blog
  • Posts: 1,185
  • Joined: 02-April 09

Re: [Discussion] PHP Dinosaurs?

Posted 28 January 2011 - 06:46 AM

Right. If you want to start here, the best thing I think you can do is set PHP challenges, like those that're getting popular in other language forums.
People will enjoy learning, trying to do better than others and explaining what they did that was so clever. They will also get ripped into by people telling them how bad doing X is.

Second thing, get newbies to start with PHP5, learn OO, learn the difference between client-side and server-side code, learn NOT to mix HTML and PHP in every file, learn NOT to just use PHP to echo out truckloads of HTML and learn that NOBODY wants to help with their mafia wars game.

This post has been edited by moopet: 28 January 2011 - 06:47 AM

Was This Post Helpful? 3
  • +
  • -

#12 CTphpnwb  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 3030
  • Posts: 10,567
  • Joined: 08-August 08

Re: [Discussion] PHP Dinosaurs?

Posted 28 January 2011 - 06:57 AM

You probably already know what I'm going to say: Code separation.

Languages like C are highly structured. When a C coder looks at a php file that switches back and forth between two (or more!) languages they're seeing an unstructured mess.

The ability to mix html with php is a convenience that should not be taught to beginners because they will inevitably abuse it, and that will lead to them becoming completely confused by their own code. If you really want to improve the reputation of php, then get them to separate their code before helping those that do mix the two. Toward this end, I'd also try to keep beginners away from Dreamweaver, which although I don't use it so I can't say from experience, seems to encourage them to mix languages liberally.

This post has been edited by CTphpnwb: 28 January 2011 - 07:00 AM

Was This Post Helpful? 3
  • +
  • -

#13 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 6076
  • View blog
  • Posts: 23,543
  • Joined: 23-August 08

Re: [Discussion] PHP Dinosaurs?

Posted 28 January 2011 - 08:37 AM

Quote

Languages like C are highly structured. When a C coder looks at a php file that switches back and forth between two (or more!) languages they're seeing an unstructured mess.


As I've stated before repeatedly...if only this were true! :)
Was This Post Helpful? 0
  • +
  • -

#14 Guest_surgbc*


Reputation:

Re: [Discussion] PHP Dinosaurs?

Posted 28 January 2011 - 09:55 AM

View Postbaavgai, on 28 January 2011 - 06:05 AM, said:

and there is a lot of cut and paste going on.


Very true. Too much copy and paste. But that's the way I learnt Php.
Was This Post Helpful? 1

#15 CTphpnwb  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 3030
  • Posts: 10,567
  • Joined: 08-August 08

Re: [Discussion] PHP Dinosaurs?

Posted 28 January 2011 - 10:27 AM

View PostJackOfAllTrades, on 28 January 2011 - 11:37 AM, said:

Quote

Languages like C are highly structured. When a C coder looks at a php file that switches back and forth between two (or more!) languages they're seeing an unstructured mess.


As I've stated before repeatedly...if only this were true! :)

Which part? If you mean that C coders are able to create spaghetti code too, then I absolutely agree. Still, the process of learning to write code in any version of C involves much more learning to structure your code than PHP, where many people with years of experience write awful, disorganized code. Beginners will write bad code in any language. PHP's problem is that many "experienced" developers write bad code, and I blame that on the lack of code separation.
Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2