Hacker News new | past | comments | ask | show | jobs | submit login
Notes from porting C# code to PHP (moserware.com)
70 points by moserware on Oct 26, 2010 | hide | past | favorite | 25 comments



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.


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


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..., for example.


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.


PHP will continue to do well because it is the most extreme example of the "Worse is Better" (http://www.jwz.org/doc/worse-is-better.html) design style. "Worse is Better" software designs (e.g Unix, C) have shown to be far more popular in the market than more elaborately designed systems (Common Lisp, etc).


The comments are something I avoid about PHP docs. There are lots of bad PHP programmers who feel the need to help everyone else by posting their terrible implementation of X which people then just blindly copy... I like the idea, but in practice, I don't think it works very well.


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.


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).


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


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.


Whereabouts in the UK are you? Less than a year ago, in London, PHP was booming. The PHPLondon meetup was 10% recruiters.


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.


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...

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.


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.


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


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!!


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.


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!


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.


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

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


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#.)


(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/


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".


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.


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.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: