Motivated by the latest silly comments on Slashdot, I decided to write a little bit about programming language wars.
Re:other languages
Ovid on 2005-10-18T20:45:00
I think undef would be fantastic if Perl better supported three-value logic. Right now we have true or false. If Perl natively supported "true", "false" and "unknown", many problems could be made simpler.
I did allude to other paradigms (logic programming, to be specific), but I confess that I don't know much about OCaml.
Re:other languages
mary.poppins on 2005-10-19T05:24:01
My unhappiness with undef is that I can never remember whether my functions return undef or not, and what the behavior of the function is when given an undef arg, etc.. In the end, I always end up having to write comments.
Ocaml has a nice distinction between a type "foo" and a type "foo option" -- the latter can be undef, whereas the former is guaranteed to have a value:
let succ_int i = i + 1;;
let succ_int_option o = match o with
| None -> 0
| Some i -> i + 1;;
Re:other languages
Ovid on 2005-10-19T05:37:49
Keep to a strict convention and it's easier to remember. Don't return undef or a false value when you mean false, just return. A bare return will return undef in scalar context and an empty list in list context. By keeping to this convention, you can simplify your code. If you're returning from a ternary operator, use parens:
return;
# or
return $val ? defined $val : ();Personally, I usually return as soon as I know a function will fail and I don't get to the ternary operator too often (though that's not always the case. Depends upon what I'm working on).
That's past tense - it doesn't matter unless the current set of regular expression functionality isn't stable or as fully-featured. If it is, say that, instead of talking about how Perl was great against Java v1.0 (or whatever).Java languished for a long time without regular expressions.
Can (s)he back that up?The regular expression support of languages like Python, Ruby, and even C# trump that of Perl.