tags:

views:

521

answers:

14

I have been working with the Microsoft stack, and would like to get a little bit of experience with alternative stacks, like LAMP, in my spare time.

The P in LAMP, is usually "PHP", but can be Perl (or Python, but I am considering Perl or PHP above Python.). I am gravitating towards Perl, because it looks like it would be useful in other applications, and because Perl seems to have a reputation as 'smarter' and 'better' than PHP.

Pros for Perl:

  • Better reputation. PHP has a bad reputation for having bad design decisions and a lot of bad programs written in it.
  • Can be used for non-web programs.
  • More people seem to LOVE Perl, but even the PHP community is lukewarm to PHP.

Pros for PHP:

  • More webservers have PHP installed already than have Perl.
  • Easier to get started since some of the architectural problems having to do with the web are solved for you.
  • PHP is a popular language that is used for most sites currently on the internet.
  • Knowing PHP seems more likely to be of use in my job.

Since this community seems to be more focused on Microsoft and Java, and that's where I'm starting off from. I'm interested in your opinions.

+7  A: 

For web development, I would say PHP clearly because it integrates better with databases and was kinda designed for the web. Not to forget that almost all webhosts supports PHP, the same is not true for other languages.

However, if the option is there, Python could be a better choice given all the frameworks that are now available, but again from a hosting viewpoint PHP is easy to find, unless you are hosting from your own server.

Sujoy
Care to provide ANY evidence that it has better support for databases? PDO is a ways behind DBI and most people don't even use PDO, it's fairly common for PHP developers to code to database specific libraries.
Trey
PHP programmers usually even don't know about what a placeholder is. And Perl programmers are using them by default.
Alexandr Ciornii
PHP does not have good support for the web. It has poor support for handling HTTP requests, and it has poor support for generating HTML. Adequate, but not great. If you use Perl, you will get *excellent* support for both of those things and more, as long as you are willing to dig into the CPAN.
jrockway
You say this as if PHP lacks those things. If you're willing to dig into PEAR or the countless high quality PHP libraries in the wild, you'll get the same, and PHP has much better out-of-the-box support for all the things you mentioned than Perl.
Andrew Noyes
A: 

Why not continue on the Microsoft stack if you want to get into Open Source?

Try here:

http://www.codeplex.com

As pointed out in the comments by Frakkle, you can even try other 'Open Source' languages while continuing on the Microsoft stack.


Perl:

ActivePerl


Python:

IronPython


Edit:

Since you changed your question, I will add you could also use a LAMC# stack:

The Mono Project

Geoffrey Chetwood
Perl also hops onto Microsoft in IIS very easily:http://www.activestate.com/activeperl/
Frakkle
I think you misunderstand. I want to learn the LAMP stack might have been more clear.
Limesoda
@Limesoda: I am answering what you are asking in your question. You will find plenty of info about learning the LAMP stack on SO.com if you look.
Geoffrey Chetwood
I'm sorry didn't mean to cause confusion, so I changed the post to say LAMP stack instead of Open Source. PHP VS Perl was kind of the meat of what I was asking, Active Perl looks interesting. Thanks, Rich B and Frakkle.
Limesoda
@Limesoda: You changed the entire meaning of the question after you had answers. LAMP != open source at all.
Geoffrey Chetwood
+7  A: 

Why don't you take a look at what open source projects you are interested in and make your decision based on that? I don't think doing it the other way around is particularly smart.

n3rd
+1  A: 

Its a personal decision, the plusses you stated for PHP would push me toward PHP over Perl. But thats just me. There are some who really like PHP, but mostly I think you are right, they are lukewarm to it. But that doesn't mean there aren't good PHP sites.

Nate Bross
+8  A: 

PHP is a very popular language that has an awful reputation because a lot of the design decisions coax the untranied into making computer science blunders in their code. PHP allows the user to easily intermix HTML and domain logic, which is obviously a big no-no in computer science. It is both what makes PHP easy to use and what leads it to be regarded so poorly. If you're a good, disciplined programmer, you can apply good, clean programming practice with PHP.

Perl is fading very quickly and isn't used very much in modern web applications. There are a lot of Perl purists, but I know far too many people who scoff at Perl's syntax as much as they do PHP's.

PHP is a doman-specific language, Perl is not. PHP includes a lot of the nice features you'll be used to from the .NET environment, like validating and sanitizing input and working with a database easily through an ORM. Perl doesn't really have much in the way of doing such a thing natively, so it is almost always easier to work with a framework or web programming library with Perl, much the same as it is with other common CGI langauges, like Python and Ruby. For that reason, if you're looking to get into web programming, I would probably forego Perl altogether than start with one of those other two languages if you choose to not start with PHP.

Andrew Noyes
Voted up. Very insightful. I was counting the non-specific domain of perl as a feature, but you're right. I didn't know PHP had orm or validation, you mean through libraries and addons like cakephp?
Limesoda
Nope, look into PDO and the filter_* functions. PHP can sanitize HTML input, escape characters, and prevent a lot of XSS style attacks "out of the box", and the built-in database functions are a lot more intuitive than those in Perl, and not to mention PDO is a very popular and accessible way to add a little abstraction to your SQL queries. There are some great PHP ORMs like Propel out there, if you're interested. PHP can validate URLs and e-mail addresses. http://us3.php.net/manual/en/filter.filters.valiate.php
Andrew Noyes
Awesome :) thanks.
Limesoda
If Perl is fading, it is fading *slowly*.
Brad Gilbert
http://www.tiobe.com/index.php/content/paperinfo/tpci/index.htmlPerl has been shedding usage on this index like wildfire for some time now. The current standing is actually pretty mild, last time I checked this Perl had dropped a very large number of spots.
Andrew Noyes
TIOBE is flawed, see this article: http://blog.timbunce.org/2008/04/12/tiobe-or-not-tiobe-lies-damned-lies-and-statistics/For Perl popularity, see this page: http://www.perlfoundation.org/perl5/index.cgi?usage_statistics
Alexandr Ciornii
This post is nothing but FUD. I like the use of the expression "computer science". "Stand back... I'm going to try SCIENCE!"
jrockway
Also, how is PHP's database support "more intuitive" than Perl's? You liking something better makes it "intuitive"?
jrockway
Anything I post is inherently my opinion. That's kind of the idea. It has my name next to it.
Andrew Noyes
A: 

If it is Open Source you are after, then choose what ever YOU want.
One of the freedoms of open source is you can do it any way you like it.

Oh, and I would go for Ruby (On Rails)

Itay Moav
+4  A: 

This may upset Perl programmers, but I would learn PHP. From experience its API is a lot more user and newbie friendly and you get visible results faster.

Once you are a few months into PHP, you can then try out Perl and most of its semantics will be familiar, minus the API and modules. Perl has a lot of shortcuts such as "$_" which may take a while to figure out.

The PHP API uses a lot of functions that would be familiar to C programmers, and you get to grips with passing by reference along with some core OO features in PHP 5 (you will learn OO programming in Perl too however, and the syntax really isn't much different).

Another extra: the PHP documentary is extremely good. It has comments and notes for almost all the functions and put MSDN to shame before the proliferation of .NET. It still puts the Javadoc (for the standard libraries) to shame.

My disclaimer - I learnt it the opposite way around - Perl then PHP. Perl was version 5.x and PHP 3.x to 4.x. I haven't used either language for about 5 years now though, but wrote this lot when I did. Also Perl 6 was heralded as a being the future saviour back then (looks like it's still not released!).

Chris S
They are quite different these days. :-)
Andrew Noyes
Voted up because you offer personal experience. This is kind of hard to choose an answer for, because it is not clear which is the answer. Yours has helped me the most so far.
Limesoda
A: 

I'd say PHP first, because it is more widely spread, you will find more help and there is more documentation. Deployment is easier since 99.99% of hosting companies provide PHP support.

Then again, like Itay Moav said, I'd recommend Ruby on Rails... you'll get the real alternative/open source experience ^^

marcgg
+2  A: 

Why either Perl or PHP? Why not Python, or Ruby, both of which have excellent web frameworks available, and are much easier to learn than Perl but much better-designed than PHP.

Daniel Roseman
I didn't like the whitespace requirements of Python, which I know is a silly roadblock. I wasn't think of Ruby when I did this post, that is a good suggestion too.
Limesoda
+12  A: 

Perl has a bunch of libraries which address the web stack (includes ORMs). CPAN is your friend. One of the biggest drivers for using Perl is CPAN.

I would suggest looking at Perltidy, Mason, Catalyst, Template-Toolkit2, Moose, DBI and POE as relevant keywords to start searching, once you learn the basics of the language.

PHP is more "newbie" friendly, in the same sense that VB6 is newbie friendly. You can write code, maybe even good code, but it is significantly harder to write good PHP code.

Asa Ayers: perldoc perlvar is your friend (Also see perldoc perl).

Devdas
Perl is absolutely no different. PHP and Perl have a very similar lineage. Perl, just like PHP, was very popular amongst beginners, which is usually signifies an early death. I once heard that the lifespan of a language popular amongst beginners is "the time it takes these new programmers to become competent programmers". PHP is not only more newbie friendly, its quirks aren't as disastrous as Perl--Matt Wright comes to mind.
Andrew Noyes
I disagree on all points, Andrew. Perl has more libraries and has better language support, including lexical environments, closures, a MOP, etc.Matt Wright did write bad code, but that was nearly ten years ago. A lot has changed since then.
jrockway
+4  A: 

I use both Perl and PHP actively. Typically, I use PHP for web development and Perl for heavyweight scripting tasks. I also help maintain a legacy system that uses Perl for the web language along with Mason.

I used PHP for at least a couple years off and on before I started using Perl (with 5.x). After having used both languages for a while, I find the syntax and usability of the core Perl language to be slightly better than PHP. This is typically on minor things which I suspect are due to the implementation of PHP. For example, the PHP function func_get_args requires that the result be set to a variable. You have to do this:

$args = func_get_args();
return $instance->objectMethod($args);

It isn't possible to do this:

return $instance->objectMethod(func_get_args());

The example shown is a very minor irritation but it is typical of the kind of things that come up. The other typical one is the order of parameters for functions (see the string functions where it varies which parameter comes first instead of sticking to what some would see as a logical idea of always have the string as the first parameter).

On the flip side, looking at the legacy system with Perl and Mason, I have to say that I prefer reading another programmers convulated PHP over Perl with Mason. The issue is that the connection between loading a page in a browser and the code that is executed is quicker to determine. That may be due to how Perl and Mason were used here. I strongly suspect it is.

One other point about Perl is that while CPAN is a powerful thing, the ongoing maintenance of applications that require a large number of CPAN modules can sometimes take more time than one would expect. With that in mind, I try to limit superfluous CPAN module usage.

My recommendation is start with PHP. PHP, while it may have minor annoyances, is quite powerful when used properly with careful thought.

Cymen
Mason is complex - It's like OOP for template. That's why many of us do not use it. Template Toolkit is much simpler and allows more separation of code and design. That's also why you should not use PHP.
Alexandr Ciornii
I actually use Template Toolkit for generating non-HTML content (vender-specific report configuration files). I do like it although it has a few oddities when used in this fashion that I'll not get into here.PHP has plenty of similar options to Template Toolkit. One can mix Perl and HTML or PHP and HTML. Neither prevent bad coding habits. It is the responsibility of the developer to use the tools properly with thought to the next developer coming behind them.
Cymen
+6  A: 

@Asa Ayers

Perl doesn't use magic variables, programmers do. Perl merely offers them.

foreach (@x) {
    print $_, "\n";
}

or

foreach my $x (@x) {
    print $x, "\n";
}

isn't difficult. $_ and @_ are really, really basic in Perl, and are optional. RTFM or Larry Wall's book.

PHP is a God-awful mess. Perl was designed and is supported by brilliant people. PHP is what you'd get if you outsourced the development of a well-thought-out language like Perl to people who spend half their time answering AMEX FAQs, and half their time programming.

xcramps
PHP is a train wreck and there is absolutely no reason to choose it, it offers no advantages (except ubiquitous hosting) over ANY other language. If you don't like Perl (and it is pretty dated, I would not choose it for a new product even though I spent most of my career with it) choose Ruby, Python or Java.
Trey
Perl may have been designed by brilliant people, but that doesn't change the fact that the language has many deep problems that it struggles with to this day, similar problems to those of PHP. I don't dislike Perl and I enjoy using it, but even so, it's far from a well thought out language.
Andrew Noyes
So, what are some of these "deep problems"?
jrockway
+2  A: 

You should pick a small project which you think ought to be doable in both languages and try to implement it in both to compare how you feel about each one.

That is how I made my choice and I haven't regretted it.

Sinan Ünür
+3  A: 

Any *nix or *BSD (including current Mac OS) has Perl installed by default - you can't say this about PHP. Of course any hosting server would have PHP, but they install it (for example when selecting dist installation type).

Perl advantages:

  1. Very good community
  2. Stability, version and OS compatibility
  3. CPAN + cpantesters
  4. Testing orientation
  5. Good Unicode support.
  6. Powerful and fast regular expressions
  7. Tight and fast integration in Apache (mod_perl)
  8. Badly written code is more evident than in other languages
  9. Possibility to extend language with language itself and CPAN. Old Python-style OO system is considered outdated - Moose took it's place. Devel::Declare allows adding new keywords. CPAN has modules even for type safety. Source filters allow adding new languages. Inline::* family allows integrating code in other languages.
  10. Good readability (see http://www.slideshare.net/osfameron/readable-perl-presentation/ )

comparing with PHP:

  • use strict;use warnings;
  • Perl::Critic, perltidy
  • Unicode is integrated into language
  • 'eq' and '==' instead of ==/===/strval/intval

I's recommend to start with CGI::Application framework. It exists in 3 languages: Perl, PHP and Python.

Alexandr Ciornii