Feeds

back to article What's that? A PHP SPECIFICATION? Surely you're joking, Facebook

A group of Facebook developers has decided to break with 20 years of tradition and release a formal specification for the PHP programming language. The initial draft of the spec was released on Wednesday and is available via a Git repository hosted on PHP.net. Language specs, in and of themselves, are nothing new. Many of the …

Bronze badge

Specless master of the web

I see this development as the end of a golden age. Before, the horror of PHP was the stuff of legend. Now it will be down in black and white, and so, subject to being "improved." In time, PHP will become just another adequate programming language, and in the process we'll have lost a big piece of the crap that illuminates our lives and cuts thru the bland pudding of existence. Alas...

9
2
Bronze badge

Re: Specless master of the web

I doubt it'll make any difference. My observation of the evolution of PHP is that's it's driven by a bunch of ego-driven prima donnas and I can't see a spec devised by somebody else ever being to their satisfaction. Like you I've had the joys of re-working previously reliable code for the sake of point one version bump, and being admonished in the error log for neglecting to use a feature that didn't even exist twelve months previously.

PHP could be a great language, if it wasn't for the people making it up as they go along.

12
1

Re: Specless master of the web

Unfortunately, it's not just the language itself that's broken, the standard library is also broken; stuff like launching a process, creating temporary files, creating a fucking file, etc. are all *MORE* difficult that any other language. EVER. All of the existing options are a weak and/or broken counterpart of the C version.

This is probably an even bigger problem, since it's more difficult to fix... I could probably live with PHP if it had a sane standard library...

3
3
Silver badge

Re: Specless master of the web

"stuff like launching a process, creating temporary files, creating a fucking file, etc. are all *MORE* difficult that any other language."

You've been very lucky if you've never seen these things done worse than in PHP (which in no way implies that PHP is good at any of them).

7
0
DJV
Facepalm

@Robert Long 1

"creating a fucking file"

Er yes, Java - millions of ways of creating and accessing files, not one of which does exactly what you need it to do!

7
0
Bronze badge
Paris Hilton

Re: Specless master of the web

And what is so difficult about creating a file in PHP ? The easy and dirty way is easier and faster than VB/VBA (using error_log), and the proper way using fopen takes 1 variable and fopen, just the same as C....

Now, about the standard library with unstandard argument conventions and orders, there I totally agree with you.

Maybe in the end, Facebook may breathe some sanity into the strange parts of the damn language...

5
1
Anonymous Coward

Re: @Robert Long 1

Er yes, Java - millions of ways of creating and accessing files, not one of which does exactly what you need it to do!

Err, the only way in the standard library that I can think of is the java.io.File class. If you referring to various Apache Commons libraries, then I suggest you stop using them until you've checked the code - most of the Commons stuff is terrible under the hood, and some of it (the Pool library for example) is hideous at the API level as well.

2
1
Anonymous Coward

Re: @Robert Long 1

I've used everything from COBOL and C to Java and VB and I can't say that PHP is particularly difficult.

In my experience it's a lot easier than Java. We had two teams developing a small project, one in Java and one in PHP. The PHP team finished long before the Java team and I was surprised to find that the PHP solution was as fast and used a lot less machine resource to do it.

I agree that there's a lack of consistency but then we have that in human langauges. I found it fairly trivial to remember the exceptions.

4
1
Anonymous Coward

Re: @Robert Long 1

I've used everything from COBOL and C to Java and VB and I can't say that PHP is particularly difficult.

It's not particularly difficult to cobble something together with PHP and have it work, but it'll likely be a maintenance and security nightmare.

In my experience it's a lot easier than Java. We had two teams developing a small project, one in Java and one in PHP. The PHP team finished long before the Java team and I was surprised to find that the PHP solution was as fast and used a lot less machine resource to do it.

For a trivial project such as you describe, then PHP may get you something that just about works in shorter time (although a good Java developer shouldn't take long knocking something up with Spring). But for big projects a properly designed, statically typed language that allows for and has good tooling will always win. That typically means Java or C#.

I agree that there's a lack of consistency but then we have that in human langauges. I found it fairly trivial to remember the exceptions.

Human languages are far more complex and ambiguous than a programming language, so that's no excuse for PHP's awful flaws. As for remembering all or even a reasonable number of the "exceptions" - really? Go read http://phpsadness.com/, http://www.phpwtf.org/ and the "fractal of bad design" page. I suspect you don't even know how flaky the apps you write really are for end users if you think you can remember - and avoid - most of those flaws.

2
0
Silver badge

Wow.

With an actual spec to pretend to follow, we'll no longer have new improved versions that break things written for older versions in annoyingly subtle ways.

Oh, wait... Since this spec wasn't written by the PHP developers themselves, what relevance (if any) would it really have?

13
0
Vic
Silver badge

Re: Wow.

Oh, wait... Since this spec wasn't written by the PHP developers themselves, what relevance (if any) would it really have?

Upvoted, because however much I'd love for you to be wrong, ...

Vic.

1
0
Silver badge

Re: Wow.

"Since this spec wasn't written by the PHP developers themselves, what relevance (if any) would it really have?"

Go ask IBM how their specification for IBM-compatible PCs is doing.

FB is the 800lb gorilla of PHP deployment/usage.

0
0

No improvement needed

It's been my experience that PHP has always worked exactly as coded.

6
0
Silver badge
Trollface

Next release PHP 5.6.1

With everything slightly changed. That'll learn 'em.

Which is probably what would have happened anyway.

4
1

PHP is like democracy

In that it's the worst programming language for the web, except for all of the others.

Perl - I love Perl, but if you want to write code which other people can easily grok, this is not the correct language to do it in.

Java - appeals to enterprise scale application writers perhaps, but the overheads are just too high for typical use cases.

C# - I have a lot of respect for C# as a language, and it's solid for web development, the only problem being that it's a gateway drug leading to Microsoft as a wider environment, which most people don't really want on their webservers.

Ruby / Python / Node.js / Insert name of other trendy contenders - Sure, if you like. But at the moment they all a bit far out to ever see the mainstream appeal of PHP.

So people live with PHP because despite it's quirks and inconsistencies it is fundamentally a relatively sane OO language with syntax which is familiar to anyone with a background in a c-like language.

14
3
Bronze badge

Re: PHP is like democracy

So people live with PHP because despite it's quirks and inconsistencies it is fundamentally a relatively sane OO language with syntax which is familiar to anyone with a background in a c-like language.

PHP may have support for objects but it's a long way from being object oriented. The standard library would have to actually make use of those facilities for a start. As it is it seems a lot of my code begins by placing OO wrappers around the standard library to compensate for that not having been done in the first place.

2
3
Bronze badge

Re: PHP is like democracy

"relatively sane" and "OO" - I do not think those words mean what you think they mean.

For me, this is the definitive summary of PHP: http://eev.ee/blog/2012/04/09/php-a-fractal-of-bad-design/

By combining PHP and JavaScript you end up creating a perfect storm of badly designed but carefully implemented languages. Someone who had worked with both exclusively ( as many web developers have ) would probably think that being insane was a basic feature of a programming language.

11
1

Re: PHP is like democracy

Perhaps you're right, I've never been an OO purist, but it has native support for objects and my previous language of choice was perl which had OO grafted onto it in the most monstrous way imaginable (although I understand that the semi-mythical perl 6 improves on this).

Putting aside high-falutin' arguments about it not being pure OO because it has raw scalars or whatever, it is a language which let's you encapsulate logic using the object oriented paradigm, and so far as I'm concerned discussion beyond that is into the realms of 'how many angels can dance on the head of a pin' navel-gazing.

4
0
Bronze badge

Re: PHP is like democracy

It is a fair point, but once you have used a real OO language like Ruby or Python ( or Java, C#, Smalltalk or whatever else attracts your whimsy ) the shortcomings of PHP's implementation start to become somewhat glaring - it may be no more tacked on than Perl's, but it also doesn't do a lot of things that an optimist might hope for.

That said, it's a few years since I have endeavoured to wrangle PHP's object system into something that resembled a thing a person might be able to use, so it has probably got a lot better than it used to be.

1
0
Silver badge

Re: PHP is like democracy

"PHP may have support for objects but it's a long way from being object oriented."

Same as C++, then.

3
0
Silver badge

Re: PHP is like democracy

...except that PHP's (initial) implementation of Objects was created through a third hand inept description of what Objects are. The whole thing feels like "we've heard about Objects, but barely understood them, therefore we implemented them like this"... and then changed their minds a year later and bodged another layer on top of it all.

0
0
Bronze badge
Boffin

In my experience...

The problem with web development is not the language used, being it PHP, or Java or Perl.

The problem seems to be that a majority (not all) of web developers are very bad developers who barely know the language and have a poor understanding of how to write good code that scales well. Not to mention an appalling lack of knowledge of the underlying platform they are programing for.

One can either write indecipherable crashy crap or write a good/decent piece of code, but 'good/decent' only comes with the programmer's.

Note that I'm not defending PHP's flaws.

13
0
Silver badge

Re: In my experience...

True, but PHP does also hand such developers a pre-loaded gun with an automatic foot sensor.

4
3
Bronze badge

Re: In my experience...

There isn't a language in existence which can protect you from crap developers.

Or am I wrong and there's one out there which produces a message saying "are you sure you want to make 20,000 SQL calls to retrieve that data before filtering through it in software?", or "did you know that what you've typed will guarantee the machine starts swapping?"

5
0
Bronze badge

Re: In my experience...

Can you elaborate on this? In my opinion, and it seems to be shared in this thread, is that there is no good or bad languages, there are good and bad programmers.

I have had experience first hand when trying to deliver some very very nasty code and I was told that it was "barbarian coding"... who then taught then how to use multi-dimensional arrays to make a far more elegant (and fast) solution - though admitedly that was in VB6, but years later, I have seen others doing the same with PHP, but also with Java and C#, and I attempt to pass on my experience.

Currently my personal mindset is that there is rarely a problem with the language (except maybe with Brainfuck that was designed explicitly to be difficult), but bad project spec and scope. If you can visualise the problem and algorithm, language choice becomes a moot point, and every language has it's own gotchas and you learn to work with them. I don't feel that PHP is a foot shooting tool, just it would be nice if the order of function arguments were always coherent, other than that, I have always found it to be a flexible, fast, reliable and forgiving language.

2
1
Bronze badge

Re: In my experience...

The article "PHP: A fractal of bad design" that I linked above is the ideal guide to this issue. The opening metaphor is very accurate indeed and tells you most of what you need to know.

1
1
Anonymous Coward

Re: In my experience...

There isn't a language in existence which can protect you from crap developers.

No, but a well designed one makes it possible to write analysis tools that can point to areas of concern. It can encourage good encapsulation, through contracts (Java interfaces for example) that make refactoring easier. PHP in comparison encourages the writing of unlayered, ball of mud applications that defy cleaning up. Remove some of the restrictions of a language like Java or C#, and you end up with abominations like Groovy on Grails, where they ignore (and the proponents loudly applaud) static typing and decent encapsulation.

2
1
Silver badge

Re: In my experience...

"Can you elaborate on this? In my opinion, and it seems to be shared in this thread, is that there is no good or bad languages, there are good and bad programmers."

There are, however, languages which are a good or bad fit to your problem domain. C++ is not a good fit to web development; but then I'm not really sure what is, although I like the look of Aida running on whichever flavour of Smalltalk you like.

0
0
Silver badge

Re: In my experience...

"The problem seems to be that a majority (not all) of web developers are very bad developers who barely know the language..."

And the good developers stay away from PHP because its virtually impossible to "know the language" well enough to use safely. If I want a back end it's perl or, these days, node.js because I can memorise all the quirks and avoid the danger areas. Frankly, I'd rather write the back end in C++ than in PHP.

0
3
Bronze badge

Re: In my experience...

"No, but a well designed one makes it possible to write analysis tools that can point to areas of concern."

...which is utterly irrelevant if you're surrounded by crap developers.

The thing about PHP is that despite its severely dodgy beginnings, it has belatedly furnished itself with most of the things which make it possible to write a properly engineered project. PHP Composer makes it a breeze to use precisely-controlled versions of third party software in your project. The leading frameworks such as Symfony encourage patterns commonly seen in other languages, and unit testing and BDD is not just easy in PHP but has become part of the furniture. Unlike the abomination of javascript which, having already infected the client-side is now busy burning a swathe through the server side with Node.js, PHP is a safe haven which still offers the clarity of words like 'class' and 'protected', so you don't need to enter the free-for-all of "how shall we try to build a sensible object-oriented system with a prototypal language that allows people to choose their own method of simulating classes.

Sure, it's not perfect. Bless it's cotton socks, the most-used versions of PHP have yet to offer stong type enforcement (or what PHP calls 'type hinting' for fear of upsetting the old-timers) of simple types in methods for those times when it's what you want.

But in the end, PHP has all you need to develop rich, stable, tested, maintainable web applications, and it's kept the things which made it great in the beginning such as its practical and powerful associative array-handling and fabulous range of practical functions. When web developing, base64-encoding is a single function away. As is converting JSON to associative PHP arrays. As is sending a blooming email.

In short, PHP is good enough to engineer good systems. The risk factor of your project is entirely settled within the capabilities of your developers. Immersing bad developers in the environment of Java, C#. C++ or whatever will not in any way protect you from disaster. (Nor will it when they're using PHP).

If you want your project to turn out well, get good developers. Chucking out the PHP isn't the thing that'll make the difference*.

(*the caveat here is that there are plenty of applications where a properly compiled application in full charge of its own memory handling (sorry Java) will run rings in performance terms around PHP, but that's irrelevant for web applications where the largest latencies are often tied to data management or calls to 3rd-party APIs.

2
2

Re: In my experience...

"...which is utterly irrelevant if you're surrounded by crap developers."

Crap developers and great developers aren't the ones we should cater to. Statistically speaking, most of us are average. So to me, the test of a programming language is whether average devs can create safe, working code, and whether their eventual replacements (who are also average) can maintain and extend that codebase.

For my money, PHP* passes this test, provided that the devs religiously use unit testing, continuous integration, etc.

* and this applies to every language, really.

0
0
Anonymous Coward

No, all programming languages are <em>not</em> the same

Just like with protocols/APIs/instruction set architectures/whatever you have. People who feel they are simply don't see the difference between a (good) design and a random combination of bits and pieces. Making a statement like "don't blame the programming language, blame the crap developers using the language" simply means you're the colour blind person who keeps telling us that red and green are not really different colours. It's okay, it doesn't make you less valuable as a human being or anything, but it does severely limit the contribution you can making judging that kind of things.

If you insist on defending crap languages then a slight modification of the argument could make it a bit closer to being true: don't blame the language, blame the crap designers of the language.

And how can you tell the designer of a language/protocol/whatever is probably crap? Often there's a clue in the name. Calling a programming language personal home page is not a good starting point and certainly raises certain suspicions (just as calling a network filing protocol "server message block" instead of, say, "network filing system" does, but I digress).

0
1
Silver badge

Bah!

PHP. Ptui!

No website is worth looking at unless it is scripted using Turbo Hyperventilated Zebulon-6 rev2.3.7 On Tramlinez-2.

At least until next Wednesday, when the beta release of Thunderbox ProtonSplitter 9.3 is promised for the CranezOnCrak framework.

4
2
Bronze badge

lol @ Java

Imagine if Facebook had used Java, it wouldn't actually exist. Would be awesome.

Another day another "tail -f catalina.out", "java.lang.OutOfMemoryError" and "-Xms10000000000G"

"It's an enterprise language bro!" they say. Sigh.

2
0
Anonymous Coward

It's a poor professional that says the tools are to blame.

3
0

POST COMMENT House rules

Not a member of The Register? Create a new account here.

  • Enter your comment

  • Add an icon

Anonymous cowards cannot choose their icon