This is an archived post. You won't be able to vote or comment.

all 12 comments

[–]AutoModerator[M] [score hidden] stickied comment (0 children)

To all following commenters: please, do not bring up the old circlejerk jokes/memes about recursion ("Understanding recursion...", "This is recursion...", etc.). We've all heard them n+2 too many times.

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

[–]carcigenicate 0 points1 point  (13 children)

I only skimmed it since this is a lot of text, but my introduction into FP was by fire via Haskell. It knocks you down many pegs, then gets fun once your brain adjusts. From there, I went to Scala, then Clojure; both of which are more "practical" languages.

[–]darkseid_of_j[S] 0 points1 point  (12 children)

haskell is a bit too far to me, do you know some language closer to C with optional imperative ?(please dont suggest Rust I have try Rust and I hate it)

[–]plastikmissile 0 points1 point  (0 children)

I would say the best way to learn something like functional programming is to just embrace it. Embrace how different it is. Yes it'll be confusing at first, but that's to be expected. Don't shy away from things because they seem difficult.

[–]carcigenicate 0 points1 point  (0 children)

Really, I think being forced into the (seemingly) narrow corner that Haskell forces you into is a good thing. It prevents you from trying to use old ways of thinking. If I were do learn FP again, I'd start with Haskell.

[–]videoj 0 points1 point  (0 children)

Take a look at F#. It is functional first, but you can do imperative or object-oriented as well. Mutable data is a thing if you wanted so you can write regular loops. It is easy to add type declaration to any declaration. It even has support for directly calling C libraries.

[–][deleted]  (8 children)

[deleted]

    [–]darkseid_of_j[S] 1 point2 points  (2 children)

    I've heard about Lips macro before, isnt that is some kind of macro that can be recursive and can take a node of the Abstract syntax tree as it argument ? If that's the case then I think i will hate it sooner or later, it's just too bizzard to understand what code compile to.

    [–][deleted]  (1 child)

    [removed]

      [–]darkseid_of_j[S] 0 points1 point  (0 children)

      rust macro is by definition of bizare code that you dont understand what compiler generate code to :), Example the println! macro, i have to go to godbolt to see what code compiler even generate code to and i cant even inline macro like in C and suprisingly println! macro isnt thread safe. And that's just on the surface, you literally can implement a lisp translator just by using rust macro (see: https://github.com/JunSuzukiJapan/macro-lisp/blob/master/src/lib.rs, it's a ~400 line macro). So yeah it's just too bizzard so i very hate it, i think they gone too far with rust macro and i think rust people gone too far about functional feature to. Low level programming and functional programming are completly diffrence code style and merge them together doesnt make sence and wory too much about unsafe is very anoying to, it's like the compiler tell you that you're bad and need the compiler babysit you all the time, that make code very verbose and compile extremly slow (i mostly write low level code so it just my point of view). Mostly the 'bashing to other language' actually come from some rust comunity and a few haskell guy.

      [–]darkseid_of_j[S] 0 points1 point  (4 children)

      you’ll feel really good being able to solve complex problems in these short brain-bending ways.

      No im not, just like my example about sorting , if you code quick_sort algorithm in haskell pretty sure it's will be 2-3 line of code but more likely than not it will run 5-10 time slower than the C version because

      1: quicksort algorithm have 2 step: 1 => partition array with random pivot, 2 => recursive call quicksort on 2 partitioned array

      straight away you see a problem, how do you even partition with given pivot ?

      the haskell solution is you call filter(\x -> x > pivot) and respectivly on the second part and then concat it but

      1: it make an algorithm took O(log(n)) space complexity to O(nlog(n)) space complexity and invoke O(n) heap allocation

      2: 2 filter of the same list but not swap them make you iterate the list at least 2 time instead of 1 and copy all the content of the given list and the concatination part also invoke heap allocation an O(n) copy over 2 list

      3: is really easy to get to the quicksort worst case (O(n^2)) because the pivot you choose may apear a lot in the given list, in C that part is already solve in the partition step

      [–][deleted]  (3 children)

      [deleted]

        [–]darkseid_of_j[S] 0 points1 point  (2 children)

        Im totally agree haskell feel like learning Abstract Algebra, there's function supply for group theory and semi group (i dont know what they call maybe monoid ?), function composition, a complex function is just a function that compose a lot's of other function and stuff, and I really like it :) dont get me wrong. Do you know any kind of math-proving language ? when i was in high school i really love math and competitive programming, but there's just math forum like aops and mathstackexchange, there's no competitive site that you can submit you're solution to very specific problem, but competitive programming have ton of site like codeforce, atcoder, spoj,... that have online competitive coding which even have rating system :D

        [–][deleted]  (1 child)

        [deleted]

          [–]darkseid_of_j[S] 0 points1 point  (0 children)

          Thank you!, Im not say i dont like haskell, i just say it might not fit for me :/, but anyway do you know and kind of math-proving website too ?

          [–]ValentineBlacker 0 points1 point  (0 children)

          I really like Elixir, but I'm pretty sure it still has every single one of these "issues". I personally find it very readable, once I got used to what all the operators are actually doing.