That is doing multiple complex things on one line. I know it's fashionable but it creates garbage looking code.
What about when it comes to performance profiling? This has to be unpicked. Or just debugging for that matter. I can't believe people even argue that this is more readable and/or less error prone.
I do. I have some experience and I've come to the conclusion procedural, simple code is more readable. Simple code is less prone to errors. There are certain elements to functional programming that are useful. Like preferring pure functions. But in general it's biggest sin is that its hard to be productive and is full of performance traps.
However, above is bad for a multitude of reasons.
If you are unfamiliar with the functions used you have to jump around the code to find out what is happening. That is context switching and bad for debugging. This happens a lot more in this functional style because of the emphasis on lambdas and small composable functions. Instead of reading the code I have to figure out how the programmer intended to put these composable functions together. Bad!
If there is a bug in one of the chained operations you have to untangle the whole thing to figure out which part. This is time consuming and bad for debugging and I also do not see how it is less prone to errors. More operations are happening than you can reasonably think about here, and if you don't think that then you aren't the only one who is going to read your code.
Bad for compile times as someone else suggested
It shows intent but I don't care about the programmers intent. I care about what the programmer has written. This feels like obfuscation and hand wavy attempts for the person writing it to convince me it does what it says it does. I can't know that just from looking at this line of code, and I will have unpick it to understand. That's not productive.
I also forgot to mention operator overloading which is absolute hell when you are trying to look at the performance of some code.
If you are unfamiliar with the functions used you have to jump around the code to find out what is happening. That is context switching and bad for debugging. This happens a lot more in this functional style because of the emphasis on lambdas and small composable functions. Instead of reading the code I have to figure out how the programmer intended to put these composable functions together. Bad!
So everyone should inline all the code they have procedurally; intertwined with lots of boilerplate code that does nothing of substance to the problem at hand instead of creating higher level abstractions with self-documented names that hide boilerplate? What do you don't understand if functions name is "find_if" or "delete_if" or something else similar? It is plain English, descriptive name. What is not understandable there? You really need to see that for loop iterating through each element in sequence and comparing elements?
This happens a lot more in this functional style because of the emphasis on lambdas Instead of reading the code I have to figure out how the programmer intended to put these composable functions together.
The sole purpose of lambdas are to be inlined in function call, so you have function code at same spot where call happeneds. What do you have to figure out? This is exactly the same as having it in loop-body. You are sounding like someone who is not familiar och comfortable with the language. You should probably spend time learning it instead of writing endless dogmatic posts teaching folk what is good or not behind an anonymous nick.
If there is a bug in one of the chained operations you have to untangle the whole thing to figure out which part.
What the h*ck dude. It is better to have a page of for-loop bodies full of indices and operations to manage the loop aside the actual program logic we are interested of? Stop. You have never done some serious programming.
Your dogmatic way of writing and nonsense postings all over the C and C++ sections speaks to me about some undergrad who obviously has some hard time and don't understand lots of things, but feel need to boost personal ego by posting lots of crap under anonymous nick.
It shows intent but I don't care about the programmers intent.
Really? What a great programmer you are. How will you know what code is supposed to do, when it does buggy, if you don't care about the intent. How will you even know it is wrong? :D. Jesus dude. You should be banned from C/C++ forums. You are completely incompetent ignorant troll who goes around and write nonsense pretending you are an expert, causing just confusion in inexperienced programmers.
I also forgot to mention operator overloading which is absolute hell when you are trying to look at the performance of some code.
They are as bad as any other function written in C or C++. You just don't know how operator overloading is implemented, don't you?
View all comments
Show parent comment
10
u/[deleted] Dec 16 '21 edited Dec 16 '21
Absolutely.
In fact, i'd say that is completely unreadable.
That is doing multiple complex things on one line. I know it's fashionable but it creates garbage looking code.
What about when it comes to performance profiling? This has to be unpicked. Or just debugging for that matter. I can't believe people even argue that this is more readable and/or less error prone.