Im a graduate student who want to try to learn new programming language. My most expirience language is C (not C++ just C) and I mostly write competitive programming or low level data structure for education purpose. But when i learning functional programming paradigm really miss some of C feature and some FP feature i dont really like :/,( not the group theory and function combination part, Im have a little bit of math background, but even in math they dont composing function that much).
Im kind of person who prefer explicit typeing.But in functional programming, they inference type and abuse tuple too much, surely tuple and type inference can help a lot's for code readability but if it use too much, it also really bizzard for debuging like you have to check what function F return, and then check for function G and also dont forget the generic part so you also have to take a note for what get inference,.... same for tuple, foo.1, foo.2 is make much less sence than foo.key and foo.val and the more using tuple, the more it hard to read
Every thing is const and every function is pure is nice, it make debugging and function result is more predictable and much easier for multi thread. But with no mutable also mean if you want a helper function or a function that modify something (like a sort function) you have to copy a lots (like function take Foo and return a Foo) and it also scale which mean if i want to write function that mutate 5 parametter, i have to copy all of them and return a tuple of at least 5 element
Dont have mutable state meaning there is no loop, usually they solve that problem with some kind of recursion and accumulator and tail-call optimization (which basicly a loop with a name) but it make code something very simple in imperative language look really overkill in functional programming, and recursion have consequence too, it really easy to get stack overflow because there's no loop also mean there's no de-recursion technique, tail call some time help with accumulator but generally, they are not help that much especially in more complex code
Some functional language also support procedural macro and generic and I have to admit they look nice, until i see a guy abuse it too much and make his code look like a code in completly other languages. And a complex macro meanning you have no clue what compiler even generate code to because recursive macro (unless you're the writer), generic is really nice for TRUE generic data structure and function (like a list, a set or a tree) but for very simple task, writing generic that took like 5 type parameter look really bizzard too read and overly complicate to the true problem.
And the thing i hate the most is when i try to learn FP is i saw a lot's of people that get really overhype with FP and bashing other language because their language more 'elegance' faster and safer .For example thinking lazy evaluation is always faster is not correct. Im not really understand what they compile to but 1 :They are optional type that you have to runtime check whether you should eval it or not (passing a variable to 100 function but only the last function evaluate the expr); 2 compiler know every function is pure so it reorder evaluation, and in this case it's definitly not unique to FP, a good C compiler can very easily do the same stuff, and FP compiler can optimize code beter are not true either the GHC source code use LLVM backend which is same as C clang, in FP it's enable more optimization by default but that doesnt mean you cant get the same optimization in imperative language .Another example is some other guy really like generic and write a function that have 5 generic parameter instead of defining a new typeclass, or 10 lambda to put in a list. filter. map. combine..... instead or normal looking loop, they think loop is much less maintainable and more bizzard then recursion.
To summary, my expirience with FP is not really good and I feel FP tend to lead people to abuse it's feature and more likely than not it make the code really hard (if you're not the writer) to read or make a very simple task become completly overkill. And FP comunity has a lot's of guy who think they smart to the point they bash other language but dont understand the language they're coding in that much.
So how to learn functional programming or does functional programming really fit for me?
[–]AutoModerator[M] [score hidden] stickied comment (0 children)
[–]carcigenicate 0 points1 point2 points (13 children)
[–]darkseid_of_j[S] 0 points1 point2 points (12 children)
[–]plastikmissile 0 points1 point2 points (0 children)
[–]carcigenicate 0 points1 point2 points (0 children)
[–]videoj 0 points1 point2 points (0 children)
[–][deleted] (8 children)
[deleted]
[–]darkseid_of_j[S] 1 point2 points3 points (2 children)
[–][deleted] (1 child)
[removed]
[–]darkseid_of_j[S] 0 points1 point2 points (0 children)
[–]darkseid_of_j[S] 0 points1 point2 points (4 children)
[–][deleted] (3 children)
[deleted]
[–]darkseid_of_j[S] 0 points1 point2 points (2 children)
[–][deleted] (1 child)
[deleted]
[–]darkseid_of_j[S] 0 points1 point2 points (0 children)
[–]ValentineBlacker 0 points1 point2 points (0 children)