SitePoint Sponsor |
|
User Tag List
Results 51 to 75 of 174
-
Jul 24, 2005, 12:05 #51
- Join Date
- Jul 2004
- Location
- Gerodieville Central, UK
- Posts
- 446
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Originally Posted by DougBTX
Returning back to namespaces, I agree with Marcus, I don't understand the point of the private class cack, it's much like the final keyword, it's totally evil and no one has any use for it in PHP anyway
-
Jul 24, 2005, 13:27 #52
- Join Date
- Sep 2004
- Location
- Zagreb, Croatia
- Posts
- 830
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Originally Posted by MiiJaySung
-
Jul 24, 2005, 14:05 #53
- Join Date
- Nov 2004
- Location
- Romania
- Posts
- 848
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Originally Posted by MiiJaySung
For raw performance take a look here: http://www.bytonic.de/html/benchmarks.html
I couldn't find a recent benchmark, but a good example is always http://www.walmart.com/ which handles according to them 7 million sessions and 106 million page views per day and it is based on Tomcat and Apache (no fancy websphere or weblogic or jboss).
Next time please provide some real arguments to support your claim.
Ruby doesn't even compile to bytecode (at least Python does, and PHP does too with some help). So you can't expect features like just in time compiling or a HotSpot compiler pretty soon.
-
Jul 24, 2005, 14:07 #54
- Join Date
- Jan 2003
- Posts
- 5,748
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Had no idea that my mobile phone is powered by a Quad processor SPARC server...
-
Jul 25, 2005, 01:41 #55
- Join Date
- Mar 2004
- Location
- Russia, Penza
- Posts
- 265
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Originally Posted by MiiJaySung
I'm currently studying Hibernate code(i think it's a glory of OOP) and this Java verbosity helps to understand its internals much better.
I really miss static typing in PHP, especially when i need to make some major refactoring(e.g changing method signature, etc) which spans many files. All modern editors simplify some tedious refactoring analyzing the code and using static types as helpers, i wonder if PHP type hinting would allow that.
-
Jul 25, 2005, 02:13 #56
- Join Date
- Jul 2005
- Posts
- 194
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Well, weak typing is just bad, I hope they will throw that support away in PHP 5.1 or make weak typing only available through a flag, which is off by default.
-
Jul 25, 2005, 02:28 #57
- Join Date
- Jan 2005
- Location
- Ireland
- Posts
- 349
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Nevermind, I see a limitation in what I posted.
Last edited by Ryan Wray; Jul 25, 2005 at 02:34. Reason: A mistake
-
Jul 25, 2005, 02:33 #58
- Join Date
- Sep 2004
- Location
- Zagreb, Croatia
- Posts
- 830
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Originally Posted by wdeboer
-
Jul 25, 2005, 02:36 #59
- Join Date
- Nov 2004
- Location
- Romania
- Posts
- 848
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Originally Posted by BerislavLopac
That's sweet !
a = 12 + "24"
it's not strong typing
also
a = b + c
where b and c haven't been initialized, that's not strong typing either.
-
Jul 25, 2005, 02:41 #60
- Join Date
- Sep 2004
- Location
- Zagreb, Croatia
- Posts
- 830
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Originally Posted by bonefry
-
Jul 25, 2005, 02:44 #61
- Join Date
- Jan 2005
- Location
- Ireland
- Posts
- 349
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Originally Posted by bonefry
Last edited by Ryan Wray; Jul 25, 2005 at 03:08. Reason: forgot a word
-
Jul 25, 2005, 02:47 #62
- Join Date
- Nov 2004
- Location
- Romania
- Posts
- 848
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Originally Posted by BerislavLopac
In a dynamic typed environment, messages sent to objects are not checked on compile-time, but rather on runtime.
And yes, your example is very good, and proves my point. Read it carefully one more time.
-
Jul 25, 2005, 02:51 #63
- Join Date
- Nov 2004
- Location
- Romania
- Posts
- 848
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Originally Posted by Ryan Wray
"A language is strongly typed if conversions between different types are forbidden. If such conversions are allowed, it is weakly typed."
-
Jul 25, 2005, 03:17 #64
- Join Date
- Sep 2004
- Location
- Zagreb, Croatia
- Posts
- 830
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
However, the most important quote on that page is definitely:
Programming language expert Benjamin C. Pierce has said:
I spent a few weeks . . . trying to sort out the terminology of "strongly typed," "statically typed," "safe," etc., and found it amazingly difficult. . . . The usage of these terms is so various as to render them almost useless.
In my usage:
- Strongly typed (or simply "typed"): when a language has types internally (examples: PHP, Python, Java, C).
- Weakly typed (or "untyped"): when a language stores the values without caring about types (e.g. all values are strings); each operation must internally resolve the implicit type to work with a variable (examples: TCL, Net.Data).
- Statically typed: when a type is bound to the variable as well as to its value. (examples: Java, C).
- Dynamically typed: when a type is bound to values only, and the actual type required for an operation is determined and the value is dynamically converted to it (examples: PHP, Python).
-
Jul 25, 2005, 03:23 #65
- Join Date
- Nov 2004
- Location
- Romania
- Posts
- 848
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Originally Posted by BerislavLopac
Because in Python 12 + "24" isn't allowed. Also in Python, you can't use a variable if it wasn't initialized.
And PHP is definitelly weak typed from all points if view if such term exists.
-
Jul 25, 2005, 03:30 #66
- Join Date
- Nov 2001
- Location
- Bath, UK
- Posts
- 2,498
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Originally Posted by BerislavLopac
Loose:
$seven = 3 + '4';
Strong:
seven = 3 + '4'.to_i
Static:
seven := "seven";
seven := 7; // exception
Dynamic:
$seven = 'seven';
$seven = 7; // no exception
PHP, Ruby, Delphi, PHP respectively.
Later,
DouglasHello World
-
Jul 25, 2005, 03:33 #67
- Join Date
- Sep 2004
- Location
- Zagreb, Croatia
- Posts
- 830
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Each of us is correct. And each of us is incorrect. Nobody is the final authority. Pot-a-to, potato.
-
Jul 25, 2005, 03:34 #68
- Join Date
- Sep 2004
- Location
- Zagreb, Croatia
- Posts
- 830
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
So let's return this discussion to the topic of PHP namespaces. Would it really be so difficult to make an extension with namespaces as proposed by Marcus?
-
Jul 25, 2005, 03:42 #69
- Join Date
- Nov 2001
- Location
- Bath, UK
- Posts
- 2,498
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Originally Posted by BerislavLopac
PHP Code:function require_in($file, $namespace) {
$content = file_get_contents($file);
$content = str_replace('all_class_names',
"$namespace_all_class_names",
$content);
eval($content);
}
Once we have that, we can worry about adding the _once_ in require_once_in, then we can worry about caching the whole lot to the file systm so we can do require $file if file_exists.
DouglasHello World
-
Jul 25, 2005, 03:52 #70
- Join Date
- May 2003
- Location
- The Netherlands
- Posts
- 391
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Wouldn't be easier to use a Register/ObjectFactory and store the registered objects under a common array key that would function as a fake namespace?
-
Jul 25, 2005, 04:02 #71
- Join Date
- Jan 2005
- Location
- Ireland
- Posts
- 349
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Originally Posted by DougBTX
I don't imagine the overhead of doing like that would be worth it. But, if that was the way, maybe regular expressions could probably be used to work it all out.
PHP Code:preg_replace('/^class (.*)/', 'class '. $ns .'_$1', $content);
, but you get what I mean.
Too much of a hack for my liking.
-
Jul 25, 2005, 04:06 #72
- Join Date
- Nov 2001
- Location
- Bath, UK
- Posts
- 2,498
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Originally Posted by nacho
index.php
PHP Code:require('foo.php');
require('bar.php');
PHP Code:class Klass {
function hi() {
echo 'hi';
}
}
PHP Code:class Klass {
function bye() {
echo 'bye';
}
}
I wonder if anything in the Simple Test mock library could handle this?
DouglasHello World
-
Jul 25, 2005, 04:12 #73
- Join Date
- Nov 2001
- Location
- Bath, UK
- Posts
- 2,498
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Originally Posted by Ryan Wray
A better fix would be to extend the extension so that this code works:
PHP Code:namespace ns {
require('foo.php');
}
$foo = new ns:Foo();
DouglasHello World
-
Jul 25, 2005, 04:13 #74
- Join Date
- May 2003
- Location
- The Netherlands
- Posts
- 391
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Originally Posted by DougBTX
You're absolutely right, my mistake. I was trying to avoid the ugly eval function ...
-
Jul 25, 2005, 04:44 #75
- Join Date
- May 2005
- Location
- Finland
- Posts
- 608
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Originally Posted by DougBTX
Bookmarks