Hacker News new | ask | show | jobs
by azangru 1307 days ago
`let` and `const` expand and replace `var`; and make variable declarations more intuitive by removing var's hoisting and adding block-level scoping (which the programmer doesn't need to care about if he doesn't wish to). What this means is that one can just use var if they are happy with it, or use let and const without the var. Not so with Perl. There is no "legacy mode", with all the awkward punctuation of decades ago, as opposed to a much saner "convenient modern mode" in Perl.

(Although I agree that a javascript programmer might get confused by declaring an object or an array as a const and then being allowed to mutate it.)

1 comments

I'm not defending the sigils because they are terrible, but the reason you can't just get rid of them is that they are actually used.

For instance:

my @arr = ("Larry", "Moe", "Curly");

my $len = @arr;

will store 3 in $len. Application codebases and libraries make use of this kind of thing everywhere.

You can find some of the reasoning why in interesting essays like this: http://www.wall.org/~larry/natural.html

Larry Wall was trying to incorporate some natural language features in Perl, unsuccessfully in this case but I would say it went very well in others.