General statistics
List of Youtube channels
Youtube commenter search
Distinguished comments
About
Continuous Delivery
comments
Comments by "" (@defeqel6537) on "Declarative vs Imperative in Functional Programming" video.
Thank you for mentioning the (mental) cost of abstractions! I generally use both styles where I feel they make reading the code easier, and I'm not married to any one style, but some pointers: - complex (/overly generic) declarative statements should still be abstracted with smaller, better named, methods - declarative style becomes much more readable when the language supports piping functions instead of nesting them But as you allude, I think, the bigger the picture the more declarative style shines. If the purpose of the software is to present something of a domain language to the user, considering a declarative style can be helpful.
3
e.g. if your declarative example were to read something like: return dictionary | filteredBy | (word) => 5 == len(word) | convert_to_list it becomes much more readable, at least in my opinion then there is API design in general, the example could also read (might be invalid Python, it's been a while): return filter(dictionary).by(lambda word: 5 == len(word)).then(convert_to_list)
2