Jump to content

Is PHP practical for general purpose programming?


Recommended Posts

My main focus is creating websites. I know CSS and html and I know its time to learn a scripting language.  It would be nice to have both a general purpose programming language and web scripting language under my belt. PHP No? Two birds one stone so to speak.  So my question is would it be a good idea to use PHP for general purpose programming or just take the time to learn python also?

Link to comment
Share on other sites

Python is an awesome programming language which has been well thought out, designed and is allot more versatile than PHP simply because there are allot more system programming libraries around.

 

Really though, PHP remains a pretty big contender on the web.

 

Ruby might also be something you might want to look into. It's also a very well designed language, is well web enabled via Rails and is also quite versatile. It's still quite young compared to Python though so there's not quite the amount of libs around but it is quickly catching up.

 

There is always Perl too, though I wouldn't use it for the web.

 

It really depends on what you want to program exactly. Are you a windows user? You might be better off taking a look at C# & .Net.

Link to comment
Share on other sites

Python is an awesome programming language which has been well thought out, designed and is allot more versatile than PHP simply because there are allot more system programming libraries around.

 

Really though, PHP remains a pretty big contender on the web.

 

Ruby might also be something you might want to look into. It's also a very well designed language, is well web enabled via Rails and is also quite versatile. It's still quite young compared to Python though so there's not quite the amount of libs around but it is quickly catching up.

 

There is always Perl too, though I wouldn't use it for the web.

 

It really depends on what you want to program exactly. Are you a windows user? You might be better off taking a look at C# & .Net.

 

Thanks for the help. I will be using linux and thats what had me leaning towards php and python.  With python do I get the best of both worlds(general purpose programming and web development)?

Link to comment
Share on other sites

I would really question what it is that you are going to be doing most of the time.  Python can be bent to do Web development, although it is not as well suited to that as PHP.  It's used a lot in academia and by scientists.  I'm not sure exactly why that is, but I suspect that some of the things I don't like about Python are the very reason people who aren't primarily programmers like it.  For example, in Python, indentation of code is important.  In fact, you really have to configure your editor so that it uses spaces instead of tabs, and things like that.  It's logical, and I guess you could argue that it's terse and efficient not to have to have block delimiters, but I'd rather not have a program not work because I typed an extra space somewhere. 

 

As for php, the biggest issue I've seen with it is in people trying to do socket servers and things of that nature.  The routines in the language are flakey enough that people regularly avoid them and use curl to for example, connect to a web service or server, even those capabilities are baked right into the file handling routines.  PHP doesn't for example, seem to make a great platform for the development of an irc bot, whereas, python does.

 

With that said, you can probably get by with making either language your general purpose language, but I'd certainly consider which task I believe I'll be doing more of and make my decision based on that, rather than which one is more of a swiss army knife.  Sure a swiss army knife could be used to dig a ditch, but if you're mostly digging ditches I'm sure you'd rather have a shovel.

Link to comment
Share on other sites

It's used a lot in academia and by scientists.  I'm not sure exactly why that is, but I suspect that some of the things I don't like about Python are the very reason people who aren't primarily programmers like it.

 

I think the reason it's (Python) used allot in academic situations is because it is very clean and easy to see the point of a programs functionality. Python definitely stretches far beyond that however, entire OS infrastructures are built around it these days (see Portage) and most (if not all) Linux distributions depend on it being installed by default.

 

As for php, the biggest issue I've seen with it is in people trying to do socket servers and things of that nature.  The routines in the language are flakey enough that people regularly avoid them and use curl to for example, connect to a web service or server, even those capabilities are baked right into the file handling routines.

 

I'm not sure how substantiated these clams are either. Iv'e seen (and used) web servers written in php (see Nanoweb) that are certainly robust enough to run most personal web sites.

Link to comment
Share on other sites

The claim is basically from my own experience working on an irc bot, and the fact that it was never really stable, but you can certainly see plenty of other complaints when you read about the file wrappers and issues that they have.  With that said, I know work has been done on the socket routines to make them better.  I don't personally think a web server is a good example, due to the request/response nature of php, but I have always thought nanoweb is a cool project, and I'm sure a lot could be learned from looking at its code.

Link to comment
Share on other sites

  • 2 weeks later...
  • 4 weeks later...

My main focus is creating websites. I know CSS and html and I know its time to learn a scripting language.  It would be nice to have both a general purpose programming language and web scripting language under my belt. PHP No? Two birds one stone so to speak.  So my question is would it be a good idea to use PHP for general purpose programming or just take the time to learn python also?

 

If your application needs to communicate with the web then yes, php can be adjusted to just about every web situation.

Moreover Facebook recently released a tool called HipHop that can convert your php scripts into high-speed c++ binaries.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.