|
Posted by Dikkie Dik on 12/20/05 18:32
.... Add support for goto. ....
*AAAAAAAAAAAAAARRRGGGHHHHH!*
How can anyone match that with an object-oriented language? Most
object-oriented laguages that have a goto statement only have it as an
ancient left-over. Something to clean out in a cleaner version of the
language. NOT to put it in!
Let me clarify:
In an object-oriented language, you have two independent "axes" of
controlled software modification. "Controlled" meaning that you change
software without introducing bugs in existing software:
- The Open Closed Principle (first axis). "Software should be open to
extension, but closed to modification". In OO languages, this is
implemented through inheritence. If you want to modify something, you
can inherit from an existing class instead of breaking it. So you don't
introduce new bugs in EXISTING code.
- Refactoring (second axis). The structure is changed with Refactoring,
but not the behaviour. And this is tested (with automated tests, called
"unit tests") in every single little step. So you don't introduce new
bugs in existing code because you test it thouroughly on component and
function basis.
If there is one thing that makes simple refactorings overly difficult,
it is goto statements and disguised goto statements like "return" (=
goto end).
But in reaction to your comment:
> If you want PHP to be considered as more than a 'toy' language
> then you must stop behaving like petulant children.
Like Microsoft when they introduced VB .NET? The compatibility between
PHP4 and 5 is far, far better than between Visual Basic and VB .NET. In
fact, I did not encounter one function or statement yet that refused to
run under PHP5.
> You are not improving the language, you are killing it.
On the contrary. PHP could be a *lot* more strict in my opinion. I like
the type hinting in PHP 5, as it saves me a *huge* amount of work in
parameter checking. If you following "design by contract", you either
accept a parameter as valid and do something with it or reject it. Most
legacy code I encounter just accepts anything and hopes it does not
explode. Yuck. I even don't like the automatic string-number conversion.
If I pass a string to a numeric function, there's something
fundamentally wrong with my code. I don't want that covered up by the
language, I want to get a decent error message. *Off course* foreach
should give an error when something other than an array is passed!
> ... That means that you are outnumbered ...
You don't speak for me. My provider supports both PHP4 and PHP5 and I
came in time to get into PHP5 only. Alas, at my work they still use
PHP4. It is taking a giant step back in OO functionality. And, wether
you like it or not, it's their product. You are not in charge. You are
free to start your own open source project. How would YOU like it when
somebody starts shouting you are not even allowed to run your own project?
> ... Please notice that 'breaking existing features' does NOT appear
> in that list.
Times change. Live with it. Acient DOS programs do not run under
Windows. Lots of Windows 3.1 drivers are totally useless for Windows 95.
AutoCAD's ENDSV command now only gives an error message: "Discontinued
command". And THAT's an _awfully_ backwards compatible program. Java has
lots of "deprecated" methods. Even the off-switch of you PC may start a
shutdown sequence instead of just disconnecting the power. You must be
angry every day.
Oh, and I don't expect an update. I'm not surprised if there is one
either, but I don't require it as you seem to do. I don't expect updates
for Windows 98, VB6 or whatever old versions of old programs. Likewise,
I don't expect updates for PHP4. Not even for 5. But as even the PHP
makers are human, there may be some.
> Note here that the removal of undocumented features can
> only be justified ...
No one has to justify a change in a side effect. Undocumented features
are side effects. There is and has never been any guarantee about
undocumented features. It would mean that you were never allowed to fix
bugs!
> The customer is always right
Thanx. I know I am. ;)
Oh, you were speaking about yourself? Well, there are a *LOT* of
customers, so "the customer" does not exist. If he did, it was taylor
made software and you could just pick up the phone.
> ... Providing an elegantly-coded solution, or a technically
> pure solution, is secondary.
Where have you been for the last 20 years? In the 80s, we programmed so
the computer could understand it. Now we program so your computer *and
your colleague* can understand it. Code has grown larger and larger and
is rarely written anymore by one lonely hacker who stays with the
company for 30 years. Legibility is everything.
So, PHP makers, if you are reading this:
Please, please, please, *PLEASE* drop the ternary operator from future
PHP versions! Just read the legacy code I'm confronted with and you
understand why.
> If it ain't broke, don't fix it
Again, where have you been in the last 20 years? If a statement does not
appear to be executed because it "silences" any error condition, you
have a hell of a time finding bugs. PHP code can be very hard to read
because of its un-strictness. When I see a parameter initialised as
FALSE, I assume it is a boolean. I mean, the initialization is also
documentation. You see the parameters in your editor wherever you use
them. But it may be an array, a string, or whatever. But FALSE will not
break the code. You can write monstrous code that coincidentally works
with the parameter types you pass. Now code that is illegible is not
legible by your collegue either, *SO IT IS BROKE*. And, *YES, IT NEEDS
TO BE FIXED*.
Sorry to disappoint you.
Best regards
tony@marston-home.demon.co.uk wrote:
> If you have any PHP scripts which will not work in the current releases
> due to breaks in backwards compatibility then take a look at
> http://www.tonymarston.net/php-mysql/bc-is-everything.html and see if
> you agree with my opinion or not.
>
> Tony Marston
> http://www.tonymarston.net
>
[Back to original message]
|