#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2012
    Posts
    11
    Rep Power
    0

    Type safety in PHP


    Hi,

    I am currently working on my final project of my undergraduate study and the project is about type safety in PHP. One aspect of the project examines the opinion of the PHP community on this topic.

    I now need your help. I would be very glad, if you could take 5 20 minutes to fill in my online survey: http://www.q-set.co.uk/q-set.php?sCode=PGSKQCJUWZVK

    I will publish the deliverables of my project under an open source license. Thus you contribute automatically to an open source project if you fill in the form

    Thanks for your help
    Robert Stoll
  2. #2
  3. Transforming Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    14,115
    Rep Power
    9398
    1. Do you think type safety in PHP should be improved?
    Your survey consists mostly of loaded questions. Of course PHP should be improved! Where's the question about whether I consider PHP to be lacking in this area?

    2. Should the following improvement towards type safety be made?
    PHP Code:
    public function setName(string name){ 
    //...

    The "improvement" is vague, not to mention an incorrect sample of PHP code. Must the variable be of a string type? Is it cast to string if not?

    7. Templates, files which will be included respectively (include 'template.php';) - which improvement towards type safety should be made?
    This doesn't address type safety. It's a question of defining variables on-the-fly. Related, sure, but a different topic.

    I want to introduce shortly my project with the title 'Type-Safe PHP: A compile time approach'.
    ...
    Please consider in the following questions, that an improvement does not include any change to PHP but can be realised with TSPHP [Type-Safe PHP].
    ...
    It certainly would change PHP: you're redefining the syntax for the language. If I were to write for your tool I would not be writing PHP anymore - I would be writing "TSPHP".

    12. If you could wish, in which time should TSPHP (with complete support for type safety) be developed, regardless of whether it is feasible or not?
    Wait... So if the project is unfeasible then do I enter "infinity"?

    13. Which of the following concepts should be supported by TSPHP?
    Enums, generics, operator overloading, properties, object initializers, list-style object initializers, catching multiple exceptions at once... These are all features in other languages. I'll say it again because it seems you've lost track: this is not PHP anymore. C# is cool and all and I really do love it (screw Java), but I also love PHP because it's not C#.

    15. Which IDE do you use mostly (would you define as "your IDE")?
    16. How satisfied are you with...
    What does this have to do with strong typing? I get that later questions are about establishing a background for the interviewee but IDE?

    27. At which trigger point is TSPHP relevant to the PHP community?
    Who am I asking? "The community"? Which one? Made up of what type of people?

    Also, have you seen the Type-checking RFC?
    Also, that site is reeeaaallly slow.
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2012
    Posts
    11
    Rep Power
    0
    First of all, thanks for your answer.

    Originally Posted by requinix
    Your survey consists mostly of loaded questions. Of course PHP should be improved!
    Well, I am sure not everyone will have the same opinion as you have. I read many times statements such as, "no, to complicated", "PHP was always a weak typed system and every attempt to improve it is evil" etc.

    Originally Posted by requinix
    Where's the question about whether I consider PHP to be lacking in this area?
    These question should come once


    Originally Posted by requinix
    The "improvement" is vague, not to mention an incorrect sample of PHP code. Must the variable be of a string type? Is it cast to string if not?
    As mentioned the improvements are not yet applicable in PHP. It's an example how scalar types could be defined for parameters in a later PHP version (or in TSPHP).

    Originally Posted by requinix
    This doesn't address type safety. It's a question of defining variables on-the-fly. Related, sure, but a different topic.
    I mostly agree, I am just curious what people think about this related topic.

    Originally Posted by requinix
    It certainly would change PHP: you're redefining the syntax for the language. If I were to write for your tool I would not be writing PHP anymore - I would be writing "TSPHP".
    Cannot agree on this one, PHP would remain as it is today, but yes, the developer would need to write TSPHP instead of PHP with this approach. Do you agree that we could say, if one want type safety he should use TSPHP if one doesn't care the should stick to PHP?

    Originally Posted by requinix
    Wait... So if the project is unfeasible then do I enter "infinity"?
    Hm... maybe I have asked my question wrong or it's not clear enough. I wanted to say enter your desired time regardless if it is feasible to develop TSPHP in this time.

    Originally Posted by requinix
    Enums, generics, operator overloading, properties, object initializers, list-style object initializers, catching multiple exceptions at once... These are all features in other languages. I'll say it again because it seems you've lost track: this is not PHP anymore. C# is cool and all and I really do love it (screw Java), but I also love PHP because it's not C#.
    You are right, that's not PHP at all and I wanted to know if you miss one of those concepts in PHP.

    Originally Posted by requinix
    Which IDE do you use mostly (would you define as "your IDE")?
    16. How satisfied are you with...
    What does this have to do with strong typing? I get that later questions are about establishing a background for the interviewee but IDE?
    Indirectly it has something to do with type safety. You said you are familiar with C#. I am sure you aware of the support of the language within the IDE.

    Originally Posted by requinix
    Who am I asking? "The community"? Which one? Made up of what type of people?
    I know, it's a realy hypothetical question.

    Originally Posted by requinix
    Also, have you seen the Type-checking RFC?
    Yes I have seen all RFC relating to type safety, but thank you.

    Originally Posted by requinix
    Also, that site is reeeaaallly slow.
    Yes unfortunately. you cannot image how long it takes to set up an online survey and you wouldn't change to another platform either. Futhermore q-set is free and has many good features (as rules, jumping etc) which other services do not provide.
  6. #4
  7. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2012
    Posts
    11
    Rep Power
    0

    Results


    Heya,

    Quite a long time ago (almost a year), I asked you guys to fill in a survey about type safety in PHP which I conducted in context of my bachelor thesis.
    Unfortunately, I did not really have time to publish all results on a website so far but I am happy to announce that you can find the results here now:
    http://tsphp.tutteli.ch/wiki/display...+Safety+in+PHP

    My bachelor thesis serves as a basis of the open source project TSPHP (Type-Safe PHP). You can find further information about it on the wiki as well:
    http://tsphp.tutteli.ch/wiki/display/TSPHP/Overview

    Please don't hesitate if you have further questions about the survey or the project.

    Cheers,
    Robert
  8. #5
  9. Sarcky
    Devshed Supreme Being (6500+ posts)

    Join Date
    Oct 2006
    Location
    Pennsylvania, USA
    Posts
    10,908
    Rep Power
    6351
    Well, I am sure not everyone will have the same opinion as you have. I read many times statements such as, "no, to complicated", "PHP was always a weak typed system and every attempt to improve it is evil" etc.
    See, this is what Requinix was talking about. You are working from the assumption that making the typing stronger would be improving the language. All of your statements refer to "stronger typing" as an "improvement." Many people disagree with that. Of course PHP should be improved. Strong typing would not improve the language. Your questions are loaded because of your bias toward strongly typed languages.

    As mentioned the improvements are not yet applicable in PHP. It's an example how scalar types could be defined for parameters in a later PHP version (or in TSPHP).
    Requinix is asking a question though: What do you propose will happen if an incorrect type is passed into a function? Will it die? Will it attempt a cast to string? This "improvement" is simply adding the word "string" to an existing piece of [invalid] PHP code. What does this actually mean?

    Cannot agree on this one, PHP would remain as it is today, but yes, the developer would need to write TSPHP instead of PHP with this approach.
    Just FYI, you are agreeing with Requinix here. Your new PHP would be a whole new language.


    As for your actual original post, the URL no longer seems to be valid.
    HEY! YOU! Read the New User Guide and Forum Rules

    "They that can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety." -Benjamin Franklin

    "The greatest tragedy of this changing society is that people who never knew what it was like before will simply assume that this is the way things are supposed to be." -2600 Magazine, Fall 2002

    Think we're being rude? Maybe you asked a bad question or you're a Help Vampire. Trying to argue intelligently? Please read this.
  10. #6
  11. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2012
    Posts
    11
    Rep Power
    0
    Hey,

    Originally Posted by ManiacDan
    See, this is what Requinix was talking about. You are working from the assumption that making the typing stronger would be improving the language. All of your statements refer to "stronger typing" as an "improvement." Many people disagree with that. Of course PHP should be improved. Strong typing would not improve the language. Your questions are loaded because of your bias toward strongly typed languages.
    I totally agree with the point that many people disagree , yet some would agree (as the survey shows as well). Nevertheless I still don't see clearly why my questions were loaded tbh. IMO I tried to be as neutral with the questions as possible and I think I managed that quite well. As an example the first question (which was mentioned by Requinix) "Do you think type safety in PHP should be improved?" where the user had the possibility to say "no".
    Originally Posted by Requinix
    Your survey consists mostly of loaded questions. Of course PHP should be improved! Where's the question about whether I consider PHP to be lacking in this area?
    I think someone who answers the above question with "no", states clearly that the language is not lacking in this area. Don't you think so? I interpret it this way at least.
    And for your information (I assume you haven't filled in the survey), if one had answered question 1 with "no", then questions 2 - 9 have been skipped (Requinix must have chosen "yes" or "I dont know").
    So basically, if one said no improvements are necessary then I just asked him if he wants complete type safety (for some people an improvement doesn't make sense but a complete change does) and if he answered this with "no" as well, did not change his opinion after I have introduced my project, then he did not see any further question about type safety and the remaining questions were just to gather demographics and general questions like "Q21 Which of the following concepts should be supported by PHP/TSPHP?", "Q24 Which IDE do you use mostly - would you define as your IDE?" etc.

    Originally Posted by ManiacDan
    Requinix is asking a question though: What do you propose will happen if an incorrect type is passed into a function? Will it die? Will it attempt a cast to string? This "improvement" is simply adding the word "string" to an existing piece of [invalid] PHP code. What does this actually mean?
    Well, it isn't easy at all to write good questions which are concise, not manipulative etc. and I am not a native speaker, that's a disadvantage of course. I am sure I would be able to improve my questions if I would repeat the survey. I see that some questions where too imprecise but that's mainly because I did not want to manipulate the participant and bias him as well.
    As a side notice, TSPHP's compiler would cause a compile error if one tries to pass an incorrect type into a function unless the cast modifier is used and the passed value can actually be casted to the formal parameter type.

    Originally Posted by ManiacDan
    Just FYI, you are agreeing with Requinix here. Your new PHP would be a whole new language.
    That's mostly right. It is a new language but not a whole new one. I tend to think about it as a language on top of PHP. You could see it as an extension or as a very big DSL for PHP where the domain stands for type safety as well. Why? The syntax of TSPHP is almost similar to PHP (additional type definitions are required), you can do almost everything with TSPHP which is possible with PHP expect things like conditional functions (not right now though, the project is still under development) and at the end of the day TSPHP is translated back to normal PHP. TSPHP has not an own runtime environment (in contrast to HHVM for instance).

    Originally Posted by ManiacDan
    As for your actual original post, the URL no longer seems to be valid.
    That's correct, the survey was from December 2012 to February 2013.

IMN logo majestic logo threadwatch logo seochat tools logo