News for hackers. Stuff that matters.
Re:Software in 2014 by xd on Thursday January 09, 2014 @04:56AM (#7029606)
"It’s a pity some people still build important apps in PHP..."

Getting real tired of seeing these baseless statements from so called software professionals.

Here is an off-the-top-of-my-head list of features of modern day PHP:

* yield

* event

* pthreads - yeap, real threads.

* closures (including support for $this)

* consistent hashing api

* "finally" added to try-catch

* empty() now supports expressions, rather than only variables.

* array and string literal dereferencing

* foreach support for list() - foreach($array as list($var, $var))

* array_column

* traits

* short array syntax

* namespaces

* json manipulation is second to none.

* runkit - all kinds of danger here

Re:Software in 2014 by stiff on Thursday January 09, 2014 @06:26AM (#7029858)
I'm not a real programmer. I throw together things until it works then I move on. The real programmers will say "Yeah it works but you're leaking memory everywhere. Perhaps we should fix that." I’ll just restart Apache every 10 requests.

-- Rasmus Lerdorf

Re:Software in 2014 by poolpool on Thursday January 09, 2014 @07:21AM (#7030023)
For all the folks getting excited about my quotes. Here is another - Yes, I am a terrible coder, but I am probably still better than you :) @rasmus
Re:Software in 2014 by andyroid on Thursday January 09, 2014 @06:34AM (#7029885)
Yeah, xd clearly missed to list that the creator of the language also has a sense of humor, but trying to limit it to technical features seems reasonable.
Re:Software in 2014 by qwerta on Thursday January 09, 2014 @08:29AM (#7030324)
I think this would apply to early Ruby On Rails. PHP libs and interpreter are actually fairly good.
Re:Software in 2014 by dscrd on Thursday January 09, 2014 @01:35PM (#7032234)
Can you have a long-running process on PHP these days? I thought it still wasn't an option.
Re:Software in 2014 by xd on Friday January 10, 2014 @06:56AM (#7036192)
I've been running long running process's with PHP for well over 8 years now.
Re:Software in 2014 by dscrd on Friday January 10, 2014 @12:04PM (#7037712)
How did you deal with the resource leaks before PHP 5.3, which was released in 2009?
Re:Software in 2014 by xd on Saturday January 11, 2014 @04:48AM (#7042167)
I steered clear of circular references.
Re:Software in 2014 by zfran on Thursday January 09, 2014 @06:27PM (#7033990)
yeah. I know of a startup doing significant data analysis with long-running (months without restarting) php processes.
Re:Software in 2014 by thejosh on Thursday January 09, 2014 @07:48AM (#7030125)
lucky php has very clever people doing clever things with it - see hhvm for a recent great thing for PHP.
Re:Software in 2014 by _pmf_ on Thursday January 09, 2014 @09:16AM (#7030553)
> lucky php has very clever people doing clever things with it - see hhvm for a recent great thing for PHP

The whole point of HHVM is to migrate away from the PHP runtime (by using the PHP language on another runtime). It's a bit perverted to say that's a god thing for PHP.

Re:Software in 2014 by kayoone on Thursday January 09, 2014 @09:48AM (#7030716)
its just a more performant runtime environment, why is that migrating away from php ?
Re:Software in 2014 by jokoon on Thursday January 09, 2014 @07:48AM (#7030124)
I agree, but that can't really work on the long term...
Re:Software in 2014 by seabee on Thursday January 09, 2014 @07:57AM (#7030160)
It's the equivalent of smacking a malfunctioning (mechanical) appliance to try and make it work again. Maybe you just want something to last long enough until you can get a better-designed, more reliable appliance.
Re:Software in 2014 by daphneokeefe on Thursday January 09, 2014 @12:55PM (#7031972)
Percussive maintenance
Re:Software in 2014 by enneff on Thursday January 09, 2014 @05:27AM (#7029682)
So what? Part of the reason PHP is such a disgusting mess is because it is a raft of haphazardly accumulated features.
Re:Software in 2014 by xd on Thursday January 09, 2014 @05:35AM (#7029712)
For someone that works on Go at Google I'm shocked by your very much subjective view of PHP. Elitist much?
Re:Software in 2014 by dmak on Thursday January 09, 2014 @05:45AM (#7029742)
That comment didn't even come across as elitist. There was no need to get personal.
Re:Software in 2014 by xd on Thursday January 09, 2014 @06:05AM (#7029795)
He works on Go at Google. A skilled professional no doubt, could he not have made some valid points rather than simply calling PHP disgusting. It didn't add anything to the conversation.

If you where in the pub and someone spent some time listing the virtues of the pint they where drinking, and then someone joined in the conversation and called it disgusting with no basis .. wouldn't you find that to be odd behavior?

Re:Software in 2014 by zxcdw on Thursday January 09, 2014 @06:28AM (#7029864)
He did explain why PHP is disgusting mess.

And hell, the fact that people have that opinion stems from somewhere. And that is a fact we should all take a note of -- to build better tools. You see, PHP is nothing but a tool, and as a tool, it's not very liked one due to it's flaws. Solution? Abandon it! Build new, better tools instead of feeling threathened.

Le PHP sink and die it's well deserved death and make way for better tools, because professionals shouldn't feel attached to their tools, instead they should be critical towards them and look to find better ones.

Re:Software in 2014 by memracom on Thursday January 09, 2014 @10:15AM (#7030864)
And that is precisely what Tim is saying. He happens to work mostly with the new tool named Go but he does recognize that there are others like Rust and Dart that are also trying to do things better.

But we need to actually move away from using bad tools (and this has happened with PERL) and start using the newer, better tools more often. Every software developer should learn some Erlang (or Elixir), some Clojure, some Go, etc.

If you don't try these tools out and kick the tires for a while, then you end up stuck in the past like all those COBOL programmers.

Re:Software in 2014 by aryastark on Friday January 10, 2014 @12:42AM (#7035293)
Oh god. It's Perl. And no need to drag it through the mud here. It's pretty much the only language that gets Unicode right. It has nothing in common with the abject misery that is PHP. Perl came out in '87. Erlang came out in '86. I don't know what you're high on, other than trends and trendwhores.

Clojure isn't new. Not to take a dig at Rich Hickey, but everything he is doing with immutable objects was done more than a decade ago by the likes of Henry Baker (http://home.pipeline.com/~hbaker1/home.html). Of course, everything that has ever been tried at all has been tried in some variant of Lisp/Scheme at one point in time.

Re:Software in 2014 by mortyseinfeld on Friday January 10, 2014 @11:54AM (#7037626)
Clojure isn't new. Not to take a dig at Rich Hickey, but everything he is doing with immutable objects was done more than a decade ago by the likes of Henry Baker (http://home.pipeline.com/~hbaker1/home.html). Of course, everything that has ever been tried at all has been tried in some variant of Lisp/Scheme at one point in time.

Stop while you're behind. Nobody believes that Henry Baker's papers are equal to what Rich Hickey has done with immutable objects. Geez, get a grip on reality man.

Re:Software in 2014 by xd on Thursday January 09, 2014 @10:37AM (#7031019)
I might be wrong, but COBOL isn't being actively developed as a language anymore .. PHP however is still solving problems and under constant development and improving all the time.
Re:Software in 2014 by aaronem on Thursday January 09, 2014 @11:33AM (#7031396)
> PHP however is still solving problems

But is it solving more problems than it creates?

Re:Software in 2014 by codygman on Thursday January 09, 2014 @10:21PM (#7034908)
PHP is great for developers and firms because they are always required to stay and make sure things blow up. Most of the PHP I've worked with was also very hard to decipher by anyone except the original developer.
Re:Software in 2014 by raiph on Friday January 10, 2014 @10:31AM (#7037058)
Hi memracom,

Where will Perl 6 sit when/if it becomes something you could realistically use? Would you classify it as one of the bad tools or a newer, better one?

Re:Software in 2014 by xd on Thursday January 09, 2014 @07:11AM (#7029985)
"haphazardly accumulated features" is not an explanation, it's a subjective point of view.

"it's not very liked one due to it's flaws", PHP is very well liked, just not by everyone .. which goes for most things in life.

Re:Software in 2014 by josteink on Thursday January 09, 2014 @08:23AM (#7030283)
"haphazardly accumulated features" is not an explanation, it's a subjective point of view.

If you really need it, here's a very good write-up which should cover that in an impressively detailed manner:

http://me.veekun.com/blog/2012/04/09/php-a-fractal-of-bad-de...

Re:Software in 2014 by xd on Thursday January 09, 2014 @09:26AM (#7030605)
This was hotly debated, by myself included, right here on HN: https://news.ycombinator.com/item?id=3820431

He has updated the article over time which is good of him, but much of it is still subjective and from a quick glance there are points that no longer hold true.

Re:Software in 2014 by Tegran on Thursday January 09, 2014 @01:21PM (#7032127)
Re:Software in 2014 by josteink on Friday January 10, 2014 @05:32AM (#7035990)
It was a long one, and I'll admit I only skimmed it.

But from a glance, it looks like the one writing the rebuttal didn't really understand the criticism, and is himself 100% captured by the exact mindset which the original article criticized PHP for having.

This guy is the one who will be standing at the door complaining that you just broke his house. He is what is wrong with PHP.

And naturally, however much sense he thinks his argument makes, it will still be wrong. It's in the very nature of this situation.

Re:Software in 2014 by grey-area on Thursday January 09, 2014 @06:24AM (#7029848)
He probably didn't elaborate because he felt the basis for the view was clear - there are clearly areas of PHP which still need work. PHP is often frowned upon because the APIs are a mess of legacy cruft like addslashes, magic_quotes, mysql_escape_string, mysql_real_escape_string, mysqli_real_escape_string versus prepared statements. Efforts are being made to clean it up, but for a language to ever end up in a place with that sort of library functions is a pretty big red flag.
Re:Software in 2014 by xd on Thursday January 09, 2014 @07:04AM (#7029969)
Check the manual; magic_quotes, mysql_escape_string and mysql_real_escape_string have already been deprecated/removed.
Re:Software in 2014 by grey-area on Thursday January 09, 2014 @07:29AM (#7030050)
I'm aware of that thanks, as noted in the last line:

Efforts are being made to clean it up, but for a language to ever end up in a place with that sort of library functions is a pretty big red flag.

Re:Software in 2014 by xd on Thursday January 09, 2014 @08:10AM (#7030215)
"for a language to ever end up in a place with that sort of library functions is a pretty big red flag."

At the time it was reasonable .. but PHP evolved and learned lessons, it didn't just stop there as you seem to be saying.

Re:Software in 2014 by cowsandmilk on Thursday January 09, 2014 @12:23PM (#7031729)
mysql_escape_string [1] mysql_real_escape_string [2]

Why is exposing a C library's functions and their names PHP's fault?

[1] http://dev.mysql.com/doc/refman/5.5/en/mysql-escape-string.h... [2] http://dev.mysql.com/doc/refman/5.5/en/mysql-real-escape-str...

Re:Software in 2014 by Joeri on Thursday January 09, 2014 @05:13PM (#7033657)
Because php ends up combining the API consistency of C with the syntactic elegance of visual basic. I say this as someone who programs php professionally, the fact that they still haven't provided a complete set of OO api's very much speaks against the language stewards. PHP could have a sane subset, like javascript, but because there are gaps in the API (like the string and array API's, which are horrible) you can't get a sane subset without adding some extra API wrappers of your own.

And that's why it's impossible to build frameworkless PHP code that is elegant, something that even the designed-in-10-days javascript lets you do.

Still, i like php for its getting things done mentality. What it lacks in elegance it makes up for in productivity.

Re:Software in 2014 by ben0x539 on Thursday January 09, 2014 @06:28AM (#7029865)
Do you really want another thread in which everybody enumerates their favorite issues with php?
Re:Software in 2014 by enneff on Thursday January 09, 2014 @04:22PM (#7033359)
Sorry if I upset you. Your feature list is no stronger a point than my response, though. Features don't make a language great. Clarity, consistency, simplicity, and orthogonality do. PHP has none of those qualities. I know, because I used it extensively for a decade.

I stand by my comment. I can see why people like PHP but nobody in their right mind should deny that it is a mess and that it was constructed haphazardly.

Re:Software in 2014 by icebraining on Thursday January 09, 2014 @06:41AM (#7029904)
Even if he hadn't explained why, and he did, it still wouldn't be elitist.
Re:Software in 2014 by aaronem on Thursday January 09, 2014 @09:21AM (#7030583)
"Elitist?" I came into web development via the PHP tradesman's entrance, and until by the grace of God I found my way out into the wider world, I didn't even begin to suspect just how miserable I had it. If there's a tinge of elitism in the wider world's attitude toward PHP, I'll be the first to contend that it's justified.
Re:Software in 2014 by ThomPete on Thursday January 09, 2014 @01:22PM (#7032140)
Yeah I think you are more like an ex-smoker who after you managed to quit tells everyone who awful smoking is :)
Re:Software in 2014 by aaronem on Thursday January 09, 2014 @04:02PM (#7033208)
Not really a parallel; you'll never meet a long-time cigarette smoker who doesn't know how awful a habit it is, although you'll probably meet some who will lie about it.

On the other hand -- and I say this as a smoker, albeit as one who's cut back his habit to almost nothing over the last couple years -- smoking is an awful habit, which is both severely addictive and without meaningful benefit for the person with the habit or for anyone else. So I suppose I'm not all that inclined to quibble about the not-quite-perfect parallel, after all. :)

Re:Software in 2014 by ThomPete on Thursday January 09, 2014 @07:57PM (#7034353)
In other words. The parallel is perfect.
Re:Software in 2014 by ciupicri on Thursday January 09, 2014 @05:44AM (#7029739)
It's not just his view, there are other people who feel the same way about PHP.
Re:Software in 2014 by enneff on Thursday January 09, 2014 @04:09PM (#7033258)
I wrote PHP code for 10 years. You could say my relationship with the language is pretty subjective.
Re:Software in 2014 by xd on Friday January 10, 2014 @04:18AM (#7035822)
When did you stop developing with PHP?

edit: you know what would be great, if you could show some common programming examples in PHP and how Go would manage the same situation.

Re:Software in 2014 by JackMorgan on Thursday January 09, 2014 @06:48AM (#7029927)
My perception is most developers who choose to use PHP these days for new development efforts either do so because it's their strongest language and do not want to reinvest the time to retool, or because of political reasons orthogonal to PHP's technical chops. Thankfully, it is still actively developed, so those who make that choice are able to take advantage of such new features.

I totally understand the choice to work in shops that have legacy php code: they have money and often times don't want to change off php. Handily enough, most of us like working for money.

What caused me to retool away from php was the fear that not enough new systems were being built in it, leaving a diminishing pool of jobs for a constant pool of developers not wanting to retool. I figured I'd give up my space to someone else, and seek my fortunes on other stacks. I don't think there is anything wrong with deciding X language will be the one you ride into the sunset on (some COBOL programmers I know make crazy money due to the economics of the ratio of jobs/developers). I just personally considered the risk of a job shortage to outweigh the rush of a talent shortage. (And I am so practiced at retooling, I could probably be ready to interview for a PHP job in a few weeks if I had to).

I think of choice of stacks from the agile way, "make it fast to change, and you'll be ready to snatch up arbitrage opportunities when they arise." Rather than the waterfall way, "pick the right tech that will last your career at the point of maximum ignorance".

I think most people mock PHP just because it's fashionable to do so, it's the "easy joke" that vb6 used to be. I wouldn't take it personally, you should own your choices.

Re:Software in 2014 by grey-area on Thursday January 09, 2014 @05:59AM (#7029777)
baseless statements from so called software professionals

You're calling this guy[1] a 'so-called software professional' because he criticised PHP?

[1] http://en.wikipedia.org/wiki/Tim_Bray

Re:Software in 2014 by pgeorgi on Thursday January 09, 2014 @06:50AM (#7029932)
To be fair, he _did_ bring XML upon us...
Re:Software in 2014 by grey-area on Thursday January 09, 2014 @06:53AM (#7029947)
:)
Re:Software in 2014 by Sanddancer on Thursday January 09, 2014 @11:00AM (#7031190)
Yes, php is more checklist complete than it was a few years ago, but there's still quite a bit of ugliness in the language. For example, you mention

    * closures (including support for $this)
I looked at this a couple days ago, because closures make a lot of problems easier. However, PHP's handling of closures is more than a bit ugly and hackish. Yes, it supports $this, but this was done after the initial release, doesn't give much confidence in how it's handled under the hood. Plus, you have some real syntactic ugliness; in order to scope variables into a closure, you have to declare them again with a now overloaded keyword -- use -- with them passed by value by default. Closures in pretty much any other language, you just put them in the scope of your function and the compiler/interpreter knows how to handle them without any hints from you.

While php is less bad now, there's still quite a bit of ugliness in it due to its tendency to just spackle new parts on without any regard for what the end result looks and functions like. The php team needs to make a concerted effort to clean the language of its rough points, even if it breaks backwards compatibility, otherwise, useful ideas will continue to be hampered by an overbloated ugly core.

Re:Software in 2014 by thirdsight on Thursday January 09, 2014 @05:08AM (#7029638)
Those are great features.

However the objection people, including myself, have with PHP is that the legacy stuff is inconsistent junk.

I still use it on occasion but it pains me.

Re:Software in 2014 by coldtea on Thursday January 09, 2014 @05:29AM (#7029691)
PHP, especially post 5.2, is a flexible and battle tested language to do work in. It has some bad design choices inherited but nothing that you can't overcome and never have to think about again in a couple of weeks of learning the language.

Exactly like Javascript in this regard. I've been programming JS for over 15 years, and with the exception of cross browser support back in the day, there's nothing that had me startled after I learned the language -- except for a few issues related to floating point that I stumble upon now and then, but then that would be true for floating point math in any language.

The only PHP inconsistency is with the naming of the built-in functions. Functionality wise, most are solid bindings of respected C libraries. And, really, the needle/haystack thing has been blown out of all proportion. As if that's the biggest challenge one faces when programming.

Re:Software in 2014 by xd on Thursday January 09, 2014 @05:24AM (#7029675)
PHP is making strides to remove legacy pain points. Check the changelogs i.e. http://php.net/ChangeLog-5.php#5.4.0

As to parameter ordering .. I've been using PHP for so long now that they've been memory to committed ;)

Re:Software in 2014 by mseebach on Thursday January 09, 2014 @06:38AM (#7029894)
It's a pity that people still build important app in PHP, because despite improvements to PHP, there are several, even many, languages out there that beats PHP flat out on all fronts.

PHP used to be by far the easiest language to get started with for web dev. This is not the case anymore.

And while you're certainly entitled to disagreement, Tim Bray is about as far from "so called" you can get for a software professional.

Re:Software in 2014 by lsh on Thursday January 09, 2014 @09:06AM (#7030499)
"PHP used to be by far the easiest language to get started with for web dev. This is not the case anymore."

um - who would be the contenders? in terms of getting started, which also means deploying and see your stuff on something other than your local machine, I can't think of anything better supported than PHP. Most budget hosting you can simply upload your brand new, first-ever PHP script and have it 'just work'. No need to worry about wsgi, cgi-bin, application servers or anything.

As much as I loathe PHP because it sweeps the developer towards bad habits and unreadable, bug-ridden, slop, I love it because, rather like a bash, it's a flexible and comprehensive tool in my toolbox.

Re:Software in 2014 by mseebach on Thursday January 09, 2014 @10:03AM (#7030793)
> who would be the contenders?

Here's a good start - and I'll bet that Heroku's free tier is a better option than most $5/month PHP webhosts:

https://devcenter.heroku.com/categories/language-support

Re:Software in 2014 by Joeri on Thursday January 09, 2014 @05:44PM (#7033811)
Speaking as someone who has written hundreds of thousands of lines of php over the years, i think php's main problem is not that it lacks features, but rather that it doesn't have a sane subset, a javascript-like 'good parts' if you will. PHP added OO api's for date and database handling in the 4 to 5 transition, but it never got around to doing the same for strings and arrays. So frameworkless php is by necessity a mixture of procedural and OO code (unless you go pure procedural), and always looks ugly. PHP's stewards could solve this by bringing all the API's into the OO fold, and I have experimented [0] with what PHP could look like if strings and arrays were objects, but so far this hasn't happened.

You do have some really nice frameworks that hide the procedural stuff, like laravel, and that code looks nice, but it is really slow. And this is the inherent conflict of the php developer. If you write raw php, it is ugly but fast. If you use a framework it is pretty but slow. The techempower benchmarks [1] demonstrate this, where raw php performs at near-native speeds, but frameworks like symfony and laravel are embarassingly slow in comparison.

So, php's scorn is well deserved. It's productive, yes, but it is impossible to build a world-class top-performing app in it and still get clean and consistent code without jumping through some sizeable hoops (like facebook did by building their own php engine and php-like language called Hack, in addition to their own frameworks).

[0] https://github.com/jsebrech/php-o

[1] http://www.techempower.com/benchmarks/#section=data-r8&hw=i7...

Re:Software in 2014 by krapp on Thursday January 09, 2014 @06:20PM (#7033967)
This was a competent and accurate criticism of PHP. Backed up with references, neither of which were veekun's rant. Thank you for adding some signal to the noise which usually accompanies threads where PHP is mentioned.
Re:Software in 2014 by chrisweekly on Thursday January 09, 2014 @09:24AM (#7030594)
For me, this is the definitive take-down of PHP: http://me.veekun.com/blog/2012/04/09/php-a-fractal-of-bad-de...

Even if a handful of those issues have been addressed in the intervening 15 months, the depth and breadth of fundamental problems remains. /$.02

Re:Software in 2014 by xd on Friday January 10, 2014 @04:15AM (#7035814)
Obviously you believe everything you read on the internet without question .. https://news.ycombinator.com/item?id=7030283
Re:Software in 2014 by chrisweekly on Monday January 13, 2014 @10:51AM (#7051214)
"Obviously... everything... without question"? Um, hyperbole much?

There's a lot wrong with PHP, and that'd be the case if even a quarter of the points in the article I linked to were valid.

PS Feel free to get the last word in after this, I don't plan to reply again since it's not very constructive. Have a nice day.

Re:Software in 2014 by dscrd on Thursday January 09, 2014 @01:21PM (#7032126)
PHP certainly has features and it certainly is successful, and people are certainly doing stuff with it. It also certainly has severe and fundamental design flaws that are never going away.

It's distressing to say the least to many of us people who have studied programming languages a lot, that the quality of design and coherence in your programming language has almost no effect (or even negative correlation!) to how well it succeeds.

Re:Software in 2014 by abvdasker on Thursday January 09, 2014 @11:38AM (#7031421)
Call me crazy, but PHP JSON manipulation is maybe second to node.
Re:Software in 2014 by krapp on Thursday January 09, 2014 @06:17PM (#7033958)
Node as javascript does handle the object notation natively, which is an advantage over PHP in terms of handling JSON. Which, coupled with the (recently corrected) awkward syntax for arrays, unfortunately makes PHP's most common pattern (conversion of SQL data into arrays and maybe into JSON) more of a hassle than it should be.
Re:Software in 2014 by antocv on Friday January 10, 2014 @03:52AM (#7035758)
Throwing a bunch of buzzwords or features at the problem doesnt mean the language magically becomes elegant, consistent and logical.

PHP with these features has become more of a headache.

Re:Software in 2014 by daGrevis on Thursday January 09, 2014 @07:45AM (#7030113)
Should I be impressed? Mess on top of existing mess. :(