views:

967

answers:

18

I've been programming in Ruby on Rails for a year now. I looked at some of the PHP code of WordPress and its e-Commerce plugin. This is not going to sound professional, but it looked disgusting. Having only done development in an MVC framework, I can't imagine how is it possible to work without those patterns. There also seems to be no alternative in PHP to Ruby gems, which are of outstanding quality.

I'm graduating in 3 years. Is it reasonable for me to skip PHP completely? I know a lot of big projects are built with it, but unless they get an equivalent of gems and an MVC framework, the whole thing is very unappealing. What should I do? Avoid PHP employment or plow through it?


Thanks everyone!

Thanks for great answers. Given a chance, I'll find a way to write php in a good MVC way. In other cases, I'll plow through like everyone else.

+2  A: 

Just do what the rest of us do: hack PHP without bothering to learn it.

Shog9
Which explains the general quality of PHP code I've had the misfortune to look at ;)
Andrew Rollings
Not all do that and as alway, in my eye, it's not the right way to 'hack' all the time. Why not learning it and do it cleanly :). PHP as other languages is a tool. You can do bad and creepy things with ruby, perl, python, c#, java, ... the question how much the language restrict you in doing "bad" things.
Gregor
:D :D good one.
Peter Perháč
Gregor, you're absolutely right. But for better or worse, PHP is the VB of web development - everyone uses it, even those who really shouldn't.
Shog9
--which in a way makes it a poor language to learn to program from. I often learn by looking at other people's code. But if you select the wrong pieces of code to look at and learn from, you end up picking up a lot of bad habits. Popular/easy to pick up languages tend to have a lot more cruft to sift through just by virtue of their being popular/easy to pick up.
Calvin
+3  A: 

The best strategy? Don't do it. It's not as if you're going to be unemployable because you don't know one of the huge number of technologies out there.

But keep in mind you may not have seen PHP in its best light in your cursory examination.

The list of technologies I know is far outweighed by the ones I don't know, but I've never been out of work for more than a month in the last 25 years.

paxdiablo
Yeah I think this aren't the best examples of PHP application. However, PHP is a programming language -- what you do exactly with it has nothing to do with the language ;) As Rails is based on Ruby, there are a lot MVC based frameworks based on PHP... so PHP is not at all "disguesting" ;) The question is how you use this tool.
Gregor
+3  A: 

I'm thinking your disappointment in what you saw was generated by you looking at two very complex pieces of code: one a plugin, one a very intensive plug-in-capable library. I'll bet it was all procedurally written, too.

A well written application isn't nearly as scary and PHP is quite easy to learn, and very forgiving (easier?) on things such as type-casting and initializing your variables automatically... I'm sure there's a list a mile long.

That said, PHP is used almost everywhere in some form or another and it is probably worth any professional's time to sink at least a basic understanding into it.

Also, keep in mind that learning how to program in one language is great - but once you really get the ideas down, it's just learning syntax to hop from one language to the next. I am fluent in 3 languages and picking up a fourth (AS3) took me only a few weeks of effort.

Andy Moore
+13  A: 

PHP is the type of language that can be hideous to look at, or very pleasant, depending on the designer/programmer.

I'm sure I could make Ruby look hideous since I don't know it.

Joe Philllips
+14  A: 

Don't judge PHP by the code and design qualities of WordPress. Most people see old PHP 3 and 4 code, and (rightly) go "yuck". The world has moved since then, so if you want better code, look at the source code for something like the Zend Framework instead.

All you've got now is that the code of WordPress sucks, nothing more. PHP can be beautiful as a summers day with clear blue skies, eating pies, no lies, I tell no lies.

You can of course skip PHP, just like you can skip Java, C#, Ruby, Python, LISP or any other that doesn't suit you, unless of course you want to be more than just a Ruby fanboy and live in a bubble for the rest of your life. :)

AlexanderJohannesen
It's surely possible to be more than a Ruby fanboy without subjecting oneself to PHP.
Chuck
I would like to see some _beautiful_ PHP code. I need something to learn from.
donut
+1  A: 

Do give PHP a try. All I have seen of Ruby looks ugly (not exactly disgusting) but I have heard a lot of people say they love it. I started poking around PHP only about a year ago, and never really used it too intensely, but from what I have done I learned that PHP is a really neat language.

I was in a situation somewhat similar to yours. I thought that sooner or later I will be made to understand PHP and I saw a lot of stuff out there is done in PHP, so I borrowed a book from the library, and began to force-study PHP. I tell you, it looked disgusting to me and I returned the book hoping I will just avoid PHP. I couldn't avoid it, as I got a really nice job I still enjoy to this day, and when I was kindly asked to do PHP, I did PHP. And it's NICE. Having direct hands-on experience with makes a world of a difference :) Good luck!

Peter Perháč
+2  A: 

First, do not judge a whole language by just reviewing 1 or 2 applications.

Second, learning PHP is not required in order to be a successful developer. However, knowing only just one language is dangerous. You grow as a developer when you learn different languages.

So if you don't like PHP, just skip it. Learn Python, or Erlang, or anything that makes you happy. :)

Favio
+1  A: 

I'd put money on there being more code out there that is not MVC vs the amount that is. If you're always going to be working on completely green field projects where you get to set the architecture from the ground up, then stick with Rails and don't worry about anything else.

If you ever think that it's even possible that you may work on another system that doesn't have an MVC architecture, you might try to figure it out...

CaseySoftware
+14  A: 

PHP has many MVC frameworks such as:

PHP is as good or bad as the programmer who wrote it. It is the most popular Web platform bar none so to me it seems somewhat naive to try to skip it based on seeing one example that may or may not have been poor written. I say that because you are inexperienced so don't be so sure you even know what "disgusting" is yet.

cletus
A: 

I think you're getting bored with Ruby, is that it ?

Cumatru
+1  A: 

Don't avoid it, because learning PHP, if you're a experienced programmer with some C++like language, could be very easy. PHP has one of the hugest communities and it's very well documented. You'll never get lost. Sometimes you'll see terrorific code, but there's a lot of programmers that code well and organized.

There are many MVC Frameworks for PHP. I recommend you take a look to the Zend Framework, CakePHP or Symphony

xaguilars
A: 

Honestly, I wouldn't avoid a language because you found one project written using it, and the code is hard to follow.

You can make any anything look bad if you decide to make bad decisions when you use it.

Think of it this way, it's another tool to have in your belt.

The best way to learn it? Use it. A friend of mine wanted to learn how to program, to see if he liked it, so he built a Simpson's Quote database. He used php and mysql, and did some mythtv integration, it was quite neat!

Chris
A: 

In my area, there are no PHP jobs that I've heard of. It's generally viewed as a language high-schoolers use to throw together web sites. Fair or not, you decide. Ruby is better in that regard, and I'm not a Ruby bigot by any stretch. So around here, you could completely skip PHP (most have never used it) and it would have zero impact. If you put it on your resume, you'd risk being eliminated as not-a-serious-programmer.

So, here's what I think you should do. Look around your region of choice as to where you want to work. Use Monster or Dice, and find out what's in your area, and include that information in your decision. Whatever languages are lightly used, review them briefly, and that's probably enough. Focus on the languages that you're really interested in, and have more potential for you to work in the industries you want to be in.

Don Branson
A: 

The MVC question seems to have been answered, and others have already pointed out that you shouldn't judge a language by a small amount of code that you've seen. I just wanted to add the "equivalent of gems" for PHP. If you are interested, you can check out PEAR or PECL a gem (for Ruby) or CPAN (for Perl) equivalent.

gpojd
A: 

I think it says more about you than about PHP as a language, it's important to be uncomfortable and get used to learning things you don't want to. After all that's what learning is isn't it.

And it's especially important to learn how to develop without a framework, in order to truly utalize a framework you must know the kind of programming it is composed of.

So my answer is two fold, 1.) Yes learn PHP, and 2.) PHP is the least of your problems when it comes to being employable, get ready for your first job out of school because they things you will need to learn will make learning PHP the least of your concerns.

Fire Crow
+3  A: 

If you plan to be a web developer, you should learn php. Many posters here suggest that you should skip php if you don't like it, but should definitely try learning some new language. Other developers recommend learning php until you can see the beauty in it. But I say, even if php looks ugly to you for the rest of your life, you should learn it, and it should probably be relatively high on your list of things to learn if you want to be a web developer. Here are some common tasks:

Translating an existing site from php

So you're a RoR hotshot? Great! We've been looking for a new webmaster to build our new site. Oh, did I say new? Well, okay, so the customer order forms were implemented three years ago in php by a guy who left the company two years ago. We really need a full on inventory management system, so it would be great if you could implement that, but the order forms need to be recreated or preserved and integrated with the inventory management system.

Adapting an existing technology

What would you have done if you were working for a company that used WordPress as a content management system? You might get to have that thirty-minute bull-session about how ugly the plugin code tends to be, but then what would you do? My company used WordPress, and I had to replace it from scratch. Sure, I had the pleasure of using Django, but we only made this decision after we decided that there was no possible way to get the functionality we needed from a php plugin (and until then we'd adapted it a lot with php plugins).

Translating a site into php

You have a great RoR site. The MVC design clearly respects the boundaries between presentation and logic. And you know that your extensive knowledge of Ruby is going to make maintaining it for any new demand a snap.

Then you get a call from a company interested in white-labeling (rebranding) your product. And they have to host it on some cloud data-center. And it only runs php. Okay, so this scenario has some holes in it, but it's based in something that does happen: you have to produce something for a client who will not or cannot take your input on what language to use.

Freelance work

The next time you need quick money between jobs, you'd be surprised how many posting for freelance web-programmers specify php. I think that organizations willing to debate and choose a web-framework are likely to be willing to pay the overhead to make a new hire. Those who need to get it done right away and not think about it for the time being are happy to specify php.

Of course, if you don't want to be a web developer, don't learn php. Yes, it is always enriching to learn a new language, but if that's your goal, consider Russian.

David Berger
+2  A: 

I think that we can summarise this question as:

I don't want to learn PHP. Should I learn PHP?

Um ... no, obviously!

I mean, is this even a serious question? Or just an half-hearted PHP-bashing?

If you are looking for an example of PHP code that is written cleanly and thoughtfully, with a well defined MVC architecture, then Wordpress is certainly not the best place to find that.

This isn't to say that Wordpress is a terrible application. It gets things done - it just does it with some fairly unpleasant PHP code.

thomasrutter
+1  A: 

I think the question is whether you want to learn it or not, and whether you think it'll affect your job prospects.

PHP really isn't that bad, especially in PHP 5. Admittedly, I do like Ruby better, though.

However, as a programmer, it is always better to learn more languages. The more languages you learn, the wider perspective you have, and you can apply what you learn in certain languages to others.

For instance, right now I could program rather easily in Ruby, PHP, Bash, C#, or C++ (though C++ would be a little rusty). Of course I don't use all of them all the time, and am better at Ruby right now because that's what I use most. But I'm also making a GUI application, which I am using C# for. Further, if I wanted to make a quick script to do something on the shell, I'd either use Bash or Ruby, depending on the complexity. I usually don't use PHP unless I absolutely have to. Either way, C# and Ruby have taught me a lot about OO that I can apply in anything else I might use.

Unless you can guarantee that you have complete control over your hosting environment (e.g., a server where you can install Ruby and Rails), and that every project you do will be hosted on this server, and that you will never need to do a GUI application or other type of software, then I would learn other languages, just in case. Even if you could guarantee the above, it is still good to learn other languages to see what else is out there. Technology progresses quickly, and as developers, we have to keep up, sometimes by learning other languages.

devbanana