Hmm...
Posted Dec 19, 2011 12:45 UTC (Mon) by
HelloWorld (guest, #56129)
In reply to:
Hmm... by khim
Parent article:
Cracks in the Foundation (PHP Advent)
The point is expressiveness, as usual.[...] And all thus additional unneeded manipulations are goodÂ… exactly why?
I don't see any gain in expressiveness here, nor do I see any "unneeded manipulations".
PHP:
$z = strpos($x, $y);
if ($z === false)
do_something();
else
do_something_else($z);
C++:
auto z = boost::search(x, y);
if (it == x.end())
do_something();
else
do_something_else(z);
I dislike languages without static typing because they leave too much to the runtime, but then if we are already in realm of dynamic languages it's stupid not to use the fact that you can return objects of different types to your advantage: why do you use language with dynamic typing or duck typing if you only use things available in statically typed language???
Well, you're raising a good point, and the answer is that one just shouldn't use a dynamically typed language for anything but throw-away stuff. Doing stuff like returning either an int or a boolean spoils the way people think. They start to think that in order to obtain a convenient solution to this problem they need dynamic typing, even though that isn't so.
(
Log in to post comments)