PHP Finally Getting a Formal Specification 180
itwbennett (1594911) writes "Despite becoming one of the most widely used programming languages on the Web, PHP didn't have a formal specification — until now. Facebook engineer and PHP core contributor Sara Golemon announced the initiative at OSCON earlier this month, and an initial draft of the specification was posted Wednesday on GitHub."
Comment removed (Score:4, Insightful)
Re:its why devs cringe. (Score:5, Insightful)
Python has emerged a juggernaut to contend with in RESTful coding environments.
Putting aside the whole whitespace debate(*), I'm pretty sure that python has its own list of issues. Maybe not to the same extent as PHP, but they exist.
* For which I personally do have trouble with python - I want the computer to bend to my will, not the other way around.
Re: (Score:2)
Putting aside the whole whitespace debate(*), I'm pretty sure that python has its own list of issues. Maybe not to the same extent as PHP, but they exist.
Picking a programming language is like picking an application, though. It's not about picking the syntax. That's not particularly relevant unless you're looking at Brainfuck or INTERCAL or GW-BASIC. You start by deciding what capabilities you need. There are inevitably several choices that meet your technical requirements, so in the end you're picking a language based on whatever set of limitations and issues you're willing to work with.
Re: (Score:2)
Then I did it 30 years wrong.
Picking languages by syntax, shame on me.
Perhaps I should now try a Lisp like language finally?
Wtf, what nonsense ... what language has a capability another language has not? Wow, now we are at language paradigms, functional, oo etc.
A language should either be a DSL or oo or at least functional, if it is neither, it is close to useless (yes, that includes C) and I certainly won't use a language that hurt my eyes and where I have in simple situations to think about 'syntax'.
Factors that force choice of language (Score:2)
We live in a world with enough languages that pure technical constraints are unlikely to limit you to a single language.
But there are more than enough political constraints on developers to force their language choice. For example, Windows Phone 7 and Xbox Live Indie Games platforms could run only verifiably type-safe, .NET CF-compatible CIL, which in practice meant C#. In the applet era, you needed a language that compiled to JVM bytecode. In the Flash era, you needed a language that compiled to AS3 bytecode. Nowadays, the client side of a web app needs to be in JavaScript. And for a long time, entry level web hosting with
Re: (Score:2)
- it utilisies the very thing that we do in other languages where it isn't necessary to make our code clear.
Except it imposes a burden on the developer, which, in sane languages, can be handled with a single click on the the pretty-print button.
This argument drives me crazy. It completely ignores *every other factor* that affects code legibility. I've even seen Python zealots argue that all Python code readable because indentation is enforced. What a joke! I've seen plenty of illegible Python code.
And yes, when the indentation level changes by more than one level, it's significantly more difficult to read tha
Re: (Score:2)
Of course it's possible to write illegible code in Python. After all, it is possible to write FORTRAN in any language.
Re: (Score:2)
Imagine, if you will, a mix of tabs and spaces that place two lines the same distance from the left-margin, yet, to Python, are at different indentation levels.
Visually identical means exactly that -- no visible distinction between the two programs. Take two screen-shots, they'll be identical down to the pixel.
Not 'similar'. Not 'really really close'. Identical.
It's not something you can defend. Which is funny, considering that it's not even the worst problem caused by Python's absurd use of whitespace.
Re: (Score:2)
Putting aside the whole whitespace debate(*), I'm pretty sure that python has its own list of issues.
My understanding is that Python's two biggest issues are a lack of static typing (justifiable, but annoying) and the ability to use arbitrary objects as dictionaries. The latter causes significant issues when trying to optimize code, because something as simple as reading a value from a property becomes a hashtable lookup.
Re: (Score:3)
Most high level scripting languages (can't speak for PHP, but it's true for Perl, Ruby and Python) implement simple user defined objects as dictionaries. That said, the lookup cost, while obviously much higher than pre-compiled v-tables, are not as expensive as you might imagine; attribute access uses interned strings, and strings cache their hash code on first hash. If you don't actually have to recompute the hash, and equality checks are (for attribute lookup) a simple reference identity test, the CPU cos
Re: (Score:2)
Nice to know how that works, but ordinary languages like C++ and Java etc. don't need a v-table to access attributes.
The offset into the 'record' is calculated by the compiler, so accessing it is just 'base pointer' + 'offset'. Like in Pascal and any other language supporting something like a 'record'.
Re: (Score:2)
Re: (Score:2)
Re: (Score:2)
Re: (Score:2)
Re: (Score:2)
I'm pretty sure that python has its own list of issues. Maybe not to the same extent as PHP, but they exist.
Python's problems are far broader and deeper than PHP's. At least with PHP, there isn't anything fundamentally wrong with the language. Python, on the other hand, is beyond salvation.
Just one example: The whitespace issue isn't simply a matter of personal preference. It's why Python will NEVER have anonymous functions without laughably absurd limitations.
Re: (Score:2)
Re: (Score:2)
Putting aside the whole whitespace debate(*)...
* For which I personally do have trouble with python - I want the computer to bend to my will, not the other way around.
Do you only use languages that let you choose the language keywords? Surely there is leeway in how much bending to your will that you demand of a language.
If you indent your C, PHP, Java, or whatever else sanely, then you will have no issues with Python indentation rules. They are just the sane C rules, but enforced.
Re: (Score:2)
The whole semantic-whitespace thing in Python is genius if you think about it. I mean, it's horrible - awful to use, makes a hash of copy&paste and makes emailing code around (which I guess is a bad idea but anyway) impossible. BUT, and this is the genius part, one of the endless will-never-be-settled arguments that programmers love to have is the one about indentation. If you build a position on this argument actually into the syntax of the language, then the language will always be part of the argumen
At last (Score:3)
I wonder if my favorite bug/misfeature will make the cut and be enshrined forever, because it's *fun* when a successful database instruction throws an exception.
PHP Finally Getting a Formal Specification (Score:5, Funny)
Re: (Score:2)
Is it "Formal Specification" or "Specification Formal"? Will the process take the form of "PHP to Formal Specification" or will it be "Formal Specification from PHP"? How about "php2spec"?
Re:PHP Finally Getting a Formal Specification (Score:5, Funny)
Re: (Score:2)
Re: (Score:2)
Re:PHP Finally Getting a Formal Specification (Score:5, Funny)
Full specification text: (Score:3, Insightful)
PHP Formal Specification:
1) Don't use PHP.
Re:Full specification text: (Score:5, Funny)
PHP Formal Specification:
1) Don't use PHP.
No wonder you're getting modded down if you think that's a formal specification! C'mon:
1. Abstract.
Don't use PHP.
2. Conventions used in this document.
The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT",
"SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this
document are to be interpreted as described in RFC-2119
3. Normative Guidance for the Use of PHP
One MUST NOT use PHP.
Re: (Score:3, Funny)
Re: (Score:2)
Bitter tears of regret.
Re: (Score:2)
Look at any better languages like Python or Ruby lately?
Python is not only simpler than PHP.. its actually designed.
PHP is the garbage of programming languages.. today's BASIC.
If Dijkstra were alive today he'd say that PHP causes brain damage.
Here it is.. (Score:2)
I formally specify PHP to be crap!
Re: (Score:2, Insightful)
Not really.
If you don't have a formal specification and you have two implementations that do different things, there is no way to know which is correct.
Besides, not having a specification is what led to PHP being such an ad-hoc mess in the first place.
Re: (Score:2)
Besides, not having a specification is what led to PHP being such an ad-hoc mess in the first place.
Yeah, but unfortunately it's *way* to late in the day to avoid having to retain (and, ironically, formalise) the ad-hoc mess without breaking countless existing programs.
The most notorious example being one of the simplest, but also the most obviously naff; the fact that the ternary "?:" operator has incorrect precedence in PHP (compared to every other C-derived-syntax language). This quite obviously *was* a fsck-up early on (IIRC they said as much), but will always have to be kept in, an unwelcome remind
A clean break is needed, like "Visual Fred" (Score:2)
Re: (Score:2)
Let's be honest; VB.Net was a good example of one that *didn't* succeed. It was very different to VB6, effectively a whole new environment and tech tied together with a similarly-syntaxed language, a
Re: (Score:2)
Re: (Score:2)
Not all that well in Python's case, but if 2.6 sucked as bad as PHP does now, there might be more urgency. And Perl 6 might get a bit more traction when and if it starts existing.
Re: (Score:2)
That is BS. In order to create a second implementation, you need an _exact_ specification. It being a formal specification is completely optional.
Re:Formal specifications are pretty useless for th (Score:5, Informative)
A formal specification is useful for the implementers of the languages to guarantee that your code runs the same across all implementations. It is pretty important. It should define all use cases possible and highlighting the "undefined" use cases.
Re: (Score:2)
BS. A formal specification is needed if you want to use automated theorem proving to prove properties of the language or if you want to generate compilers automatically. For specifying how an implementation works, you need an exact specification, but that can well be (and usually is) an informal one.
Come on people, does nobody know basic CS terms anymore?
Re: (Score:2)
This is Slashdot so ... probably not.
Re: (Score:2)
Well there is "formal" as in the "rigorous" and "official" sense and then there is "formal" in the Formal Languages sense. The article does not mention which one is being built, I assumed it was the first, not the latter. Honestly even PHP people have more to do than proving theorems about PHP.
Re: (Score:2)
Formal language specification isn't meant to be perused with a cup of coffee in one hand. It's primary purpose is that you can use it to prove that your implementation of the language does what the language specs say it's supposed to do. Your "informal (but exact) specification" doesn't do "a much better job" at that. It can't do that job at all.
Re: (Score:2)
Oh? And which language implementations do you know that actually have such a proof? For real world languages and implementation, the number is likely "zero" as most languages do not have a formal specification that could be used as starting point in the first place.
And here is one more hint from the real world: Nobody proves compiler correctness using formal methods for real languages, because nobody can pay the huge amount of money that would cost or wait the few decades it would take. Instead there is thi
Re: (Score:2)
Doubtless true - but imagine how much better the world of practical day-to-day computing would be if we *could* prove compilers to be correct. I don't disagree that formal methods are more or less useless for real-world problems today, but does that mean that we shouldn't continue to investigate them? I hated my formal methods class when studying Computer Science at uni as much as the next guy (well, I guess some people probably enjoyed it), but unless there's some reason that such methods can never be appl
Re: (Score:2)
The point, as I see it, is: what with the mess PHP was (and is [sorry I remain scpetical]), it must have been a humbling,
and as such deserving, experience on the part of the PHP developers. Let's see where that leads to.
As I used to say: you can do great things in PHP in spite of PHP. In that regard, the language is unique.
Re: (Score:2)
Well, it certainly is a good thing that they try to put this language on a solid basis. It is used in far too many places to remain without a specification.
Re: (Score:2)
an informal (but exact) specification does a much better job.
Informal and exact are mutually exclusive, pretty much by definition.
Re: (Score:2)
They are not. In fact, not at all. Most of mathematics is done informal, yet exact. Of course some intelligence is required on the side of the user and the writer.
Re: (Score:3)
Yes, very much so. Most languages do not have formal specifications.
Re: (Score:3)
I should also add that what they are doing is at best a "semi-formal specification". Still pretty clunky.
Re: (Score:2)
I should also add that what they are doing is at best a "semi-formal specification". Still pretty clunky.
That seems appropriate considering the topic.
Re: (Score:2)
Lucky me, that I only used (except for PHP) languages that have a formal specification.
If you know so many languages that have none (we are talking about programming languages, not computer languages, right?) do you like to point some out?
Re: (Score:2)
You very likely have used not a single language that has a formal specification. That is because there is not a single mainstream language that has one. The only language with a formal specification I know is Algol68.
Re: (Score:3)
-Chris
Re: (Score:2)
What bizarre notion of "formal standard" are you holding on to that would exclude the C standard? It has a formal standardization process complying with the requirements for ISO/IEC publication.
An informal standard is "what some guy wrote", like the K&R C book (which really was used as a standard by compiler writers before the formal standard, and worked well enough for a while).
Re:Formal specifications are pretty useless for th (Score:5, Informative)
A formal specification is a specification done in a formal specification language. There is no other meaning of that term. The people claiming they are doing a "formal" specification likely confused this with "exact". These two concepts are orthogonal. A formal specification can be inexact (or even unsound), while an informal specification can be exact (and sound).
A "formal standard" is something else, it usually refers to a more-or-less exact and complete _informal_ specification that is uniquely identified by its designation. The main difference is that in theory, you could check a formal specification for soundness using an automated theorem prover. Or you could automatically generate a compiler from it. An informal (but possibly exact) specification does not allow that, as it needs a human in the loop.
Re: (Score:2)
I beg to differ.
First of all C's syntax was defined or described in a graphical way. That is as formal as any 'formal specification language' secondly: the word formal is not the point, the point we are talking about is 'specification' ...
Or how do you define a 'formal specification language' used to write a 'formal specification' for another language? Do you really have a 'formal meta specification language' to be able to define the 'formal specification language' to be able to define 'the language'? Or do
Re: (Score:2)
It is "as formal as in a formal specification language" exactly if it is done in a formal specification language. There really is no other way. And yes, "formal" is very much the central and most important point if somebody claims to have a formal specification. The "formal" is not a modifier to "specification", a "formal specification" is one very specific thing. I think you have no clue what "formal" actually means. Your second paragraph demonstrates that. Maybe stop commenting on things you do not unders
Re: (Score:2)
I am not confused at all. I never wrote "formal language", I wrote "formal specification language", which is a completely different beast. You fail.
Re: (Score:2)
I am not confused at all. I never wrote "formal language", I wrote "formal specification language", which is a completely different beast. You fail.
"Formal specification language" is "formal" because it's a formal language [wikipedia.org] in the same sense that any of the many dialects of "regular expressions" or even PHP itself is a formal language. Nothing more, nothing less. The fact that you keep calling C/C++ standard specifications "informal" means that you're just parrotting buzzwords without actually understanding them. When you talk about formal specification languages or any formal languages [wikipedia.org] at all, the word "informal" is inapplicable because it's a complete
Re: (Score:2)
A formal specification is a specification done in a formal specification language. There is no other meaning of that term.
What, there are language specs that don't have an EBNF or similar for valid statements in the language? Seems odd.
theory, you could check a formal specification for soundness using an automated theorem prover
Ooh, sounds magical. Let me know when you find a theorem prover that is (even "in theory") complete and consistent (and runs in finite time).
Re: (Score:2)
A formal specification is a specification done in a formal specification language. There is no other meaning of that term.
What, there are language specs that don't have an EBNF or similar for valid statements in the language? Seems odd.
If you had the least clue what you are talking about (or actually had read what I wrote), you would know that there are informal specifications around and that this is in fact the normal way to do them. You would also know that putting in some formal grammar does not make a specification a formal one.
theory, you could check a formal specification for soundness using an automated theorem prover
Ooh, sounds magical. Let me know when you find a theorem prover that is (even "in theory") complete and consistent (and runs in finite time).
You throw around big words but do not understand them. Pathetic.
Re: (Score:2)
They are not. But it takes some _actual_ understanding to see that.
Re: (Score:3)
Understanding implies the ability to explain ones position, not merely assert it. You come off like those clowns who go on about proofs of program correctness, but perhaps that's a mistaken impression
Can you give an example of a formal language spec? Are you talking about an actual set of formal transforms to object code or somesuch?
BTW, set-ups like a C compiler written in C are very much in line with Godel statements. There certainly exists source code for which the question "does this compiler compile
Re: (Score:2)
And "fail to read plain English". The C standard is not a formal specification at all. It is a formal standard though. A formal standard is made formal by a formal standardization process. A formal specification is made formal by exclusive use of a formal specification language. Hint: "formal" means two different things here.
Sessh, does nobody know any basic CS terminology anymore?
Re: (Score:2)
Well, if you steadfastly refuse to explain your use of your pet phrase "formal specification language", you'll continue to fail to communicate. Whatever point you're trying to make, no one here outside your head is getting it.
Re: (Score:2)
Re: (Score:2)
That is not possible. The English language is not a formal specification language and hence does not allow the creation of formal specifications using it. ANSI C does not have a formal specification.
Re: (Score:2)
Is somebody promises a "formal specification" they promise something very, very specific. In practice, you usually only need a "specification" and in fact, as I wrote before, a formal specification is typically pretty useless. People just should not try to inflate the perceived quality of their product by using words they do not understand.
Re: (Score:2)
You cannot do formal specifications that way. A formal specification must always be done in a formal specification language, or it is not a formal specification. As I have pointed out, you can do exact non-formal specifications and that is what C and C++ have.
Re:Formal specifications are pretty useless for th (Score:5, Informative)
Yes, which is probably why this is coming from a Facebook engineer. PHP is pretty central to Facebook and Facebook has been re-implementing PHP for many years now. Facebook created a PHP to C++ translator (HPHPc) which has since been deprecated in favor of a new PHP virtual machine; HHVM. So Naturally formalizing PHP is of great interest to Facebook.
Re:Formal specifications are pretty useless for th (Score:4)
An open source version of Hack is available at http://hacklang.org/ [hacklang.org] as part of the HHVM runtime platform, which supports both Hack and PHP.
Also, FBIDE (a web-based Hack development environment) was presented at Facebook's Hack Developer Day [facebook.com],
Re: (Score:2)
Re: (Score:3)
Why binary? (Score:2)
Automatic ahead of time compilation (Score:2)
Then perhaps JIT might not be the best term. Ahead of time compilation managed by the PHP engine could help; it's the same philosophy that APC uses and Python uses when importing a module. I was mostly objecting to the concept of distributing a compiled PHP script for two reasons. First, debugging integration with a library is more difficult if you don't have the library's source in front of you, and second, ABI is even more likely to break between platforms or minor versions than PHP already is.
Six identifiable bullet points (Score:3)
Re: (Score:2)
No, that's a strawman. The the criticism is that languages should facilitate productivity by acting intuitively whenever possible. Language design is to an extent a user interface design for developers. And the number
Re: (Score:2)
, as you can tell from his meticulous list of instances when == is not transitive.
Which highlights his laughable ignorance. He clearly doesn't understand dynamic languages. If you do the same comparisons in other dynamic languages, or others with the relevant type casts, you'll get the exact same results.
Then again, I'm not trying to defend a long-debunked meme. I appreciate the effort you put in to your "rebuttal", but it's laughably incompetent. A bit like the "fractal" article itself.
Re: (Score:2)
Try this in Ruby
Try this in Lua
It's not as if PHP's hidden casting saves you any effort either. If I actually wanted to compare a string to an
Re: (Score:2)
Because reading is difficult for you:
The claim was that == was intransitive. My claim was that, like every other language, transitivity only breaks down when you start to mix types.
Feel silly yet? You should.
As Patman64 already said
And you felt the need to repeat it? Even though his reply was completely idiotic? Why?
Re: (Score:2)
Re: (Score:2)
Here you go:
>>> 1 == 1.0
True
>>> 2 == 2.0
True
>>> 1 / 2 == 1.0 / 2.0
False
Something silly (that you'll, hopefully, understand) to show you what that claim looks like to everyone who's thought about it for at least 30 seconds.
>>> 1/2==1/3
True
A bit more obvious, but to the baffled and the unthinking it looks like Python can't be trusted with simple arithmetic. You've, sadly, fallen for the trap because you bought in to the meme and are thus willing to accept any argument that
Re: (Score:2)
Re: (Score:2)
Actually, it seems that YOU don't know what transitivity is. I'm not surprised. The autodidacts have taken over slashdot.
What you've shown is A == D and B == E does not imply A / D == B / E. Where the hell is the A == B statement?
Okay, basic math for you:
If a=b and c=d then a/c = a/d (as c=d) = b/c = b/d (as b=a and d=c)
Nice try, though. I'm sure your local community college has a remedial math course for you.
Re: (Score:2)
True
>> 1/3 == 1/4
True
>> 1/4 == 1/2
True >> 4/3 == 1/2
False
>> 4/3 == 1/4
False
>> 1/4 == 4/3
False
Re: (Score:2)
And the second half of your post has nothing to do with transitivity either.
As I took great pains to point out. Good job, Captain Obvious.
Now, read it again. Do you see the point I was trying to make?
I'm sure that your local community college also has a remedial reading course.
Re: (Score:2)
If you choose a weakly typed language and are unable to remember how weak typing works, you shouldn't have chosen a weakly typed language in the first place, instead of writing long-ass rants about it.
But it's not like everyone has a meaningful choice. There was a time when a particular weakly-typed language had a near monopoly among entry-level web hosts. "Want Python? That'll cost you extra per month. Want Java? That'll cost you a lot extra per month."
Re: (Score:2)
Re: (Score:2)
I've used PHP for 12+ years. I have always hated how often I have to refer to reference materials because I can't remember the way a function is spelled, order of parameters, etc. I've never been able to put my finger on it exactly, but PHP has always just bothered me with it's inconsistencies. Reading the fractal post has opened my eyes! I've experienced no less than half of the issues listed, some of which I never was able to resolve why (just ended up coding around the issue). Mostly I've gotten use
Re: (Score:2)
Re: (Score:2)
They don't exist. I've asked the "what's wrong with it" question countless times. I've never received an actual answer. I think your six points are about spot on, that's pretty much all the article has to offer.
I disagree with the first point, for obvious reasons. As well as point 5, which is not a language issue. Point 6 would need some clarification as it's completely unsupported. Point 2 doesn't make sense to me. How many languages throw an exception on a parse error? What if the error is in the ha
Re: (Score:2)
No way to turn off the language's loosely-typed comparisons.
I disagree with the first point, for obvious reasons.
True, there's a strict counterpart to ==, namely ===. But what's the strict counterpart to < or switch?
PHP allows the server operator to change program semantics in ways that are annoying to work around, such as not allowing a shared hosting subscriber to turn off "magic quotes" or not following HTTP redirects in libcurl.
[This] is not a language issue.
In PHP, if you write a program, how can you be sure that it will work as intended with whatever combination of php.ini settings happens to be in effect on the server on which you deploy the program? For example, if I use the LightOpenID library to authenticate users on a server that has open_basedir set, attempts to authenticate users coming from Yahoo! will fail because Yahoo! implements OpenID with an
Re:Engineer? (Score:5, Informative)
Facebook engineer and PHP core contributor....
My father in law in an actual engineer
As an actual engineer as well, this sort of inflating of titles is a peeve of mine right now. It makes job searches nigh impossible as every position out there has the word engineer in them, and all recruiters seem to be doing nowadays is matching keywords - sort I keep getting emails about 'engineer this' and 'engineer that', when they are totally irrelevant to any sort of genuine engineering position.
Re: (Score:2)
Once I got a call from a recruiter for a circuit board assembly job... because I had "assembly language" in my resume. (And another time I got a call for an IBM 370 Assembler position because of course that's the only assembly language that has ever been invented, but at least that was somewhat less off-target.)
Anyhow, most code monkeys out there are not "software engineers", regardless of what HR calls them. They don't engineer their code so much as poop it out and throw it at each other through the bars
Re: (Score:2)
You're not an actual engineer unless you're rolling your petard up to the castle gate! Don't give me any of this new-fangled train-driver crap. That makes job searches nigh impossible, as recruiters keep bugging be for train-driving jobs when they are totally irrelevant to any sort of genuine siege engine!
Re: (Score:2)
But there is!
In many places, it's illegal to engage in the practice of unlicensed engineering.
We could stand a good crack-down. I'm sick of seeing all the one-skill-wonders running around calling themselves "engineers" to feed their fragile egos. It does a serious disservices to REAL engineers, like the parent.
Hygiene technician (Score:2)
http://youtu.be/VBxm7EP93h4?t=... [youtu.be]