I think we can all agree that declarative coding makes your code more readable. C# LINQ is a great example of this.
I think the greatest danger is that you may lose oversight of what the declarative code is actually doing. You may end up iterating your datasets several times without you knowing it.
Just recently I have been mentoring a colleague on C#. After showing him some examples of C# LINQ, he came to me complaining that C# is awfully slow. I looked at his code where he had been using LINQ amply and it turned out he was iterating his dataset (a couple of million of rows) at least 9 times. A bit of changes brought the execution time from 50 minutes to 5 seconds.
Of course, the real problem here was my lack in teaching but it does show that declarative coding makes your code easier to read but less transparent.
Coder, writer, nonconformist 🤘
Ex-SWE @ Facebook 🤩
Sharing experience and notes on building a career, sharpening coding skills and creating great things 🏆
Thanks for your response and a perfect example Jakob!
I'm not familiar with C#/LINQ but as far as I understand it's a tool that hides the complexity of DB/XML searching behind a slick interface. As we can see from your example, there's another point to be considered especially when it comes to junior developers. Declarative tools can unintentionally hide computational complexity - and provide small to no signs of that something goes wrong.
It is true that there are LINQ providers for databases and for XML. But LINQ also provides a funtional interface for any type of collections, in the same way as you see reduce, map, and filter in other languages.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Thank you for your write-up.
I think we can all agree that declarative coding makes your code more readable. C# LINQ is a great example of this.
I think the greatest danger is that you may lose oversight of what the declarative code is actually doing. You may end up iterating your datasets several times without you knowing it.
Just recently I have been mentoring a colleague on C#. After showing him some examples of C# LINQ, he came to me complaining that C# is awfully slow. I looked at his code where he had been using LINQ amply and it turned out he was iterating his dataset (a couple of million of rows) at least 9 times. A bit of changes brought the execution time from 50 minutes to 5 seconds.
Of course, the real problem here was my lack in teaching but it does show that declarative coding makes your code easier to read but less transparent.
Thanks for your response and a perfect example Jakob!
I'm not familiar with C#/LINQ but as far as I understand it's a tool that hides the complexity of DB/XML searching behind a slick interface. As we can see from your example, there's another point to be considered especially when it comes to junior developers. Declarative tools can unintentionally hide computational complexity - and provide small to no signs of that something goes wrong.
Thank you for your reply, Oleg.
It is true that there are LINQ providers for databases and for XML. But LINQ also provides a funtional interface for any type of collections, in the same way as you see reduce, map, and filter in other languages.