

Notes from porting C# code to PHP - moserware
http://www.moserware.com/2010/10/notes-from-porting-c-code-to-php.html

======
mgkimsal
Not sure I've read a more balanced view of PHP's pros and cons as it relates
to a real life programming project (in comparison to another language) in a
long time. Perhaps ever. Nicely done, imo.

~~~
moserware
Thanks! I was tired of all the language-bashing out there and wanted to look
at it objectively.

~~~
mgkimsal
Well, you've done so.

Personally, one of the reasons I think PHP will continue to do well is the
accessibility which is helped with the basic documentation. Can't remember how
something works? php.net/foo. <http://php.net/strpos> \- you get the
'official' docs, along with wiki-ish input from the community about gotchas,
workarounds, extra tips, etc. Makes a big difference to many people compared
to
[http://download.oracle.com/javase/7/docs/api/java/lang/Strin...](http://download.oracle.com/javase/7/docs/api/java/lang/String.html),
for example.

~~~
ceejayoz
Yeah, PHP's docs are one of the truly phenomenal bits about the language. I've
yet to see another language get this as right as PHP does.

------
mattew
The reason we ended up learning php at my company was pure market demand. We
kept getting prospects whose websites written in php and we either learned and
got the business or we said no and missed out. There is a ton of php out
there, and if you want to build your business up on consulting revenue, its
hard not to use it fairly regularly.

~~~
DirtyAndy
I think this is very subjective to where in the world you are. In the UK,
especially in larger businesses, PHP is rare and C# / ASP.NET / .NET are
fairly very common. Rates for PHP are also generally lower.

As an example Jobserve.com, one of the major search engines for jobs here, has
501 PHP jobs, 1,100 ASP.NET jobs, 2,736 .NET jobs and 1,954 C# jobs (search
against UK, Europe and Middle East but most of those will be UK).

~~~
bad_user
Maybe there are more .NET jobs because there aren't too many .NET devs to fill
them? Just a thought.

~~~
DirtyAndy
Whilst I like you logic I don't think this is the case, at least in the UK
market. Trying to find a PHP developer is actually very difficult here,
especially if the work is at a somewhat boring company, I guess they want to
be at start-ups. No lack of unemployed .NET devs (or employed and looking for
a change), although a real lack of quality ones, but I would imagine that is
the case with most dev jobs.

------
erikstarck
There are also lots of good frameworks written in PHP. Wordpress of course (in
June 8.5 percent of all sites were powered by WP) and Drupal and I've come to
really like CakePHP.

Considering the Wordpress numbers I wouldn't be surprised if PHP powers 15% of
all sites on the web, perhaps more.

~~~
Travis
You seem to be pretty close to this guy's analysis of the top 1k sites in
google: [http://blog.sucuri.net/2010/06/google-top-1000-sites-
interes...](http://blog.sucuri.net/2010/06/google-top-1000-sites-interesting-
stats-about-them.html)

He figures that 15.3% of websites are written in PHP. However, the WP numbers
are super low (since these are all huge sites), so I bet that the PHP
percentage is somewhere north of 20% overall.

It's tough to estimate that stuff, though, because of all the parked pages
that are out there.

~~~
erikstarck
Yes and since that 8.5 percent number Microsoft in a surprise move decided to
move all their 30 million Live blogs to Wordpress.com.

------
StanDarsh
Hey, great post. I'm in a similar situation, and I'm not as
intimidated/frustrated as I once was...for now.

------
sp4rki
So basically the author is saying what hackers have been saying all along?
That even tough you can make amazing things with php (though the same can be
said about almost any language), php is still a clumsy language with awful
conventions. No decent programmer is going to tell you that you're wrong to
use php, but that there are so many better languages out there now, that
people should really open themselves to new (or old) but better technologies.

Edit: Don't get me wrong though, I completely agree with your 'review'. But
you came to the conclusion that php is not _that bad_... which off course
doesn't make it _good_ by exclusion.

------
nathanwdavis
Author: I read (well.. began reading) your previous post on the TrueSkill algo
(<http://www.moserware.com/2010/03/computing-your-skill.html>). Great job!!

------
snissn
Why did you want to port your code to PHP (Or anything) in the first place? To
familiarize yourself with the language, or to solve a real problem? Thanks!

~~~
nuclear_eclipse
FTA: _When Kaggle offered to sponsor a port of my TrueSkill C# code to PHP, I
thought I’d finally have my first real encounter with PHP._

------
jasonlotito
Well... that was refreshingly accurate, warts and all. =)

Thank you for writing this. I really enjoyed reading it.

------
terra_t
Not object oriented?

PHP 5 is just as object-oriented as Python, Perl or Javascript. Sure, you can
have global variables and functions that aren't tied to classes, but you can
do that in the CLR too (you just can't write 'em in C#.)

~~~
moserware
(From the alt text on the hyperlink where I said that):

Yes, it has the 'class' keyword, but [it seems] that was bolted on relatively
late and wasn't the primary focus in PHP's design.

See the linked article: <http://michaelkimsal.com/blog/php-is-not-object-
oriented/>

~~~
mgkimsal
That's my post, and I'll clarify a bit.

I worked with numbers of people who all fawned over PHP5, some going so far as
to (ignorantly) say "PHP4 didn't support classes". Of course it did - the
class keyword was there, and I'd done a lot of OO work in PHP4 for many years.

Yes, there's _more_ class functionality in PHP5, but it's not on parity with
some other languages. _AND THAT'S OK_.

My beef was/is mostly with the term "object oriented". PHP as a language is
not _oriented about objects_. Your _apps_ can be, to a large extent, but the
language is not oriented about objects the same way that Groovy or Ruby or
Python is. And it shows.

So.. embrace the function-based nature of PHP's core which allows you to build
OO or procedural based on your needs. Just quit saying "PHP is Object
Oriented" just because it's "Object Capable".

~~~
Jach
Perhaps we should start applying "Object Capable" to other languages like C
and C++ and the Lisp family then? I like your distinction (and your article)
so you get an upvote but I don't really find it that useful other than for
anti-marketing.

~~~
mgkimsal
Personally, I don't deal in those platforms, and I don't work with people
trying to justify those other languages by claiming they're "object oriented".

It was really just a semantic beef I had some time ago, and really would
prefer people embrace the things about PHP which make it useful, rather than
trying to sell it as something where it comes up short.

