News for hackers. Stuff that matters.
Re:Why Perl Didn't Win by tobinfricke on Monday June 09, 2014 @12:53AM (#7867086)
But in those languages, the equivalent to ($x == "foo") will return false (almost) all of the time. The poster here says that this expression is true (almost) all of the time in Perl. Why?
Re:Why Perl Didn't Win by mst on Monday June 09, 2014 @03:55AM (#7867416)
Because if you disable warnings, it silently coerces 'foo' to 0.

This is why disciplined (i.e. non-tiny-script-y) perl code starts off with

    use strict;
    use warnings;
just like disciplined javascript starts off with

    /* use strict */
and disciplined C code enables compiler warnings, and truly disciplined C code makes those fatal, just like in perl you can do

    use warnings FATAL => 'all';
If you don't do that, then you get the short script/one liner style behaviour where, just like sed, awk or bash, it assumes you know what you're doing. If you don't, then you should be asking the VM to help tell you when those problems exist, same as 'set -x' in bash is incredibly useful if you don't plan to add '|| exit 255;' onto the end of every command.
Re:Why Perl Didn't Win by mike-cardwell on Monday June 09, 2014 @05:14AM (#7867593)
I've been writing perl for over ten years. I think I learned to stick "use strict; use warnings;" at the top of my scripts on day number 1. God only knows why so many other Perl programmers never learnt this.
Re:Why Perl Didn't Win by kamaal on Monday June 09, 2014 @01:04AM (#7867120)
But what is $x? Integer? String? Character? Some_Object?

How do you evaluate this, depends on the context. Wasn't that the whole point of a dynamic language anyway?

Re:Why Perl Didn't Win by CatMtKing on Monday June 09, 2014 @01:25AM (#7867178)
After learning Haskell, I'm not sure what the benefits of dynamic typing are anymore.
Re:Why Perl Didn't Win by keypusher on Monday June 09, 2014 @01:37AM (#7867202)
No, not at all. Type coercion is orthogonal to type safety.
Re:Why Perl Didn't Win by AlexanderDhoore on Monday June 09, 2014 @03:10AM (#7867354)
Amen, brother! I call this "weak typing". But some others use weak typing to mean different things (like "unsafe typing") [1].

Javascript, PHP and Perl are weakly typed. Smalltalk, Lisp, Python, Ruby... are strong typed. But all of them are dynamic.

[1] http://en.wikipedia.org/wiki/Strong_and_weak_typing#Predicta...

Re:Why Perl Didn't Win by girvo on Monday June 09, 2014 @05:11AM (#7867580)
I love dynamic languages with strong typing. You get most of the dev time developments, but without the inherent subtle bugs that creep in via automatic type coercion.