18 ms·
If it's functional (recursion vs imperative loops) most people/organizations will not use it. At this point that is just the reality.
by vvpan 11mo ago
If it's functional (recursion vs imperative loops) most people/organizations will not use it. At this point that is just the reality.
- zaphar 11mo agoHaving loops is not the defining feature that separates functional from imperative. Where did this idea come from? I'm suddenly seeing it in a lot of places.
- gmadsen 11mo agoits a simplification of immutability and its consequences
- vvpan 11mo agoIt is not the defining feature but loss of the loop is one of the most obvious differences for people who look at a functional language Rust has immutability, pattern matching, etc, but it remains an imperative language with "some functional features". Or this is my subjective analysis.
- jlouis 11mo agoYou can be functional "in spirit" more than purely functional. OCaml and Standard ML falls into this category. Ocaml has loops for instance. You might just not see many loops if code is written by OCaml developers, because there's frankly no need to use them in a lot of places. You often want to lift the abstraction level of iteration to an arbitrary data structure such that you get freedom of implementation. See Applicative and Monad.
- int_19h 11mo agoBut, again, loops aren't automatically imperative per se. Consider loop / recur in Clojure for an example. For someone coming from JavaScript, it's not really much different from writing a while loop where every branch has to terminate with an explicit break or continue.
- tome 11mo agoSo is Haskell not functional? Or an imperative language with some functional features? -- ghci> example -- Triangular number 1 is 0 -- Triangular number 2 is 1 -- Triangular number 3 is 3 -- Triangular number 4 is 6 -- Triangular number 5 is 10 example = runEff $ \io -> evalState 0 $ \st -> do for_ [1..5] $ \i -> do n <- get st let msg = "Triangular number " <> show i <> " is " <> show n effIO io (putStrLn msg) st += i where st += n = modify st (+ n) (This is not a trick question. Simon Peyton Jones described Haskell as "the world's finest imperative language" [1], and I agree. This code is written using https://hackage.haskell.org/package/bluefin https://hackage.haskell.org/package/bluefin) [1] Tackling the Awkward Squad: monadic input/output, concurrency, exceptions, and foreign-language calls in Haskell
- bsder 11mo agoI really wish people would quit pushing "functional". People equate that with "My programming is now always a recursive logic puzzle." Talk about "immutable by default". Talk about "strong typing". Talk about "encapsulating side effects". Talk about "race free programming". Those are the things that programmers currently care about. A lot of current Rust programmers are people who came there almost exclusively for "strong typing".