I've been learning javascript recently and, considering its reputation, it doesn't seem all that bad?

I mean, it's much more ridiculous than you might think from https://www.destroyallsoftware.com/talks/wat but, compared to other things I've used professionally (Verilog, microcode, C++, Scala, etc.), it doesn't seem bad with respect to the combination of safety, sharp edges, and performance.

Microcode has fundamentally decent reasons for having a lot of sharp edges, so I'll give that a pass, but,

Wat

with respect to sharp edges, I think js is at least vaguely comparable to C++, Verilog, and Scala and I'd actually rate js as much nicer than Verilog and moderately nicer than C++.

In terms of performance predictability, js seems to be in the same league as Scala (actually better IMO) and one big win is that people's mental models seem closer to reality, e.g., I've seen a lot of Scala people say that Scala has Java-like performance if you avoid immutable data structures, which is very wrong.

Python and Ruby are arguably better points of comparison, but js totally blows them out of the water on performance unless you do really funky stuff on the Python/Ruby side.

In that space, Perl is probably the most widely used thing with performance that's vaguely comparable to js, but Perl is also full of sharp edges. I haven't used Perl seriously since 2010 or so, so I can't compare modern Perl to modern js, but I think it would be surprising if modern Perl was leagues ahead of modern js.

@danluu What makes you feel Perl performance is better than other interpreted langs / vaguely closer to JS? I always enjoy your posting but I do think this point is factually wrong.

@cdleary Hmm, maybe this changed in the past, uhhh, 15 years? I remember benchmarking some basic stuff a long time ago (just boring scripting stuff, not "real" apps or computation) and Ruby and Python were both much slower than Perl.

https://benchmarksgame-team.pages.debian.net/benchmarksgame/fastest/perl-python3.html seems to indicate perl isn't way faster anymore, although I looked at some of the source and it's fairly unidiomatic in both cases, so it's not really what I'd want to see.

Maybe I should replace perl with PHP in the "tweet"?

Perl vs Python 3 - Which programs are fastest?

Perl Python 3 - Which programs have fastest performance?

@danluu @cdleary IIRC the places Perl was fast as a language weren't "fast interpreter", they were "special case in language that gets to mostly stay in C macro-op". Which is a completely viable way to make a fast scripting language! Entirely the point of the Ousterhout dichotomy.

(As my old boss once said "The fastest Lisp is always just the one with the largest set of primitives in its C runtime".)

@graydon @danluu Yeah, I'd find that qualifier technically fair, but also I think would be good to have some key samples in mind to cite. I think a lot of it does come down to the social construct of "would you use e.g. PyPy". One of the funny things about e.g. Python is a lot of usefulness is derived from the ecosystem, as dependent on its C extensions (e.g. numpy, scipy, matplotlib), which can be particularly wed to the CPython implementation. It's a little unfair to race a best-in-class JIT vs an interpreter (Perl or any other) -- they should not generally have similar performance on normal scalar programs, stuff like "whose metaobject protocol is simpler?!" seems likely in the noise at that level. Classic "performance of a language" vs "performance of a particular ecosystem" caveat emptor stuff applies heavily.