3 ms·
Python did the same for me. Closures was not a new feature as of C# 3.0. It is a part of C# 2.0. The problem is that the syntax is so verbose and horrible in
by rayvega 16y ago
Python did the same for me. Closures was not a new feature as of C# 3.0. It is a part of C# 2.0. The problem is that the syntax is so verbose and horrible in 2.0 that the readability of the code can be quite messy and almost not worth the effort.
C# 3.0 greatly simplified things with the introduction of the lambda function syntax hence why a lot more people have suddenly "discovered" closures in .NET.
When first learning C# 2.0 I had a lot of difficulty understanding how to use delegates with closures mainly because I couldn't get past the syntax. Learning and using Python shortly after helped me tremendously in understanding how closures worked and when to use them because (not surprisingly) the Python syntax is so much cleaner and intuitive. I was able to then transfer and apply this knowledge to C# by cutting through the noise and using closures effortlessly (as needed). When lambdas arrived in 3.0, it was a no brainer.
This experience showed me how being exposed to and learning other programming languages that follow different paradigms can have a positive impact on how you write code in your primary language.