views:

1917

answers:

20

Having read in lots of places that PHP is looked down upon by lots of people, I'm thinking that I should learn a "good" language for web development to add to my repertoire.

What would be a good thing to learn? Ideally I want something that will teach me good programming habits as well as having a strong community and online manual, I'm used to being able to solve any problem in PHP by using online sources, so that wealth of online info would be useful.

+10  A: 

Python and Ruby are popular options now, often using the Django and Rails web frameworks. Both have very active online communities and detailed documentation, they're probably worth looking into.

Jeremy Banks
+55  A: 

PHP is a good language for web development. It's got its problems, but so does every language; as long as you learn the pitfalls to avoid, there's really no problem.

But do yourself a favor and learn multiple languages (once you've got some grounding in whatever language you start with). The breadth of experience will do you more good than focusing on one language for years on end.

dirtside
A: 

Without getting into the whole PHP debate, the obvious choices are Java servlets/JSP and ASP.net. Both of these let you write in a language you already know (Java/.net) which also means you can reuse classes between server/client applications. And of course there are a lot of tools and established libraries out there, especially for Java.

MidnightGun
+32  A: 

I think the main slam against PHP isn't that there is something inherently wrong with the language, just that the people using it tend to be newer to the net and not understand about sanitizing user inputs and the like. Other languages tend to attract people who've "paid their dues" or got some (usually bad) experience. Telling you to switch to perl or python or java isn't going to make your code any better, if you still don't understand basic concepts like SQL injection attacks, cross site scripting, etc.

So by all means, use PHP if you like it, but learn something about security before you design your app.

Paul Tomblin
In a good web framework I shouldn't have to worry about SQL injection attacks.
finalman
You should ALWAYS worry about SQL injection attacks.
Max
You should always think about security in overall, not just injection attacks.
Cheery
+2  A: 

PHP isn't a bad language. I guess it doesn't really force you into OO as much as other languages, but that isn't neccessairily a bad thing, depends what you want to do.

If you want to continue doing web development, perhaps look into C# with .net, but I am biased :) But you can then take that c# knowledge and then develop winform apps if you wanted to, which is cool.

There are free versions of visual studio 2008 to get your feet wet, but hosting is more expensive with .net than it is with PHP and the like.

qui
A: 

Web programming tends to be quite competitive about the "best" language to have server side. PHP is perfectly fine but it has a few flaws, to my end notably the lack of bitwise manipulation. Perl is a classic CGI language but can be hard to read. Python looks pretty and is easy to program but runs slow, same for ruby.

I have done multiple web sites completely backed by PHP and have never encountered problems through medium load sites.

bmeck
In my 2+ years of development experience in PHP, I have never once needed a bitwise operators; probably because associative arrays fill the void once filled with bitmasks.
Nathan Strong
+8  A: 

All languages are looked down upon by lots of people.

By all means use PHP if that's what you're comfortable with. As in any other language, it's possible to write good PHP code just as it's possible to write bad PHP code. Perhaps look at a framework that encourages good practice, such as CakePHP.

John Topley
CakePHP *shudder*
Steve Madsen
@Steve I have not used CakePHP, but why the *shudder*? Just curious...
alex
Steve Madsen
+1  A: 

You could certainly rephrase this question to be something like, "What should I learn in addition to PHP?" To which I would reply that there are a lot of good things to learn and various languages and frameworks exist that help with many aspects of web development. A couple that I have enjoyed investigating are Ruby and Groovy. I like them because I like convention over configuration in the frameworks Rails and Grails.

Ed.T
+26  A: 

PHP runs Wikipedia and Facebook. If the language can run the #5th and #8th most popular websites in the world reliably, then you don't have much to worry about. Don't learn a new language just because some people are idiotic enough to judge an application by the language it's written in rather than the quality of the code therein. Unless we're talking about COBOL, of course. Every language has its flaws and its critics; any new language you pick up is going to be looked down on by some. That's just the way the cookie crumbles :D

That said, Python rocks, and Django (a Python framework) is Python on acid, so I highly recommend that you look there. Check out Dive Into Python (http://diveintopython.org/) a free online book that gives beginners a great primer on using Python. And then check out Django : http://www.djangoproject.com/

thesmallprint
Facebook is #2 now, [according to Alexa](http://www.alexa.com/topsites).
alex
A: 

Might be worth taking a look at http://stackoverflow.com/questions/115256/skills-in-demand-during-2009.

This is a very subjective question and 10 people could easily give you 10 different recommendations - not least that you needn't look down on PHP as a language. I suggest you take a look at several options and just see what takes your fancy.

For what it's worth, I would advocate going the ASP.NET route as this has a strong community online, lots of blogs and resources (it's got Microsoft behind it after all!), and also gives you the potential to move out from web development into other areas whilst working with the same technologies. You also get to work in a range of languages, so you could for example explore IronPython and IronRuby and gain reusable skills that could be applied outside of .NET in the standalone form of these languages.

Luke Bennett
+3  A: 

PHP isn't a bad language. It has its strengths and weaknesses just like any other language. However, there may be more bad PHP code out there in the wild than there is for any other language. Since PHP is so universally available, many aspiring web developers cut their teeth on a php/mysql application and the results are spaghetti code. This results in a tremendous amount of 'smelly' code out there.

As you stated in your original question, the php community is wonderful, and the online resources are plentiful.

That being said...........if you really want to learn another language, IMO go the Ruby and Rails route. However, if you are interested in learning good habits, solid architecture, and best practices, you can still do this within PHP. Take a look at some of the wonderful frameworks out there like CakePHP, Akelos, symfony, codeIgnitor, etc. These frameworks are all based on tried and true design patterns. Start here if you'd like to learn about some of these.

tyshock
+3  A: 

PHP is going to be around for a while, so your in good company for web development. I would suggest you learn a different language that solves different problems. For example:

I would use Python to prototype large numerical stuff(prime # generator proof of concept).

I would use Perl for system programming with a dynamic language(cron replacement).

I would use C++ for a box and ship application(a media player).

I would use Octave for complex computation(regression algorithms).

J.J.
A: 

Your question ask what you should use instead of PHP. They are other alternative like ASP.NET and Java that are strong to build website. Some other like Ruby on Rail too.

Daok
+4  A: 

If you are doing web programming, you could try python, it has tons of libraries and lots of frameworks. Also, nowadays there's a nice method to bolt your apps to http servers.

Of course, it's a lot of learning if you don't know anything else but php. But it pays up.

I also look down upon php, but I do it because I have lots of bad experience from php. There's probably no way anyone could persuade me to use php. But please do not listen me because of this, find it out yourself!

Myself I like python a lot because I can do bunch of other useful stuff with it as well. And it's rather easy language to learn and use. My experience with it has been pleasing and in overall excellent, as long as performance hasn't been a corcern (if it is, I'll use different language).

Cheery
+4  A: 

I'll echo what the others are saying, being that I was PHP developer for around 3 years: PHP is not inherently evil, rather it is what you make of it. PHP lends itself to the old style, classic ASP, ColdFusion mentality of the unified UI and code structure. I would imagine that is where all the bad vibes are stemming from, and a hatred towards not separating your code from your UI isn't unfounded. A framework such as CakePHP or Symphony can help with this, but so can a simple templating engine ala Smarty which likely has a lower barrier of entry and learning curve.

Use the tool which is best suited to the task. I stand behind that motto, and I've even fought that point with managers, and even one CTO.

I can honestly say, every job I've had in the last 3-4 years had a PHP programmer in residence who was actively working a project. A bad language? No. Bad habits? Sure.

One such project, MyBlogLog, was and still is well known as the little start up that could. Written in horrible, non-oo, non-frameworked, ugly PHP. But you know what? Yahoo still bought it.


That said, as others have stated, learn everything you can. ASP.NET, ColdFusion, Python, and even Perl are great languages to expand your skill set with. Yes, I said ColdFusion and Perl. :)

Abyss Knight
A: 

ASPs

[Upon opening the Well of the Souls and peering down into it]

Sallah: Indy, why does the floor move?

Indiana: Give me your torch.

[Sallah does, and Indy drops it in]

Indiana: Snakes. Why'd it have to be snakes?

Sallah: Asps. Very dangerous. You go first.

- Raiders of the Lost Ark (1981)

Mark Stock
"What is this I don't even"
Thomas Owens
Bring your sense of humor.
Mark Stock
HhahahahahHAHAHhahahahahHAHAHAHA
Fire Crow
+1 for humour, and lols at asp devs :p
danp
+3  A: 

I may be beating a dead horse here, but like some others are alluding to, languages are often optimized designed for a particular job.

PHP is a great tool for building lightweight, database driven web sites like blogs, wikis and aggregators.

If the task requires interaction with Microsoft applications like a corporate intranet, look to .Net to help with the heavy lifting (coming from PHP, C#'s syntax will feel close to home but you'll need a solid footing in OOP).

If you are building something online that can honestly be considered an "Application" (something with lots of data interaction and rules separate from the visual representation), Ruby or Python may be more appropriate.

The list goes on, but the point is to use the right tool for the right job and there are many, many jobs where PHP is the right tool. Learn the other tools for the other tasks you'll be asked to perform.

Rob Allen
+2  A: 

PHP isn't a bad language. It's only considered to be bad as many new programmers get into PHP first due to it's ease and extensive manual. PHP also has flaws with its enforcement of OO and other good programming practices.

You can code perfectly good code with PHP.
Just look at many of Yahoo's projects for proof of this, many are coded in PHP. Facebook is coded in PHP as is Wikipedia, also two of the biggest sites on the net.

The error of PHP is only within the programmer. Have a good programmer and you can produce good code with PHP.

Adam Gibbins
+1  A: 

As others have pointed out here the concept of a "good" language is a pretty fuzzy term.

"good" as in "allows you to develop quickly" "good" as in "encourages good practice" "good" as in "doesn't get in your way and allows you to do what you want" "good" as in "has lots of powerful API libraries available? "good" as in "elegant"

Note that these are not mutually exclusive, so, for example, PHP is probably a great language for developing web apps quickly but probably not so good for helping you get a feel for structure, patterns, etc.etc. Java has a huge set of libraries but is not elegant compared to, say, Haskell or Lisp.

All depends on what you want, really. There are lots of good "right answers".

Steve B.
A: 

I know this is an old question but people keep answering it so I'll throw in my two cents.

After dabbling in PHP and Ruby a bit, I've come to a few conclusions. Anyone feel free to correct me on these points if you've have a different experience.

  1. PHP is easy to learn and has a simple and clear, C-style syntax
  2. PHP has lots of good documentation and examples
  3. PHP is fairly easy to deploy because it's been around a while and everyone uses it
  4. PHP is also a hacked together pile of 10,000 functions so if you like OO it will be frustrating
  5. Ruby is less easy to learn because it does things it's own way in lots of areas
  6. Ruby is very OO, so if you're coming from C# or Java, it seems much better designed as a language
  7. Ruby has been around for less time, and is not so easy to deploy. There a million hackey options, frameworks and tools like Sinatra, Rack, Camping, Passenger, Rails, etc. and you might spend more time sorting them out, choosing one(or more) and getting them installed than actually writing your app.
  8. They are both dynamically typed. If you're coming from C, C#, Java, this can be very frustrating and may produce a lot of runtime bugs until you get used to it. Also, it affects tool support because dynamic types can't have as much intellisense. Notice how all MS devs rave about VS.NET? That kind of assistance is only possible with statically typed, OO languages.

So after all that, I guess it depends on what you need it for. I personally shudder at the idea of supporting a really large business application in a dynamically typed language. Otherwise, I guess I prefer Ruby because it's laid out in a more thoughtful, OO, fashion, but I only use it for small facebook games and utility scripts.

LoveMeSomeCode