

Ask HN: Still acceptable to use PHP for new projects? - Archio

We've all heard the discussion of PHP over the years- its faults, why other languages are better. However, it is the language &#38; ecosystem that I know best and have the most experience with.<p>Obviously, the user doesn't care about the backend of a system. From a developer's point of view, though, is PHP still acceptable to use for new projects, even though "better" languages like Python and Ruby are way more available than they were years ago? Or is it no longer considered a good idea to use PHP if I'm starting with a clean slate?
======
twog
Dont let the HN Hivemind fool you, plenty of people still use PHP and write
beautiful, OO code.

The language you use doesnt determine whether you're a good developer or not.
I have used other languages (node, python, ruby) and I still prefer php,
because its quick and simple. Its syntax may not be as beautiful as a python
or a ruby, but it php just works, and it powers hundreds of millions of sites.

Bottom line, use what your comfortable with, but be open to exploring other
languages. Dont ever let someone tell you a language is better than x. Make
those decisions yourself.

------
Lazare
Use whatever language/framework is best for you. That could well be PHP, and
if you only know PHP well, it probably is.

Yes, PHP is _objectively_ a bad language. The PHP ecosystem is poor,
development is stagnant, the syntax is ugly. Whatever the future of the web
may be, it's certainly not PHP.

But...you know PHP. Presumably you know what it's good at (and what it's not
so good at). You also know your project. Think you could code it faster and
easier in PHP than anything else? Yes? Awesome, knock yourself out. As a
bonus, a ton of other developers also know PHP, so you'll probably be able to
hire coders easily.

(On the other hand, as a coder, I like to keep my skills current, and that
means learning new technologies from time to time. Yes, PHP is currently
dominant, despite what you may hear on HN, but it's not the future. I jumped
from the PHP ship a long time ago, and I have never regretted it for a split
second. Are you going to learn a new tech stack eventually? If so, why not
now? If not, then when?)

------
tjlytle
There are pros/cons to any language. If you're developing something web
related, PHP is certainly worth considering (especially in your case, as you
have experience with it).

Just a few quick thoughts:

PHP is - in most cases - very tightly coupled to the HTTP request. This can be
good or bad depending on what you're building. Doing a lot of offline
processing? Probably bad. Serving up web pages? Probably good.

There's no (or little) state with PHP (you do have the session, which can be
pushed to memcache), so - generally speaking - running your application across
a bunch of web nodes isn't too hard to implement (even scaling the horrible
legacy style code that helps give PHP a bad reputation shouldn't be _too_
hard). This may or may not be important to you.

There's really no one true way with PHP - it can be used for a simple 10 line
script, or for a large scale web application. If you like (or need) that kind
of flexibility, it could be a good choice.

Bottom line is - it's certainly sill worth considering, just know why you
picked it (or whatever other language/platform you use).

That said "it's what I know" or "I wanted to try something new" aren't
necessarily bad reasons.

~~~
Spoom
Good points. I feel I should point out that you can use PHP independent of any
web server by using the command line interpreter (CLI) version. This is, for
example, how we run PHP cron jobs where I work.

~~~
tjlytle
True. Not a strength for the language though - if that's a big part of what
you do, then I'd consider something else. That said, I've built plenty of
applications that used PHP on the command line or as a daemon.

------
methochris
I struggled with this question myself recently. I had minor experience with
PHP a long ways back so starting my app with something familiar sounded better
than starting from scratch.

But after a ton of research, I came to the conclusion that learning to
program/mvc/security techniques with php is total chaos. There is 10+ years of
php tutorials out there and everyone of them takes a different approach to
there programming methods and u have no idea if your adopting the habits of a
guru or some punk who just figured out his first script. There are so many php
functions that do the same thing (mysql vs msqli), u will struggle constantly
just figuring out what the the right/best/newest way to do things is. It's all
such a mess...

So I ended up taking the 101 udacity.com course and learned the basics of
python/programming in really short order. After that I did the 253 web dev
class there with Steve Huffman (creator of reddit). After that I fealt like I
had a solid understanding of how mondern web apps are put together and I
learned from some real pros.

I immediately picked up Flask, got set up on heroku, and have been having a
blast ever since. Flask is especially nice because there are
plugins/defaults/documentation on handling and avoiding most modern web app
features/security issues. I highly recommend this route.

Good luck!

------
jfaucett
is PHP acceptable? well, obviously it depends on the project requirements, for
instance programming a chat server in PHP is probably not the best choice, but
even though PHP has its faults for me it remains a solid language for building
new web applications. Here's why:

1\. Its easy to scale (horizontaly) because it has a "share nothing"
archtecture.

2\. like tjlyte states its centered on the HTTP protocol which is almost
always your app protocol

3\. its fast

4\. its an "easy" language to program, but still supports OOP, namespaces,
closures, anonymous funcs, etc.

5\. Its highly portable

6\. It has a very extensive developer base, tons of libraries and frameworks
that are starting to reach enterprise Java level maturity (Flow3, Symfony2 for
example )

------
Chrix
I'm a Grails developer but when friends asked me to develop their web site for
an association, I had to learn PHP. Why? Economic reasons! Web hosting pricing
are divided by three (3$ vs 9$) between PHP and Grails/JVM website hosting.
Before that, I'd prejudices on PHP like it's ugly, inelegant. And it can be
that. PHP is like C language: you can do bad code, ugly implementation if you
aren't rigorous.

And it's your project is a "standard" website (i.e. only display page and make
some SQL queries), PHP is good enough. No need to use a canon for killing a
fly.

------
gardentheory
Putting this in a more positive light. Why not take this new project as an
opportunity to learn a new stack ?

------
allardschip
If you enjoy programming in it, mostly doing http work and you think you can
find talented , smart php developers in your area, go for it.

If your ideas need thing like massive concurrency or lots of number crunching,
you may want to look at some other options as well.

------
stevencorona
On one hand, you should use the tool that you know best.

On the other hand, putting the language itself aside, dev-tools and existing
libraries are few-and-far in between (and they usually suck). And when I say
libraries, I don't mean snippets on the internet.. true libraries with tests,
etc. Besides the frameworks and a handful of active packages on PEAR- good
luck.

There is a reason why Ruby and Node have awesome tools (gem, npm, webrick,
jasmine, cucumber, etc. etc.) and a very active library sharing mentality.

~~~
jfaucett
I think your statements about lack of libraries for PHP would have been
correct about 4 years ago - maybe even as late as 2010 (pre namespacing in
PHP). But as of date, I don't think they hold up. The Bundle concept
implemented by Symfony2 - and being adopted by others, has really caused a
boom in solid high end libraries that can easily be integrated with any
project. ( check out: <http://knpbundles.com/> )

~~~
tjlytle
Composer as well (<http://getcomposer.org/>) - no one true way with PHP, but
that doesn't mean there can't be a few good ways.

------
mukundmohan
The end goal is to be more productive and to ship something. Given most
software development is hidden from the end user, most times its immaterial
what its written on.

------
hobonumber1
It's still a hugely popular language and easy to get started. I suggest using
some sort of a framework such as CodeIgniter or Zend to make the code easier
to maintain.

------
adolfoabegg
Time to market is vital, if you know php, build your project with it. If you
want to keep it clean: use a framework and TDD.

------
jhaaps
Use whatever language you want, after all it's your project.

------
0k1n
(have :a (look :at :clojure))

------
rweir
no

------
rsanchez1
I really don't think this is the kind of question to ask on HN, which hinges
on the latest fads, the latest of them being Ruby on Rails and possibly
Node.js. Use PHP if it's most convenient for you. Heck, I would say you should
even use Perl if it's most convenient for you.

