SitePoint Sponsor

User Tag List

View Poll Results: Static Typing:

Voters
45. You may not vote on this poll
  • Yes

    11 24.44%
  • Maybe

    2 4.44%
  • No

    30 66.67%
  • Don't Care

    2 4.44%
Page 4 of 4 FirstFirst 1234
Results 76 to 85 of 85
  1. #76
    Coding and Breathing CoderMaya's Avatar
    Join Date
    Feb 2008
    Location
    Atlit, Israel
    Posts
    470
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Oh why oh why do you not think things over before you say them. "You're still young" haha. Yeah, you know how you just made yourself look, right?

    Properly explained:
    Just because we want to have a bit more organized way of code-writing in PHP, does not mean we want to use Java and its repulsing compiled website creation.

    "Oh yeah!? You want static typing in PHP? Go use Java then, hahaha!"

    ...

    Can you be a bit more serious than that please? There is a valid argument up for discussion here.
    Learn about the new Retro Framework
    Code PHP the way it was meant to be coded!

  2. #77
    SitePoint Enthusiast WMX's Avatar
    Join Date
    Sep 2008
    Posts
    94
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The only reason to make PHP statically typed would be if we're going to see a large increase in speed/performance.

    Or here's another idea-- allow dynamically typed variables as currently are allowed, but also allow statically typed variables. If you declare
    PHP Code:
    $x 1
    then let it be represented as a string internally with the overhead hit of casting it to an int when you use it in a comparison for example, but then if you declare $x like this:
    PHP Code:
    int $x 1
    then let it be represented as an int internally which would give it a performance boost, while at the same time not allowing you to change its type. If you later try to assign
    PHP Code:
    $x 'a'
    it would have to give you a syntax error. Just an idea, don't know if it would be a good move though.
    ~

  3. #78
    SitePoint Guru BerislavLopac's Avatar
    Join Date
    Sep 2004
    Location
    Zagreb, Croatia
    Posts
    830
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It wouldn't.

  4. #79
    SitePoint Enthusiast WMX's Avatar
    Join Date
    Sep 2008
    Posts
    94
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by BerislavLopac View Post
    It wouldn't.
    Well that would depend on how the interpreter is implemented, wouldn't it.
    ~

  5. #80
    eschew sesquipedalians silver trophy sweatje's Avatar
    Join Date
    Jun 2003
    Location
    Iowa, USA
    Posts
    3,749
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by WMX View Post
    Well that would depend on how the interpreter is implemented, wouldn't it.
    No, I agree with BerislavLopac, it wouldn't matter how it was implemented, it would be bad for PHP.
    Jason Sweat ZCE - jsweat_php@yahoo.com
    Book: PHP Patterns
    Good Stuff: SimpleTest PHPUnit FireFox ADOdb YUI
    Detestable (adjective): software that isn't testable.

  6. #81
    PHP/Rails Developer Czaries's Avatar
    Join Date
    May 2004
    Location
    Central USA
    Posts
    806
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by WMX View Post
    Well that would depend on how the interpreter is implemented, wouldn't it.
    I too think this is something PHP should never do. If PHP did this by default, it would probably be the day I stop using it.

  7. #82
    Theoretical Physics Student bronze trophy Jake Arkinstall's Avatar
    Join Date
    May 2006
    Location
    Lancaster University, UK
    Posts
    7,062
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Exactly. We're talking about optional extras here.

    For example:
    PHP Code:
    <?php
    $x 
    "hello";
    $x 1;
    $x true;
    int $y 1;
    $y++;
    $y 'a'//ERROR
    An option to do it would be a godsend. And yes, it would speed up massive, resource-hungry applications tenfold. Currently, every time you access an integer - it needs to be converted from a string to said integer, the function applied to it and then it is converted back. A simple addition isn't 1 step, it's 3.
    Jake Arkinstall
    "Sometimes you don't need to reinvent the wheel;
    Sometimes its enough to make that wheel more rounded"-Molona

  8. #83
    SitePoint Zealot
    Join Date
    Feb 2008
    Posts
    109
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    But does that operation need to be sped up?

    By far the biggest bottleneck in a web application is... the Web itself. Saving a few CPU cycles here and there is hardly relevant to this environment.

    DM

  9. #84
    SitePoint Enthusiast WMX's Avatar
    Join Date
    Sep 2008
    Posts
    94
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by sweatje View Post
    No, I agree with BerislavLopac, it wouldn't matter how it was implemented, it would be bad for PHP.
    Quote Originally Posted by Czaries View Post
    I too think this is something PHP should never do. If PHP did this by default, it would probably be the day I stop using it.
    I grew up with C so declaring types really wouldn't bother me. At the same time, I don't think it's necessary for PHP. All I was arguing was that the interpreter could be built in such a way as to make typecasted variables quicker to evaluate than non-typecasted vars.
    ~

  10. #85
    SitePoint Enthusiast WMX's Avatar
    Join Date
    Sep 2008
    Posts
    94
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by arkinstall View Post
    An option to do it would be a godsend. And yes, it would speed up massive, resource-hungry applications tenfold. Currently, every time you access an integer - it needs to be converted from a string to said integer, the function applied to it and then it is converted back. A simple addition isn't 1 step, it's 3.
    But in any given application there are probably other bottlenecks that would need to be addressed before this type of minuscule optimization.
    ~


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •