LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 05-26-2012, 02:36 AM   #1
dman777
Member
 
Registered: Dec 2010
Distribution: Gentoo
Posts: 232

Rep: Reputation: 8
WebServer Scripting- Perl or PHP?


I'm new to WebServer scripting. I was wondering among the community which is prefered these days for it- Perl or PHP?
 
Old 05-26-2012, 02:48 AM   #2
uhelp
Member
 
Registered: Nov 2011
Location: Germany, Bavaria, Nueremberg area
Distribution: openSUSE, Debian, LFS
Posts: 205

Rep: Reputation: 43
I prefer python.

Last edited by uhelp; 05-26-2012 at 02:49 AM.
 
Old 05-26-2012, 06:16 AM   #3
audriusk
Member
 
Registered: Mar 2011
Location: Klaipėda, Lithuania
Distribution: Slackware
Posts: 360

Rep: Reputation: 199Reputation: 199
Actually, you can do web programming in many languages, Perl and PHP being only two examples. People even do it in JavaScript these days (yes, on the server). So, if you know any programming language (especially interpreted one, like the ones you've noted), there's a good chance you'll find web frameworks and other tools for it.

I personally use Python for web programming, but that's because I like Python in general and know it quite well. If you're going to check it out, there are many web frameworks to choose from. Django is probably the most popular, but there are others equally good, like Flask or Pyramid.
 
Old 05-26-2012, 06:32 AM   #4
uhelp
Member
 
Registered: Nov 2011
Location: Germany, Bavaria, Nueremberg area
Distribution: openSUSE, Debian, LFS
Posts: 205

Rep: Reputation: 43
and don't forget the Web2Py Framework.......
 
Old 05-26-2012, 12:36 PM   #5
dugan
LQ Guru
 
Registered: Nov 2003
Location: Canada
Distribution: distro hopper
Posts: 11,226

Rep: Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320
You can't go wrong with Python and Django. Without exception, other Python web frameworks have tried to distinguish themselves from Django not by having more features, but by being more streamlined.

Here's a video about the design decisions behind Web2Py, It should help you make an informed decision:

http://pyvideo.org/video/714/web2py-...d-ideas-we-had

As for web frameworks for other languages, here are two new and interesting ones:

Don't subject yourself to PHP unless you have no other choice. For example, you need to work with existing PHP software, or you've picked out a PHP-only host.

Last edited by dugan; 05-26-2012 at 12:47 PM.
 
1 members found this post helpful.
Old 05-27-2012, 01:14 PM   #6
anomie
Senior Member
 
Registered: Nov 2004
Location: Texas
Distribution: RHEL, Scientific Linux, Debian, Fedora
Posts: 3,935
Blog Entries: 5

Rep: Reputation: Disabled
Quote:
Originally Posted by dman777
I'm new to WebServer scripting. I was wondering among the community which is prefered these days for it- Perl or PHP?
I would say it depends on the size and the nature of the web applications you'll be developing.

I can speak to what I (myself) have done:
  • Small mod_perl web applications that interact with Shibboleth, MySQL, and OpenLDAP.
  • Small PHP web applications that interact with Shibboleth, MySQL, and a local filesystem.

Both required a small learning curve, and neither was particularly painful. I do find Perl to be a much more "natural" language than PHP. (For some reason I always feel like I'm contorting PHP to do what should be tasks that are logically straightforward.)

I'd say it's easy to get up and running quickly for PHP. There's a good reason the language is so popular.

If your web application is large, or if you'll be developing many related applications, you probably do want to invest the time into installing, configuring, and learning a well-vetted framework (as others mentioned).

Last edited by anomie; 05-27-2012 at 01:15 PM.
 
Old 05-31-2012, 11:57 AM   #7
dugan
LQ Guru
 
Registered: Nov 2003
Location: Canada
Distribution: distro hopper
Posts: 11,226

Rep: Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320
If you're even thinking of PHP for any reason other than need, (PHP-only software, PHP-only webhost, etc), then have a look at this:

PHP: a fractial of bad design
 
Old 05-31-2012, 01:48 PM   #8
anomie
Senior Member
 
Registered: Nov 2004
Location: Texas
Distribution: RHEL, Scientific Linux, Debian, Fedora
Posts: 3,935
Blog Entries: 5

Rep: Reputation: Disabled
Good article. I liked his analogy.
 
Old 05-31-2012, 02:21 PM   #9
809areacode
LQ Newbie
 
Registered: Aug 2011
Location: Godthåb, Grønland
Distribution: Debian
Posts: 28

Rep: Reputation: Disabled
I've always been a fan of CGI in C.
 
Old 05-31-2012, 02:37 PM   #10
dman777
Member
 
Registered: Dec 2010
Distribution: Gentoo
Posts: 232

Original Poster
Rep: Reputation: 8
Quote:
Originally Posted by 809areacode View Post
I've always been a fan of CGI in C.
So, instead of using scripting you write C programs and use CGI to interface them?
 
Old 05-31-2012, 03:05 PM   #11
809areacode
LQ Newbie
 
Registered: Aug 2011
Location: Godthåb, Grønland
Distribution: Debian
Posts: 28

Rep: Reputation: Disabled
Quote:
Originally Posted by dman777 View Post
So, instead of using scripting you write C programs and use CGI to interface them?
Exactly. Your server just runs the program and gives the user the output. E.g.:

Code:
#include <stdio.h>
int main() {
   printf("Content-type: text/html\n\n");
   printf("<html><body>Hello, world!</body></html>");
   return 0;
}
Of course, I'd actually separate the HTML from the code, but... you get the idea.

Edit: They do have to be compiled, and given an extension your server recognizes as a cgi script, though.

gcc -o mypage.cgi mypage.c

Last edited by 809areacode; 05-31-2012 at 03:06 PM. Reason: More info
 
Old 05-31-2012, 04:19 PM   #12
lykwydchykyn
Member
 
Registered: Mar 2006
Location: Tennessee, USA
Distribution: Debian, Ubuntu
Posts: 135

Rep: Reputation: 36
It's become popular to dismiss PHP, but it nevertheless works quite well and can be found on nearly any web host. It's just one of those languages (like javascript) that allows you to write bad code if you aren't disciplined.

I've written web apps in Python too. It was nice in some ways, but a pain to set up on the web server and I kept missing a lot of the convenient web-oriented functions I missed from PHP.
 
Old 06-01-2012, 12:20 PM   #13
dugan
LQ Guru
 
Registered: Nov 2003
Location: Canada
Distribution: distro hopper
Posts: 11,226

Rep: Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320
Quote:
Originally Posted by lykwydchykyn View Post
It's just one of those languages (like javascript) that allows you to write bad code if you aren't disciplined.
(The entirety of) PHP itself is bad code written by people who aren't disciplined, so this argument doesn't really work.
 
Old 06-07-2012, 10:20 AM   #14
resetreset
Senior Member
 
Registered: Mar 2008
Location: Cyberspace
Distribution: Dynebolic, Ubuntu 10.10
Posts: 1,340

Rep: Reputation: 62
Don't use Perl for server side stuff. PHP is more just *designed* for that. (with Perl, you might end up having to put large amounts of HTML in print statements, which is hellacious!).
 
Old 06-07-2012, 10:29 AM   #15
Sergei Steshenko
Senior Member
 
Registered: May 2005
Posts: 4,481

Rep: Reputation: 454Reputation: 454Reputation: 454Reputation: 454Reputation: 454
Quote:
Originally Posted by resetreset View Post
...(with Perl, you might end up having to put large amounts of HTML in print statements, which is hellacious!).
I don't think so. Try http://search.cpan.org/search?query=...plate&mode=all .

Though yes, strictly speaking, PHP was designed for web.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] [webserver]cgi/perl or php Wim Sturkenboom Programming 9 02-13-2009 11:21 AM
LXer: Eclipse DLTK IDE for Perl, Python, and PHP scripting LXer Syndicated Linux News 0 02-08-2009 02:22 AM
LXer: How to Install Apache2 webserver with PHP,CGI and Perl Support in Ubuntu Server LXer Syndicated Linux News 0 10-17-2008 06:10 PM
perl vs. php shell scripting nouse66 Programming 2 10-06-2005 02:47 PM
another cgi and shell scripting problem + webserver prinski Programming 6 04-08-2004 04:25 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 09:21 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration