Python isn't an exception among languages that people in industry actually use.
For "production grade" server software, which is driving the newfound interest in concurrency, the following languages cover 99% of code written in the last 20 years: C/C++/Java/PHP/Perl/Python/Ruby and the Microsoft Stack (C#, VB).
None of them have anonymous closures. (C# might, but it's also newer, and it's not the the prevailing style of concurrency in any case.)
This is basically JavaScript's Scheme heritage showing through. Anonymous closures are old hat for people who went through a CS program teaching Lisp, but they're not by any means standard in industry.
One of the main reasons that none of the languages needed this feature is because the predominant paradigm for concurrency for the last 2 decades was threading, not state machines and callbacks.
Perl and PHP both have closures. In fact, Perl is closer to Scheme/Lisp than most languages (at least Perl doesn't screw up scoping like JavaScript, replace first-class functions with second-class-bastardizations like Ruby, or do whatever Python thinks it's doing with lambda... ugh)
#!/usr/bin/node
function main() {
var a = 1;
console.log(a);
// named closure
function foo() {
a = a + 1;
}
foo();
console.log(a);
// anonymous closure
(function() {
a = a + 1;
})();
console.log(a);
}
main();> There is no such thing as an "anonymous closure". There are only anonymous functions which may or may not create a closure.
Which is exactly what you did: calling an anonymous function which happens to create a closure over variable `a`.