Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


Why PHP still exists
New on LowEndTalk? Please Register and read our Community Rules.

All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.

Why PHP still exists

RaymiiRaymii Member
edited March 2013 in General

Came across a very interesting article about PHP. Nowdays I have a few clients that are programming shops in the rails/django field, and most guys there won't touch PHP with a ten foot pole. But I (still) see php as a good tool when it gets the job done well, and in most cases it does.

Here's the first part of teh article:

When people complain about PHP being a horrible language, not fit for human consumption, they will often talk about how the features of their favourite language are far more refined; have been designed with elegance in mind; are consistent and secure. And you know what? They're right.

But PHP is still a better tool.

When people write very long blog posts about the horror that is PHP, which lead to double-clawed hammers being created, then they're right.

But that double-clawed PHP hammer is still a better tool.

And it shouldn't be. It really shouldn't. I want another language to knock PHP out of the way. I want to use python wherever I now use PHP. Heck, I'd even take Ruby or Java. I can't, though, because PHP does one thing really well that no other language seems capable of doing.

It works, out of the box, for people who don't know what they're doing. The install process for the vast majority of PHP projects comprises of the following steps:

1. Put files here.
2. Done.

"Installation" of database then takes place inside the application. It's configuring, not installing; the application is already running.
[....]

http://blog.samuellevy.com/post/41-php-is-the-right-tool-for-the-job-for-all-the-wrong-reasons.html

What do you guys think of PHP?

«1

Comments

  • JacobJacob Member
    edited March 2013

    PHP is easier and I suppose more commonly taught and known.

  • I like PHP, I like the syntax and I personally hate the java/python syntax. Don't mind python that much. PHP is not very lightweight either, I'd rather start learning C.

  • Just because something is "easy" this doesn't imply its "simple" or even "effective".
    I don't like php. It provokes unstructured spaghetti code.

  • GetVMGetVM Member

    PHP is easier, i like it

  • Because we still need it...

  • Why COBOL still exists?

  • support123support123 Member
    edited March 2013

    Because this forum runs on php :)

  • Because PHP is still actively being developed, not just applications but also the actual back-end code... What a retarded idea to discontinue PHP, it's a good language, but I also prefer daemon based setups like node.js, python etc rather than spawn based like PHP, ASP etc

  • PHP is successful and will continue to be because it is economical. It is easy to get programmers that can write PHP code because it's easy to learn. And most specially, it is cheap to host.

  • I honestly hate the "newer" syntaxes that are coming from programming languages. They're trying to make them more fluent, and similar to English. But in all actuality, they're deviating from the well-established norm of ALGOL/C-style syntaxes.

    One of the biggest reasons why I use PHP is because it serves a purpose. It's not hard to properly design something with PHP. Sure, the language has inherent flaws, but it's nothing you can't design around. The arguments that PHP should go away is an excuse for not wanting to properly design applications. The syntax is also a bit clunky to me. I hate loosely-typed languages and I wish PHP didn't have things like the "function" keyword. I wish it was more of a C/C++ style syntax, but otherwise, I find it better than Python (which I would only use Python as a pipe between two applications that are written in different languages).

    I've been saying it for years about all sorts of programming, colleges intro their computer science courses with Java because it's easier and this century, on a whole, is turning out poorer and poorer programmers (not saying there aren't some gems out there) because of the way society is trying to teach us how to program. It's hard, it's supposed to be hard, and knowing how things work under the hood is important.

  • It works, out of the box, for people who don't know what they're doing

    And that is why 99% of the people that use PHP use PHP.

  • i was using PHP, then start playing around with ruby and python, now i'm back to PHP. i don't know why, maybe it's just my habit.

  • flyfly Member

    @Raymii said: "Installation" of database then takes place inside the application. It's configuring, not installing; the application is already running.

    drag and drop, FTP, cpanel

    anyone who knows that the internet is a series of tubes can install wordpress

  • I would really like to try out Python. What prevents me from doing so is that there is no docs for Python.

  • erhwegesrgsrerhwegesrgsr Member
    edited March 2013

    @Spartan said: I honestly hate the "newer" syntaxes that are coming from programming languages. They're trying to make them more fluent, and similar to English. But in all actuality, they're deviating from the well-established norm of ALGOL/C-style syntaxes.

    That's not true, just because some hipster languages like Ruby kick in doesn't mean all the new ones are like that.

  • @Damian said: What prevents me from doing so is that there is no docs for Python.

    o_O?
    How is that???
    It has docs, lol

  • gaaraigaarai Member
    edited March 2013

    For years, I worked at a shop developing Perl code for a custom CMS. At the time, I loved Perl and thought PHP was a childish language. For the past few years, I've worked with PHP since I develop WordPress solutions.

    I still think that PHP has some terrible design concepts. Functions that have similar arguments may swap the order around randomly. Some functions use underscores while others don't. Some functions use full words while others use shorthand. It's a mess really.

    The reason that PHP just works is that well-written PHP code can work on just about any server environment without any tweaking or troubleshooting. This is where the "it just works" concept comes into play.

    With Perl, you often end up relying on tons of CPAN modules since they do so much heavy lifting for you due to the language itself being very light. Doing this makes your code extremely unportable as those CPAN modules may or may not exist on the desired host system. You usually end up making scripts that allow you to take a system and install the CPAN modules on it. And you had better hope that those CPAN modules install without any problems or conflicts, or else you'll have hours of troubleshooting and manual module installation in your future (I've even had to hand-modify some CPAN modules to make them work on some host systems as they weren't very portable). Try doing something like this with code that you write for use by random people that are putting your code on random systems. It simply won't happen without giving away tons of support and/or writing tons of docs.

    I feel the same way about Ruby. I know a company that develops software purely on Rails. This software is meant to be installed on client systems for various types of applications. I heard that it was so hard to actually migrate the code to other servers that the entire development team spent three days trying to get it to work on a new developer's test environment, failed, and then simply gave him full access to the development server. I never heard if that project actually launched.

    I also experienced this issue when trying to install a Rails-based bug tracker on one of our servers. I spent six hours trying to install it (while following the guide 100% over and over again), and it simply refused to work. It seems that the installation guide was written for a CentOS server running specific set of RPM repos while I only had an Debian server available for that application. The Ruby packages used required specific versions of specific packages which did not exist on the system. I ended up removing tons of packages and compiling/installing the needed package versions by hand. After far too long of screwing around with the system (likely causing all sorts of future stability issues), I ended up giving up and reverting the changes. I then installed an inferior, PHP-based bug tracker. It only took me five minutes to have it up and running.

    I don't have personal experience with it, but I've seen similar "dependency hell" problems with Python. I'm not a fan of the syntax, but I can get passed that just as I got passed PHP's function mess. However, I refuse to get involved in developing code that is tough as hell to implement on production servers and likely require root just to get the dependencies taken care of.

    PHP has PECL, which is a sort of inferior, PHP version of CPAN. However, I know of basically 0 big projects that make use of any of those libraries. In addition, the language itself is very stable with regards to backwards compatibility. I have a set of code that is compatible with the first version of PHP 4 through the latest PHP 5.3 release. It wasn't hard to do, I simply avoided functions that were released after the first version of PHP 4 and didn't use some of the PHP 5 syntax. The code was even compatible with PHP running the Suhosin patch. Thousands of customers ran this code on their random servers ranging from shared to dedicated resources and *nix to Windows hosting, all without a hitch.

    This is why you see projects releasing with PHP. If you do your job well (or simply have a basic understanding of what you are doing), your code becomes extremely portable and reduces your support load with people complaining that the code doesn't work on their system. In addition, many of the above-mentioned languages that quickly get into dependency hell often require root-level privileges to fix the problem. Try shipping such code to users that run shared or managed hosting. It likely won't work out well in the end.

  • asolarasolar Member
    edited March 2013

    php is the most popular script, already have lots of popular open-source software and all OS support it, which make it more popular in return. It's not likely there will be a new script or program language to challenge it's market share within 10 years. Not to mention of replacing it. So I will just stick to php

  • raindog308raindog308 Administrator, Veteran

    php is truly the worst of the major scripting languages. It's inconsistent, has a syntax that is different for the sake of being different, etc. It brought nothing new to computer languages, which is why it is so derided.

    I'd rank the the major scripting languages as python, perl, and then php (put ruby wherever you like - seems like a rehash of python to me with worse syntax, but to be fair I haven't done much with it).

    php exists purely out of momentum and being early in its market.

    Personally, my rule is:

    • Python is first choice

    • Perl if it's very text-based. Perl is awesome for doing a lot of fast text chopping/formatting. Yes, you can do a lot more with it - I spent 10 years doing hardcode perl oop/database stuff, so I'm quite familiar - but I prefer python now for larger projects. But for quick "parse this log file and reformat it" or "transform this .csv and slurp it into MySQL," it's fastest to work in perl. But I tend not to keep perl code around - it's a lot of one-time utilities.

    • php if it's web-based because it's already there in most cases and everybody and their mother writes it.

    Never found a use case for ruby.

    @Damian said: I would really like to try out Python. What prevents me from doing so is that there is no docs for Python.

    That's presumably meant as a joke, but for people who don't know:

    http://docs.python.org/

    Tutorials, references, everything.

    @Spartan said: But in all actuality, they're deviating from the well-established norm of ALGOL/C-style syntaxes.

    I don't know how "norm" that is across the whole spectrum of computer langauges. But anyway, what's so great about it? A block is a block, is a block, whether you write it with braces or not.

    @Spartan said: I've been saying it for years about all sorts of programming, colleges intro their computer science courses with Java because it's easier and this century, on a whole, is turning out poorer and poorer programmers (not saying there aren't some gems out there) because of the way society is trying to teach us how to program. It's hard, it's supposed to be hard, and knowing how things work under the hood is important.

    All languages are pretty much the same (other than functional vs. OOP). I've done extensive work (over the last 30 years) in BASIC, Pascal, COBOL, C, Java, Python, Perl, PHP, JavaScript, PL/SQL, lua, ksh, awk, C#, and probably some others I've forgotten. The only major languages missing from my resume are C++ (and for that I am thankful) and Lisp (for which I had time).

    Other than the concept jump when you move from functional to OOP, they're all the same. I sat down and wrote a C# database app one afternoon with no prior training - it was hardly the pinnacle of C# code, but it was just firing up Visual Studio and writing code. C# is just a different form of Java. If you know Perl or Python, you can write php cold. Etc.

    If you know a language, you find that

    • the next language has some different syntax, but it's the same operations. How do I iterate over a list? How do I add two integers? How do I open a file? I want a dictionary/hash - how do I do that? So you first equivalence everything you know.

    • Then you learn anything that is new about the language and what it's doing differently. If you are learning C for the first time, you'll need to wrap your head around pointers. If learning perl, get into typeglobs. If you're coming from perl to python, you'll learn about try/except. Etc. BTW, in the case of php the answer to what's new is "nothing" - there's nothing in php that isn't in perl or python.

    • Then you learn the library. That's where people working on big stuff spend 99% of their time. The Java or C# standard library is huge. So is python's and in a more self-assembled sense, perl's. php's is medium-sized because it's all web-focused, but still if you want to parse xml, you'll spend a lot of time learning the library calls.

    php to me is the epitome of "it's ugly, but it works".

    Now if we consider the history of --

    "Honey, are you going to mow the lawn this morning or not?"

    Ah...well, gotta go.

  • @jevermeister said: I don't like php. It provokes unstructured spaghetti code.

    @Raymii said: It works, out of the box, for people who don't know what they're doing.

    Just too damn true. Nonetheless it sometimes might still be the easiest way out for a vast amount of projects, but I'll never love it as much as Python or Java for example.

  • RomeoRomeo Member

    You can be here because PHP.
    That's why PHP still exists.

  • perennateperennate Member, Host Rep

    @jevermeister said: I don't like php. It provokes unstructured spaghetti code.

    You can write unstructured spaghetti code in any language. In the end it only depends on the programmer.

  • raindog308raindog308 Administrator, Veteran
    edited March 2013

    @Romeo said: You can be here because PHP.

    Are you saying my PHP is my father...!?!?

    image

  • @Raymii more important, When can we buy lowendtalk or LEN t shirts? I want one. O.o

  • It's fashionable to hate PHP and to like Ruby, the same way it used to be fashionable to hate Javascript. It works. It does what I need it to do. It's very very simple to setup and configure, unlike Ruby.

    It's easy to write simple code in. Saying that something provokes unstructured spaghetti code is more a matter of who's doing the programming than about what language they're using. It makes you sound like one of those OOP cultists.

    Use what works, get rid of what doesn't. I'd spend more time setting up Ruby and Rails than I'd spend just writing in code in PHP.

  • @gaarai Agreed.

    @ everyone else that thinks PHP needs to go the way of the dodo

    Yes, PHP "just works", and it "just works" very well.

    It is very portable, very well supported, and easy to learn. Yes, some of the functions don't make sense in terms of variable order, or even the function names themselves, but thats a very minor shortfall that can be easily overcome. Also, spaghetti code is not a fault of PHP, its a fault of lazy developers taking advantage of a forgiving system. I can write very elegant code in PHP, and I can write trash code in Ruby, Perl, Python, etc, if I felt so inclined. Just because its easier to get away with in PHP doesn't mean that the language is bad.

    PHP is here to stay for quite a while longer. Its powerful, flexible, active, and very, very well supported across all major operating systems and web hosts. If you don't like it, don't use it.

  • YKMYKM Member

    @rds100 said: Why COBOL still exists?

    lol, so true, I remember having to code in this sucker.. not nice !

  • When I use PHP, it's a modern dynamic language, when you use it, it's merely a scripting language.

  • KuJoeKuJoe Member, Host Rep
    edited March 2013

    I received more training, did more studying, took more classes, and invested more hours into a few other languages but I will pick PHP over the rest any day of the week. My PHP skills are all self taught and 99% of my knowledge is from trial and error or copying other code and hacking it up. Hell, I started coding for The Hosting Tool a few weeks after I learned what PHP looked like. I wrote my first forum software before I knew what phpinfo(); did, how to use includes, and at least a year before I learned what functions and classes where.

    It's just too simple of a coding language. And the fact that you can install php-cli on a Linux server without needing a webserver installed is icing on the cake for Linux admins because it's no longer a web-based language. I'll do shell scripting for most of my automation, but for complex scripts I always turn to PHP.

  • @KuJoe and so it was.

Sign In or Register to comment.