Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I love how, through all the hate and bandwagoning, some people don't get discouraged and actually do something to improve the product.

We still do new projects in PHP and we couldn't be happier.



About a year ago I was ready to jump ship on PHP. Then someone introduced me to Composer, Symfony 2 and Doctrine 2. I fell in love with PHP again, not because of the language but because of the tools. Its now clear to me that the language doesn't really matter that much, it's the tooling around the language that makes the difference.


Agreed. One thing to consider is how the features and performance of a language shape the tools. The tools can be great, but to some degree you're riding a long distance skateboard with a generator on the back...

Edit: This comment comes off as me making fun of PHP, when I simply meant to say that tools can make something effective but what underlies an effective work environment can still be crap. I don't think PHP is "crap," but at a certain level of complexity its easier to get the "average developer" to be effective using another set of tools.


Dmitry is the man who originally wrote eaccelerator, Zend caught wind of him and hired him! Then he worked on opcache and has done some amazing things in getting the Zend Engine and PHP itself flying. He's a very smart cookie.


His good sense is obvious by the way he stopped going down the JIT route and zeroed in on the bigger performance drain, memory allocation, instead. The smart programmer knows how to write a JIT; the wise programmer knows how to not write a JIT.


JIT is probably coming too, just with current way the engine built it turns out it is very hard to do JIT that makes any real-life impact. One can get magnificent benchmarks, but once you hit real-life apps, you get very low improvement. Thus a more attainable goal was chosen, but JIT may come back yet.


It's been folklore in the Drupal community for years that it's the deeply-nested arrays that are slow. It's Amdahl's law.

Profile Drupal, WordPress and the other heaviest users and look for the big wins.


> We still do new projects in PHP and we couldn't be happier.

I concur, especially when frameworks like Symfony exist. Reading all this smack talk about PHP on HN is so alien considering how thriving the PHP community actually is.


Nobody mentions how much or little the PHP community thrives. People point out how bad PHP compares against other languages. The fact that you enjoy using PHP and that you can create great products with it does not imply that it has no flaws.

Many have been where you are now, and then moved on to other languages to never ever look back. From what I've seen, the reverse is much less common.


> Nobody mentions how much or little the PHP community thrives. People point out how bad PHP compares against other languages.

I don't actually think that faults in a language matter that much if the people using it are competent. Both Javascript and Perl come close to PHP in terms of negative traits, yet a lot of good software was written with both. The same can be said about PHP, the only difference is that people on HN have very little idea about what contemporary PHP (language and software) looks like.


There are many good PHP web frameworks out there today, yes. These don't somehow erase PHP's core flaws as a language though.

You can make a new project in Symfony or Laravel, sure, but you'll get that same niceness plus way more goodies if you use a popular Python or Ruby framework.


I think you need to qualify that a bit - what are "way more goodies" exactly?

Can you name something that Python can do that PHP can't?


No, but I can name a lot of things that are way easier and cleaner to do in Python than in PHP.


Real production ready servers ,complex scientific calculations, 2d, 3d games , to name a few things. PHP is not general purpose. Python is.

PHP has type hinting and interfaces that makes it "java" like(it's a strength).

Python doesnt have interfaces but allows type hinting through decorators.

    @typecheck
    def gimmeFloat(a:int, b:list, c:tuple=(1,2,3)) -> float:
        return 3.14


And who is talking here about a general purpose lenguage in this context, i only care about the web stuff i don't need things that ain't gonna use.


It's also a far more readable language, which matters more than anything in large-scale projects

On the other hand, <? ?>.


Large scale projects doesn't need "more redeable" languages, it needs good engeneering and type checks.


The single biggest everyday-use thing I miss with PHP is keyword arguments. With PHP the only real equivalent is passing an array of arguments and then checking if each possible key exists, and that's just way clunkier.


> No, but I can name a lot of things that are way easier and cleaner to do in Python than in PHP.

Please do.


I can name two. First, list comprehensions. In PHP, what you might write as this:

    $image_urls = [];
    foreach ($images as $image) {
        $image_urls[] = 'illos/' . $image['url'];
    }
can just be this in Python:

    image_urls = ['illos/' + x['url'] for x in images]
And, closures in Python -- and to be fair, just about any language that isn't PHP -- close over variables in the scope they're defined automatically, without having to use PHP's strange "use ($a, $b, $c)" construct. Yes, that's a small thing, but PHP's way is a little bonkers.


I'd prefer something like this:

    $image_urls = array_map(compose(papply('concat', 'illos/'), papply('lookup', 'url')),
                            $images);
This builds a function via composition: first lookup 'url' then prepend with 'illos/'. This function is then mapped over the array.

Unfortunately relies on a bunch of functions which PHP doesn't include. Unfortunately PHP's stdlib concentrates on incredibly-single-purpose functions for, eg. string manipulation, while ignoring general programming constructs. Also, most of the really useful parts of the language aren't available as functions, for no real reason. In any case, we can define these things ourself like this:

    // Function composition
    function compose($f, $g) {
      return function() use ($f, $g) {
        return $f(call_user_func_array($g, func_get_args()));
      };
    }

    // String concatenation. Unfortunately we can't write "concat = papply('implode', '')"
    function concat() {
      return implode('', func_get_args());
    }

    // Array subscript. I'd prefer to do this the other way around and write an
    // argument-flipping function, but that's unnecessary for this example
    function lookup($x, $y) {
      return $y[$x];
    }

    // Partial application
    function papply() {
      $args = func_get_args();
      return function() use ($args) {
        return call_user_func_array('call_user_func',
                                    array_merge($args, func_get_args()));
      };
    }
Regarding lexical scope, Python has ridiculous gotchas too http://stackoverflow.com/questions/5218895/python-nested-fun...

PS: I still much prefer Python to PHP, but straw men aren't going to help ;)


> can just be this in Python:

In PHP 5.3+ you can write:

    $image_urls = array_map(function($image) {return 'illos/'. $image['url'];}, $images);
Not as concise, but I'd postulate easier to read for people not familiar with list comprehensions.

In PHP 5.5+ there may be another way, but we're stuck with 5.3 in production for most clients, so I'm not up to speed.

> And, closures in Python -- and to be fair, just about any language that isn't PHP -- close over variables in the scope they're defined automatically, without having to use PHP's strange "use ($a, $b, $c)" construct.

Mmm, the debate of explicit or implicit scope? Explicit at least gets round those strange errors (hello Javascript) where you think you're referencing one thing... and actually referencing something else.


You can't write production Python and be unfamiliar with list comprehensions. They're a fundamental part of the language.


this

(javascript pun intended)


  image_urls = images.map { |img| "illos/#{img}" }
Even better :)


JavaScript is a horrible language. The fact that a lot of good software is written in JavaScript because there is no good alternative in the browser does not make it any less a horrible language.

The problem with PHP is that it is a horrible language and there are plenty of better options in its niche. Those two factors combine to make PHP a nonstarter for programmers who are familiar with the other options.

I dispute that there is any good software written in Perl.


> I dispute that there is any good software written in Perl.

Do you even Linux? Have you ever installed anything? If you pay attention you will notice that lots of the libraries you are using for everything are written in Perl.


> Many have been where you are now, and then moved on to other languages to never ever look back. From what I've seen, the reverse is much less common.

I really doubt that. In my experience there haven't been a single time when someone attacking PHP actually knew something about it that wasn't outdated by at least 5 years.

It's funny how difficult it is for people like you to grasp that the language and its ecosystem evolves every day, much faster than other languages. Just look at what you just said. How can someone have been where I am right now? They used a time machine? Or you are assuming that the language stopped evolving at some point, or never evolved at all in the first place?


If you enjoy programming in it, and you can create great code then what's the problem?


That you are too pragmatic for the fashion victims of programming.


because real world people don't program because it's fun, they program because they need to make money.


Oh, come on.

I've probably written about 20x as much code in my life for fun, than I did to make money.

Guess I'm not a "real world people".

Though that ratio changes a bit closer to 3:1 looking at only PHP code I ever wrote. The "for fun" element was good times though, my first steps in server side programming :)


Something needs to pay the bills. If a PHP project takes longer to complete (I'm not saying it does), is harder to maintain, etc than an equivalent project written in another language, then you will simply be less productive in PHP.

This is the case for any language. No matter how much you enjoy something, if a design choice you made (like choosing PHP, or Perl, or C++) means that you spend more of your time on the project, you've made a mistake. The purpose of a language is to remove as much of the incidental complexity of the project as possible, leaving only the (more enjoyable) intrinsic complexity.


What's so good about Symfony compared to other PHP frameworks?


It's a mature, well designed and cleanly written piece of software that is very modular. It also has a great documentation and knowledgeable community around it.

Other PHP frameworks lack some or most of these features: some are either very opinionated and rigid (Yii, Cake) huge and sparsely documented (Zend 2) or just old and approaching abandonment (Codeigniter, Kohana).


I'm just starting to learn PHP, and I noticed that recently there have a few new books about Laravel. So, it seems to be the "new hot thing" in PHP.

To a newbie, would you recommend Symfony, or Laravel?

Thanks!


Symfony can be overwhelming for a newbie, but that's because web development is becoming a bigger field every day. There is so much to learn, and Symfony will teach you all kinds of best practices and other things that are not framework-specific at all. To learn Symfony is to learn web development done right.

Laravel is basically a wrapper around Symfony, to make it simpler and easier. A newbie might prefer to use that, but at some point after feeling comfortable with the basics like MVC, ORM, etc. you will definitely want to move to the more professional Symfony.


Yup, Laravel is a great starter framework. Like jafaku said, it uses a lot of Symfony components under the hood so it will be familiar territory if you decide to try out Symfony one day.

Be sure to check out Jeffrey Way's Laracasts, it's a really good site offering tutorials mostly for newbies.


I really like Yii. In my opinion it is exceptionally well designed and offers so much functionality.

The Yii programmers designed it with performance in mind. I can understand that you find it opinionated, but in my opinions the pros outweigh the cons.


I liked Yii too, until I had to switch to Laravel for a new client. While Laravel is missing a few features baked in, like generators and admin tools, 95% of Laravel is way better designed and documented than Yii.

The only worthwhile point I still see in favor of Yii is its ORM can generate fewer, albeit more complicated, queries when eagerly loading nested objects. (OTOH, I encountered some ugly pagination bugs last summer when doing that...)


>It's a mature, well designed and cleanly written piece of software //

Just went to the Symfony site for my first time, to have a look. OK, I'll install it ... requires use of Alpha software (Composer) to install? Also, they tell you to pipe that script straight through PHP - don't appear to be any sha hash sums given or anything. Doesn't seem terribly mature and well-designed so far.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: